GNU bug report logs - #50377
[PATCH 0/2] Support 'git describe' style commit IDs in transformations

Previous Next

Package: guix-patches;

Reported by: Marius Bakke <marius <at> gnu.org>

Date: Sat, 4 Sep 2021 18:09:02 UTC

Severity: normal

Tags: patch

Done: Marius Bakke <marius <at> gnu.org>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 50377 in the body.
You can then email your comments to 50377 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to guix-patches <at> gnu.org:
bug#50377; Package guix-patches. (Sat, 04 Sep 2021 18:09:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to Marius Bakke <marius <at> gnu.org>:
New bug report received and forwarded. Copy sent to guix-patches <at> gnu.org. (Sat, 04 Sep 2021 18:09:02 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Marius Bakke <marius <at> gnu.org>
To: guix-patches <at> gnu.org
Subject: [PATCH 0/2] Support 'git describe' style commit IDs in transformations
Date: Sat,  4 Sep 2021 20:08:45 +0200
The first patch makes it possible to pass a 'git describe' style commit
identifier to --with-commit.  The second patch arranges so that it is
used as the package version, sans any leading 'v', if applicable.

Marius Bakke (2):
  git: 'resolve-reference' handles 'git describe'-style commit IDs.
  transformations: 'git describe' style commit IDs are used as version.

 guix/git.scm              | 37 ++++++++++++++++++++-----------------
 guix/transformations.scm  | 34 +++++++++++++++++++++++++---------
 tests/transformations.scm | 19 +++++++++++++++++++
 3 files changed, 64 insertions(+), 26 deletions(-)

-- 
2.31.1





Information forwarded to guix-patches <at> gnu.org:
bug#50377; Package guix-patches. (Sat, 04 Sep 2021 18:11:02 GMT) Full text and rfc822 format available.

Message #8 received at 50377 <at> debbugs.gnu.org (full text, mbox):

From: Marius Bakke <marius <at> gnu.org>
To: 50377 <at> debbugs.gnu.org
Subject: [PATCH 1/2] git: 'resolve-reference' handles 'git describe'-style
 commit IDs.
Date: Sat,  4 Sep 2021 20:10:34 +0200
* guix/git.scm (resolve-reference): Use REVPARSE-SINGLE for looking up
commits.  Rewrite tag-or-commit case to recognize 'git describe' style
identifiers and resolve them as commits.
---
 guix/git.scm | 37 ++++++++++++++++++++-----------------
 1 file changed, 20 insertions(+), 17 deletions(-)

diff --git a/guix/git.scm b/guix/git.scm
index 9c6f326c36..5e52630f5a 100644
--- a/guix/git.scm
+++ b/guix/git.scm
@@ -2,6 +2,7 @@
 ;;; Copyright © 2017, 2020 Mathieu Othacehe <m.othacehe <at> gmail.com>
 ;;; Copyright © 2018, 2019, 2020, 2021 Ludovic Courtès <ludo <at> gnu.org>
 ;;; Copyright © 2021 Kyle Meyer <kyle <at> kyleam.com>
+;;; Copyright © 2021 Marius Bakke <marius <at> gnu.org>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -214,24 +215,26 @@ corresponding Git object."
        (let ((oid (reference-name->oid repository symref)))
          (object-lookup repository oid)))
       (('commit . commit)
-       (let ((len (string-length commit)))
-         ;; 'object-lookup-prefix' appeared in Guile-Git in Mar. 2018, so we
-         ;; can't be sure it's available.  Furthermore, 'string->oid' used to
-         ;; read out-of-bounds when passed a string shorter than 40 chars,
-         ;; which is why we delay calls to it below.
-         (if (< len 40)
-             (object-lookup-prefix repository (string->oid commit) len)
-             (object-lookup repository (string->oid commit)))))
+       (revparse-single repository commit))
       (('tag-or-commit . str)
-       (if (or (> (string-length str) 40)
-               (not (string-every char-set:hex-digit str)))
-           (resolve `(tag . ,str))              ;definitely a tag
-           (catch 'git-error
-             (lambda ()
-               (resolve `(tag . ,str)))
-             (lambda _
-               ;; There's no such tag, so it must be a commit ID.
-               (resolve `(commit . ,str))))))
+       (cond ((and (> (string-length str) 8)
+                   (string-contains str "-g")
+                   (match (string-split str #\-)
+                     ((components ... g+id)
+                      (string-every char-set:hex-digit
+                                    (string-drop g+id 1)))
+                     (_ #f)))
+              (resolve `(commit . ,str)))   ;looks like a 'git describe' style ID
+             ((or (> (string-length str) 40)
+                  (not (string-every char-set:hex-digit str)))
+              (resolve `(tag . ,str)))           ;definitely a tag
+             (else
+              (catch 'git-error
+                (lambda ()
+                  (resolve `(tag . ,str)))
+                (lambda _
+                  ;; There's no such tag, so it must be a commit ID.
+                  (resolve `(commit . ,str)))))))
       (('tag    . tag)
        (let ((oid (reference-name->oid repository
                                        (string-append "refs/tags/" tag))))
-- 
2.31.1





Information forwarded to guix-patches <at> gnu.org:
bug#50377; Package guix-patches. (Sat, 04 Sep 2021 18:11:02 GMT) Full text and rfc822 format available.

Message #11 received at 50377 <at> debbugs.gnu.org (full text, mbox):

From: Marius Bakke <marius <at> gnu.org>
To: 50377 <at> debbugs.gnu.org
Subject: [PATCH 2/2] transformations: 'git describe' style commit IDs are used
 as version.
Date: Sat,  4 Sep 2021 20:10:35 +0200
* guix/transformations.scm (transform-package-source-commit): Look for
'git describe' style IDs and use it as the version if applicable.
* tests/transformations.scm
("options->transformation, with-commit, 'git describe' style version"): New
test.
---
 guix/transformations.scm  | 34 +++++++++++++++++++++++++---------
 tests/transformations.scm | 19 +++++++++++++++++++
 2 files changed, 44 insertions(+), 9 deletions(-)

diff --git a/guix/transformations.scm b/guix/transformations.scm
index 5122baa403..e91bce3808 100644
--- a/guix/transformations.scm
+++ b/guix/transformations.scm
@@ -1,5 +1,6 @@
 ;;; GNU Guix --- Functional package management for GNU
 ;;; Copyright © 2016, 2017, 2018, 2019, 2020, 2021 Ludovic Courtès <ludo <at> gnu.org>
+;;; Copyright © 2021 Marius Bakke <marius <at> gnu.org>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -278,15 +279,30 @@ strings like \"guile-next=cabba9e\" meaning that packages are built using
   (define (replace old url commit)
     (package
       (inherit old)
-      (version (if (and (> (string-length commit) 1)
-                        (string-prefix? "v" commit)
-                        (char-set-contains? char-set:digit
-                                            (string-ref commit 1)))
-                   (string-drop commit 1)        ;looks like a tag like "v1.0"
-                   (string-append "git."
-                                  (if (< (string-length commit) 7)
-                                      commit
-                                      (string-take commit 7)))))
+      (version (cond ((and (> (string-length commit) 8)
+                           (string-contains commit "-g")
+                           (match (string-split commit #\-)
+                             ((components ... g+id)
+                              (char-set-every (cut char-set-contains?
+                                                   char-set:hex-digit <>)
+                                              (string->char-set
+                                               (string-drop g+id 1))))
+                             (_ #f)))
+                      ;; This looks like a 'git describe' style ID.  Drop
+                      ;; the 'v' prefix if applicable.
+                      (if (string-prefix? "v" commit)
+                          (string-drop commit 1)
+                          commit))
+                     ((and (> (string-length commit) 1)
+                           (string-prefix? "v" commit)
+                           (char-set-contains? char-set:digit
+                                               (string-ref commit 1)))
+                      (string-drop commit 1))       ;looks like a tag like "v1.0"
+                     (else
+                      (string-append "git."
+                                     (if (< (string-length commit) 7)
+                                         commit
+                                         (string-take commit 7))))))
       (source (git-checkout (url url) (commit commit)
                             (recursive? #t)))))
 
diff --git a/tests/transformations.scm b/tests/transformations.scm
index 3417c994ec..44fccffcce 100644
--- a/tests/transformations.scm
+++ b/tests/transformations.scm
@@ -1,5 +1,6 @@
 ;;; GNU Guix --- Functional package management for GNU
 ;;; Copyright © 2016, 2017, 2019, 2020, 2021 Ludovic Courtès <ludo <at> gnu.org>
+;;; Copyright © 2021 Marius Bakke <marius <at> gnu.org>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -235,6 +236,24 @@
                    (string=? (package-name dep2) "chbouib")
                    (package-source dep2))))))))
 
+(test-equal "options->transformation, with-commit, 'git describe' style version"
+  "1.0-gcabba9e2"
+  (let* ((p (dummy-package "guix.scm"
+              (inputs `(("foo" ,grep)
+                        ("bar" ,(dummy-package "chbouib"
+                                  (source (origin
+                                            (method git-fetch)
+                                            (uri (git-reference
+                                                  (url "https://example.org")
+                                                  (commit "cabba9e")))
+                                            (sha256 #f)))))))))
+         (t (options->transformation '((with-commit . "chbouib=v1.0-gcabba9e2")))))
+    (let ((new (t p)))
+      (and (not (eq? new p))
+           (match (package-inputs new)
+             ((("foo" dep1) ("bar" dep2))
+              (package-version dep2)))))))
+
 (test-equal "options->transformation, with-git-url"
   (let ((source (git-checkout (url "https://example.org")
                               (recursive? #t))))
-- 
2.31.1





Information forwarded to guix-patches <at> gnu.org:
bug#50377; Package guix-patches. (Sun, 05 Sep 2021 22:53:03 GMT) Full text and rfc822 format available.

Message #14 received at 50377 <at> debbugs.gnu.org (full text, mbox):

From: Marius Bakke <marius <at> gnu.org>
To: 50377 <at> debbugs.gnu.org
Subject: Re: [bug#50377] [PATCH v2 1/2] git: 'resolve-reference' handles
 'git describe'-style commit IDs.
Date: Mon, 06 Sep 2021 00:52:08 +0200
[Message part 1 (text/plain, inline)]
Marius Bakke <marius <at> gnu.org> skriver:

> * guix/git.scm (resolve-reference): Use REVPARSE-SINGLE for looking up
> commits.  Rewrite tag-or-commit case to recognize 'git describe' style
> identifiers and resolve them as commits.

I realize we can do this without resorting to 'revparse-single', which
does essentially the same as this procedure.  We just have to extract
the short commit from the describe string.  New patch attached:

[0001-git-resolve-reference-handles-git-describe-style-com.patch (text/x-patch, attachment)]
[signature.asc (application/pgp-signature, inline)]

Information forwarded to guix-patches <at> gnu.org:
bug#50377; Package guix-patches. (Mon, 06 Sep 2021 10:39:01 GMT) Full text and rfc822 format available.

Message #17 received at 50377 <at> debbugs.gnu.org (full text, mbox):

From: Marius Bakke <marius <at> gnu.org>
To: 50377 <at> debbugs.gnu.org
Subject: [PATCH v3 1/2] git: 'resolve-reference' handles 'git describe'-style
 commit IDs.
Date: Mon,  6 Sep 2021 12:38:45 +0200
* guix/git.scm (resolve-reference): Rewrite tag-or-commit case to recognize
'git describe' style identifiers and resolve them as commits.
---
 guix/git.scm | 33 ++++++++++++++++++++++++---------
 1 file changed, 24 insertions(+), 9 deletions(-)

diff --git a/guix/git.scm b/guix/git.scm
index 9c6f326c36..621de0e925 100644
--- a/guix/git.scm
+++ b/guix/git.scm
@@ -2,6 +2,7 @@
 ;;; Copyright © 2017, 2020 Mathieu Othacehe <m.othacehe <at> gmail.com>
 ;;; Copyright © 2018, 2019, 2020, 2021 Ludovic Courtès <ludo <at> gnu.org>
 ;;; Copyright © 2021 Kyle Meyer <kyle <at> kyleam.com>
+;;; Copyright © 2021 Marius Bakke <marius <at> gnu.org>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -223,15 +224,29 @@ corresponding Git object."
              (object-lookup-prefix repository (string->oid commit) len)
              (object-lookup repository (string->oid commit)))))
       (('tag-or-commit . str)
-       (if (or (> (string-length str) 40)
-               (not (string-every char-set:hex-digit str)))
-           (resolve `(tag . ,str))              ;definitely a tag
-           (catch 'git-error
-             (lambda ()
-               (resolve `(tag . ,str)))
-             (lambda _
-               ;; There's no such tag, so it must be a commit ID.
-               (resolve `(commit . ,str))))))
+       (cond ((and (string-contains str "-g")
+                   (match (string-split str #\-)
+                     ((version ... revision g+commit)
+                      (if (and (> (string-length g+commit) 4)
+                               (string-every char-set:digit revision)
+                               (string-every char-set:hex-digit
+                                             (string-drop g+commit 1)))
+                          (string-drop g+commit 1)
+                          #f))
+                     (_ #f)))
+              ;; Looks like a 'git describe' style ID, like
+              ;; v1.3.0-7-gaa34d4d28d.
+              => (lambda (commit) (resolve `(commit . ,commit))))
+             ((or (> (string-length str) 40)
+                  (not (string-every char-set:hex-digit str)))
+              (resolve `(tag . ,str)))      ;definitely a tag
+             (else
+              (catch 'git-error
+                (lambda ()
+                  (resolve `(tag . ,str)))
+                (lambda _
+                  ;; There's no such tag, so it must be a commit ID.
+                  (resolve `(commit . ,str)))))))
       (('tag    . tag)
        (let ((oid (reference-name->oid repository
                                        (string-append "refs/tags/" tag))))
-- 
2.31.1





Information forwarded to guix-patches <at> gnu.org:
bug#50377; Package guix-patches. (Mon, 06 Sep 2021 10:40:01 GMT) Full text and rfc822 format available.

Message #20 received at 50377 <at> debbugs.gnu.org (full text, mbox):

From: Marius Bakke <marius <at> gnu.org>
To: 50377 <at> debbugs.gnu.org
Subject: [PATCH v3 2/2] transformations: 'git describe' style commit IDs are
 used as version.
Date: Mon,  6 Sep 2021 12:38:46 +0200
* guix/transformations.scm (transform-package-source-commit): Look for
'git describe' style IDs and use it as the version if applicable.
* tests/transformations.scm
("options->transformation, with-commit, 'git describe' style version"): New
test.
---
 guix/transformations.scm  | 37 ++++++++++++++++++++++++++++---------
 tests/transformations.scm | 19 +++++++++++++++++++
 2 files changed, 47 insertions(+), 9 deletions(-)

diff --git a/guix/transformations.scm b/guix/transformations.scm
index 5122baa403..af3eda76f8 100644
--- a/guix/transformations.scm
+++ b/guix/transformations.scm
@@ -1,5 +1,6 @@
 ;;; GNU Guix --- Functional package management for GNU
 ;;; Copyright © 2016, 2017, 2018, 2019, 2020, 2021 Ludovic Courtès <ludo <at> gnu.org>
+;;; Copyright © 2021 Marius Bakke <marius <at> gnu.org>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -278,15 +279,33 @@ strings like \"guile-next=cabba9e\" meaning that packages are built using
   (define (replace old url commit)
     (package
       (inherit old)
-      (version (if (and (> (string-length commit) 1)
-                        (string-prefix? "v" commit)
-                        (char-set-contains? char-set:digit
-                                            (string-ref commit 1)))
-                   (string-drop commit 1)        ;looks like a tag like "v1.0"
-                   (string-append "git."
-                                  (if (< (string-length commit) 7)
-                                      commit
-                                      (string-take commit 7)))))
+      (version (cond ((and (string-contains commit "-g")
+                           (match (string-split commit #\-)
+                             ((version ... revision g+commit)
+                              (and (> (string-length g+commit) 4)
+                                   (string-every char-set:digit revision)
+                                   (string-every char-set:hex-digit
+                                                 (string-drop g+commit 1))))
+                             (_ #f)))
+                      ;; This looks like a 'git describe' style ID.  Drop
+                      ;; the 'v' prefix if applicable.
+                      (if (and (string-prefix? "v" commit)
+                               (char-set-contains? char-set:digit
+                                                   (string-take
+                                                    (string-drop commit 1)
+                                                    1)))
+                          (string-drop commit 1)
+                          commit))
+                     ((and (> (string-length commit) 1)
+                           (string-prefix? "v" commit)
+                           (char-set-contains? char-set:digit
+                                               (string-ref commit 1)))
+                      (string-drop commit 1))       ;looks like a tag like "v1.0"
+                     (else
+                      (string-append "git."
+                                     (if (< (string-length commit) 7)
+                                         commit
+                                         (string-take commit 7))))))
       (source (git-checkout (url url) (commit commit)
                             (recursive? #t)))))
 
diff --git a/tests/transformations.scm b/tests/transformations.scm
index 3417c994ec..44fccffcce 100644
--- a/tests/transformations.scm
+++ b/tests/transformations.scm
@@ -1,5 +1,6 @@
 ;;; GNU Guix --- Functional package management for GNU
 ;;; Copyright © 2016, 2017, 2019, 2020, 2021 Ludovic Courtès <ludo <at> gnu.org>
+;;; Copyright © 2021 Marius Bakke <marius <at> gnu.org>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -235,6 +236,24 @@
                    (string=? (package-name dep2) "chbouib")
                    (package-source dep2))))))))
 
+(test-equal "options->transformation, with-commit, 'git describe' style version"
+  "1.0-gcabba9e2"
+  (let* ((p (dummy-package "guix.scm"
+              (inputs `(("foo" ,grep)
+                        ("bar" ,(dummy-package "chbouib"
+                                  (source (origin
+                                            (method git-fetch)
+                                            (uri (git-reference
+                                                  (url "https://example.org")
+                                                  (commit "cabba9e")))
+                                            (sha256 #f)))))))))
+         (t (options->transformation '((with-commit . "chbouib=v1.0-gcabba9e2")))))
+    (let ((new (t p)))
+      (and (not (eq? new p))
+           (match (package-inputs new)
+             ((("foo" dep1) ("bar" dep2))
+              (package-version dep2)))))))
+
 (test-equal "options->transformation, with-git-url"
   (let ((source (git-checkout (url "https://example.org")
                               (recursive? #t))))
-- 
2.31.1





Information forwarded to guix-patches <at> gnu.org:
bug#50377; Package guix-patches. (Mon, 06 Sep 2021 10:40:02 GMT) Full text and rfc822 format available.

Message #23 received at 50377 <at> debbugs.gnu.org (full text, mbox):

From: Marius Bakke <marius <at> gnu.org>
To: 50377 <at> debbugs.gnu.org
Subject: [PATCH v3 0/2] Support 'git describe' style commit IDs in
 transformations
Date: Mon,  6 Sep 2021 12:38:44 +0200
* The new resolve-reference condition actually returns.
* The transformation code now use the same heuristics as
  resolve-reference to check for the 'describe' style.

I'm now reasonably confident in these patches and will push in a day or
two unless there are objections.  :-)

Marius Bakke (2):
  git: 'resolve-reference' handles 'git describe'-style commit IDs.
  transformations: 'git describe' style commit IDs are used as version.

 guix/git.scm              | 33 ++++++++++++++++++++++++---------
 guix/transformations.scm  | 37 ++++++++++++++++++++++++++++---------
 tests/transformations.scm | 19 +++++++++++++++++++
 3 files changed, 71 insertions(+), 18 deletions(-)

-- 
2.31.1





Information forwarded to guix-patches <at> gnu.org:
bug#50377; Package guix-patches. (Mon, 06 Sep 2021 11:53:02 GMT) Full text and rfc822 format available.

Message #26 received at 50377 <at> debbugs.gnu.org (full text, mbox):

From: Xinglu Chen <public <at> yoctocell.xyz>
To: Marius Bakke <marius <at> gnu.org>, 50377 <at> debbugs.gnu.org
Subject: Re: [bug#50377] [PATCH v3 0/2] Support 'git describe' style commit
 IDs in transformations
Date: Mon, 06 Sep 2021 13:52:27 +0200
[Message part 1 (text/plain, inline)]
On Mon, Sep 06 2021, Marius Bakke wrote:

> * The new resolve-reference condition actually returns.
> * The transformation code now use the same heuristics as
>   resolve-reference to check for the 'describe' style.
>
> I'm now reasonably confident in these patches and will push in a day or
> two unless there are objections.  :-)
>
> Marius Bakke (2):
>   git: 'resolve-reference' handles 'git describe'-style commit IDs.
>   transformations: 'git describe' style commit IDs are used as version.

I haven’t looked at the patch itself, but maybe it’s worthing mentioning
this in the “9.1.2 Package Transformation Options” section in the manual?
[signature.asc (application/pgp-signature, inline)]

Information forwarded to guix-patches <at> gnu.org:
bug#50377; Package guix-patches. (Mon, 06 Sep 2021 21:04:01 GMT) Full text and rfc822 format available.

Message #29 received at 50377 <at> debbugs.gnu.org (full text, mbox):

From: Ludovic Courtès <ludo <at> gnu.org>
To: Marius Bakke <marius <at> gnu.org>
Cc: 50377 <at> debbugs.gnu.org
Subject: Re: bug#50377: [PATCH 0/2] Support 'git describe' style commit IDs
 in transformations
Date: Mon, 06 Sep 2021 23:02:49 +0200
Howdy!

Marius Bakke <marius <at> gnu.org> skribis:

> * guix/git.scm (resolve-reference): Rewrite tag-or-commit case to recognize
> 'git describe' style identifiers and resolve them as commits.

LGTM!

Ludo’.




Information forwarded to guix-patches <at> gnu.org:
bug#50377; Package guix-patches. (Mon, 06 Sep 2021 21:05:02 GMT) Full text and rfc822 format available.

Message #32 received at 50377 <at> debbugs.gnu.org (full text, mbox):

From: Ludovic Courtès <ludo <at> gnu.org>
To: Marius Bakke <marius <at> gnu.org>
Cc: 50377 <at> debbugs.gnu.org
Subject: Re: bug#50377: [PATCH 0/2] Support 'git describe' style commit IDs
 in transformations
Date: Mon, 06 Sep 2021 23:04:47 +0200
Marius Bakke <marius <at> gnu.org> skribis:

> * guix/transformations.scm (transform-package-source-commit): Look for
> 'git describe' style IDs and use it as the version if applicable.
> * tests/transformations.scm
> ("options->transformation, with-commit, 'git describe' style version"): New
> test.

[...]

> +      (version (cond ((and (string-contains commit "-g")
> +                           (match (string-split commit #\-)
> +                             ((version ... revision g+commit)
> +                              (and (> (string-length g+commit) 4)
> +                                   (string-every char-set:digit revision)
> +                                   (string-every char-set:hex-digit
> +                                                 (string-drop g+commit 1))))
> +                             (_ #f)))
> +                      ;; This looks like a 'git describe' style ID.  Drop
> +                      ;; the 'v' prefix if applicable.
> +                      (if (and (string-prefix? "v" commit)
> +                               (char-set-contains? char-set:digit
> +                                                   (string-take
> +                                                    (string-drop commit 1)
> +                                                    1)))
> +                          (string-drop commit 1)
> +                          commit))
> +                     ((and (> (string-length commit) 1)
> +                           (string-prefix? "v" commit)
> +                           (char-set-contains? char-set:digit
> +                                               (string-ref commit 1)))
> +                      (string-drop commit 1))       ;looks like a tag like "v1.0"
> +                     (else
> +                      (string-append "git."
> +                                     (if (< (string-length commit) 7)
> +                                         commit
> +                                         (string-take commit 7))))))

For clarity, I’d extract this as a ‘commit->version-string’ procedure.

Like Xinglu writes, it’d be great to add a sentence in the manual about
these IDs.

Apart from that, it’s a good idea and it LGTM!

Thanks,
Ludo’.




Reply sent to Marius Bakke <marius <at> gnu.org>:
You have taken responsibility. (Wed, 08 Sep 2021 16:09:02 GMT) Full text and rfc822 format available.

Notification sent to Marius Bakke <marius <at> gnu.org>:
bug acknowledged by developer. (Wed, 08 Sep 2021 16:09:02 GMT) Full text and rfc822 format available.

Message #37 received at 50377-done <at> debbugs.gnu.org (full text, mbox):

From: Marius Bakke <marius <at> gnu.org>
To: Ludovic Courtès <ludo <at> gnu.org>
Cc: 50377-done <at> debbugs.gnu.org
Subject: Re: bug#50377: [PATCH 0/2] Support 'git describe' style commit IDs
 in transformations
Date: Wed, 08 Sep 2021 18:08:14 +0200
[Message part 1 (text/plain, inline)]
Ludovic Courtès <ludo <at> gnu.org> skriver:

> Marius Bakke <marius <at> gnu.org> skribis:
>
>> +      (version (cond ((and (string-contains commit "-g")
>> +                           (match (string-split commit #\-)
>> +                             ((version ... revision g+commit)
>> +                              (and (> (string-length g+commit) 4)
>> +                                   (string-every char-set:digit revision)
>> +                                   (string-every char-set:hex-digit
>> +                                                 (string-drop g+commit 1))))
>> +                             (_ #f)))
>> +                      ;; This looks like a 'git describe' style ID.  Drop
>> +                      ;; the 'v' prefix if applicable.
>> +                      (if (and (string-prefix? "v" commit)
>> +                               (char-set-contains? char-set:digit
>> +                                                   (string-take
>> +                                                    (string-drop commit 1)
>> +                                                    1)))
>> +                          (string-drop commit 1)
>> +                          commit))
>> +                     ((and (> (string-length commit) 1)
>> +                           (string-prefix? "v" commit)
>> +                           (char-set-contains? char-set:digit
>> +                                               (string-ref commit 1)))
>> +                      (string-drop commit 1))       ;looks like a tag like "v1.0"
>> +                     (else
>> +                      (string-append "git."
>> +                                     (if (< (string-length commit) 7)
>> +                                         commit
>> +                                         (string-take commit 7))))))
>
> For clarity, I’d extract this as a ‘commit->version-string’ procedure.
>
> Like Xinglu writes, it’d be great to add a sentence in the manual about
> these IDs.

Thanks for the feedback!  Looking at this again, I realized tags would
not be used as version either which seemed like an oversight.  So I
fixed(?) that too and vastly simplified this patch.  :-)

Also adjusted the test to more thoroughly excercise the new
commit->version-string procedure with the different arguments, and
updated the documentation.

Pushed in:
  1dc3825e99 git: 'resolve-reference' handles 'git describe'-style commit IDs.
  16ef7b4938 transformations: Git tags and 'git describe' style IDs are used as version.

Thanks,
Marius
[signature.asc (application/pgp-signature, inline)]

bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Thu, 07 Oct 2021 11:24:05 GMT) Full text and rfc822 format available.

This bug report was last modified 2 years and 173 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.