Subject: [PATCH core-updates 1/2] utils: Add a version-minor procedure.

From: Maxim Cournoyer <[email-masked]>
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 <[email-masked]>
 ;;; Copyright © 2018, 2020 Marius Bakke <[email-masked]>
 ;;; Copyright © 2020 Efraim Flashner <[email-masked]>
-;;; Copyright © 2020 Maxim Cournoyer <[email-masked]>
+;;; Copyright © 2020, 2021 Maxim Cournoyer <[email-masked]>
 ;;;
 ;;; 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