all messages for Guix-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Maxim Cournoyer <maxim.cournoyer@gmail.com>
To: 46028@debbugs.gnu.org
Subject: [bug#46028] [PATCH core-updates 1/2] utils: Add a version-minor procedure.
Date: Thu, 21 Jan 2021 23:51:03 -0500	[thread overview]
Message-ID: <20210122045104.30229-1-maxim.cournoyer@gmail.com> (raw)
In-Reply-To: <20210122044816.30058-1-maxim.cournoyer@gmail.com>

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain; charset=yes, Size: 2268 bytes --]

* 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





  reply	other threads:[~2021-01-22  4:52 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-01-22  4:48 [bug#46028] [PATCH core-updates 0/2] Farewell to PYTHONPATH Maxim Cournoyer
2021-01-22  4:51 ` Maxim Cournoyer [this message]
2021-01-22  4:51   ` [bug#46028] [PATCH core-updates 2/2] gnu: python: Replace PYTHONPATH by GUIX_PYTHONPATH_X_Y Maxim Cournoyer
2021-01-22 13:18     ` [bug#46028] [PATCH core-updates v2] " Maxim Cournoyer
2021-01-25  7:08       ` Maxim Cournoyer
2021-01-29 17:12         ` [bug#46028] [PATCH core-updates 0/2] Farewell to PYTHONPATH Maxim Cournoyer
2021-02-01 18:35           ` bug#46028: " Maxim Cournoyer

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210122045104.30229-1-maxim.cournoyer@gmail.com \
    --to=maxim.cournoyer@gmail.com \
    --cc=46028@debbugs.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/guix.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.