[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[bug#46028] [PATCH core-updates 1/2] utils: Add a version-minor procedur
From: |
Maxim Cournoyer |
Subject: |
[bug#46028] [PATCH core-updates 1/2] utils: Add a version-minor procedure. |
Date: |
Thu, 21 Jan 2021 23:51:03 -0500 |
* guix/utils.scm (version-components): New procedure.
(version-prefix): Use it.
(version-major): Likewise.
(version-minor): New procedure.
---
guix/utils.scm | 15 ++++++++++++---
1 file changed, 12 insertions(+), 3 deletions(-)
diff --git a/guix/utils.scm b/guix/utils.scm
index 678954dbfa..cd4e595f7e 100644
--- a/guix/utils.scm
+++ b/guix/utils.scm
@@ -8,7 +8,7 @@
;;; Copyright ?? 2017 Mathieu Othacehe <m.othacehe@gmail.com>
;;; Copyright ?? 2018, 2020 Marius Bakke <marius@gnu.org>
;;; Copyright ?? 2020 Efraim Flashner <efraim@flashner.co.il>
-;;; Copyright ?? 2020 Maxim Cournoyer <maxim.cournoyer@gmail.com>
+;;; Copyright ?? 2020, 2021 Maxim Cournoyer <maxim.cournoyer@gmail.com>
;;;
;;; This file is part of GNU Guix.
;;;
@@ -93,6 +93,7 @@
version-major+minor+point
version-major+minor
version-major
+ version-minor
guile-version>?
version-prefix?
string-replace-substring
@@ -573,10 +574,14 @@ or '= when they denote equal versions."
((negative? result) '<)
(else '=))))))
+(define (version-components version-string)
+ "Return the dot-separated version components as a list."
+ (string-split version-string #\.))
+
(define (version-prefix version-string num-parts)
"Truncate version-string to the first num-parts components of the version.
For example, (version-prefix \"2.1.47.4.23\" 3) returns \"2.1.47\""
- (string-join (take (string-split version-string #\.) num-parts) "."))
+ (string-join (take (version-components version-string) num-parts) "."))
(define (version-major+minor+point version-string)
"Return \"major>.<minor>.<point>\", where major, minor and point are the
@@ -595,7 +600,11 @@ minor version numbers from version-string."
(define (version-major version-string)
"Return the major version number as string from the version-string."
- (version-prefix version-string 1))
+ (first (version-components version-string)))
+
+(define (version-minor version-string)
+ "Return the minor version number as string from the version-string."
+ (second (version-components version-string)))
(define (version>? a b)
"Return #t when A denotes a version strictly newer than B."
--
2.29.2