unofficial mirror of guix-patches@gnu.org 
 help / color / mirror / code / Atom feed
* [bug#50377] [PATCH 0/2] Support 'git describe' style commit IDs in transformations
@ 2021-09-04 18:08 Marius Bakke
  2021-09-04 18:10 ` [bug#50377] [PATCH 1/2] git: 'resolve-reference' handles 'git describe'-style commit IDs Marius Bakke
  2021-09-06 10:38 ` [bug#50377] [PATCH v3 0/2] Support 'git describe' style commit IDs in transformations Marius Bakke
  0 siblings, 2 replies; 11+ messages in thread
From: Marius Bakke @ 2021-09-04 18:08 UTC (permalink / raw)
  To: 50377

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





^ permalink raw reply	[flat|nested] 11+ messages in thread

* [bug#50377] [PATCH 1/2] git: 'resolve-reference' handles 'git describe'-style commit IDs.
  2021-09-04 18:08 [bug#50377] [PATCH 0/2] Support 'git describe' style commit IDs in transformations Marius Bakke
@ 2021-09-04 18:10 ` Marius Bakke
  2021-09-04 18:10   ` [bug#50377] [PATCH 2/2] transformations: 'git describe' style commit IDs are used as version Marius Bakke
  2021-09-05 22:52   ` [bug#50377] [PATCH v2 1/2] git: 'resolve-reference' handles 'git describe'-style commit IDs Marius Bakke
  2021-09-06 10:38 ` [bug#50377] [PATCH v3 0/2] Support 'git describe' style commit IDs in transformations Marius Bakke
  1 sibling, 2 replies; 11+ messages in thread
From: Marius Bakke @ 2021-09-04 18:10 UTC (permalink / raw)
  To: 50377

* 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@gmail.com>
 ;;; Copyright © 2018, 2019, 2020, 2021 Ludovic Courtès <ludo@gnu.org>
 ;;; Copyright © 2021 Kyle Meyer <kyle@kyleam.com>
+;;; Copyright © 2021 Marius Bakke <marius@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





^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [bug#50377] [PATCH 2/2] transformations: 'git describe' style commit IDs are used as version.
  2021-09-04 18:10 ` [bug#50377] [PATCH 1/2] git: 'resolve-reference' handles 'git describe'-style commit IDs Marius Bakke
@ 2021-09-04 18:10   ` Marius Bakke
  2021-09-05 22:52   ` [bug#50377] [PATCH v2 1/2] git: 'resolve-reference' handles 'git describe'-style commit IDs Marius Bakke
  1 sibling, 0 replies; 11+ messages in thread
From: Marius Bakke @ 2021-09-04 18:10 UTC (permalink / raw)
  To: 50377

* 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@gnu.org>
+;;; Copyright © 2021 Marius Bakke <marius@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@gnu.org>
+;;; Copyright © 2021 Marius Bakke <marius@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





^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [bug#50377] [PATCH v2 1/2] git: 'resolve-reference' handles 'git describe'-style commit IDs.
  2021-09-04 18:10 ` [bug#50377] [PATCH 1/2] git: 'resolve-reference' handles 'git describe'-style commit IDs Marius Bakke
  2021-09-04 18:10   ` [bug#50377] [PATCH 2/2] transformations: 'git describe' style commit IDs are used as version Marius Bakke
@ 2021-09-05 22:52   ` Marius Bakke
  1 sibling, 0 replies; 11+ messages in thread
From: Marius Bakke @ 2021-09-05 22:52 UTC (permalink / raw)
  To: 50377


[-- Attachment #1.1: Type: text/plain, Size: 436 bytes --]

Marius Bakke <marius@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:


[-- Attachment #1.2: 0001-git-resolve-reference-handles-git-describe-style-com.patch --]
[-- Type: text/x-patch, Size: 2883 bytes --]

From 9af0f5fd7d8209ffe94d9e0007f58a1a475fe4f1 Mon Sep 17 00:00:00 2001
From: Marius Bakke <marius@gnu.org>
Date: Mon, 6 Sep 2021 00:21:51 +0200
Subject: [PATCH] git: 'resolve-reference' handles 'git describe'-style commit
 IDs.

* guix/git.scm (resolve-reference): Rewrite tag-or-commit case to recognize
'git describe' style identifiers and resolve them as commits.
---
 guix/git.scm | 32 +++++++++++++++++++++++---------
 1 file changed, 23 insertions(+), 9 deletions(-)

diff --git a/guix/git.scm b/guix/git.scm
index 9c6f326c36..09efab1182 100644
--- a/guix/git.scm
+++ b/guix/git.scm
@@ -2,6 +2,7 @@
 ;;; Copyright © 2017, 2020 Mathieu Othacehe <m.othacehe@gmail.com>
 ;;; Copyright © 2018, 2019, 2020, 2021 Ludovic Courtès <ludo@gnu.org>
 ;;; Copyright © 2021 Kyle Meyer <kyle@kyleam.com>
+;;; Copyright © 2021 Marius Bakke <marius@gnu.org>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -223,15 +224,28 @@ 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) 7)
+                               (string-every char-set:digit revision)
+                               (string-every char-set:hex-digit
+                                             (string-drop g+commit 1)))
+                          ;; Looks like a 'git describe' style id, like
+                          ;; v1.3.0-7-gaa34d4d28d.
+                          (resolve `(commit . ,(string-drop g+commit 1)))
+                          #f))
+                     (_ #f))))
+             ((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


[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 247 bytes --]

^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [bug#50377] [PATCH v3 0/2] Support 'git describe' style commit IDs in transformations
  2021-09-04 18:08 [bug#50377] [PATCH 0/2] Support 'git describe' style commit IDs in transformations Marius Bakke
  2021-09-04 18:10 ` [bug#50377] [PATCH 1/2] git: 'resolve-reference' handles 'git describe'-style commit IDs Marius Bakke
@ 2021-09-06 10:38 ` Marius Bakke
  2021-09-06 10:38   ` [bug#50377] [PATCH v3 1/2] git: 'resolve-reference' handles 'git describe'-style commit IDs Marius Bakke
                     ` (2 more replies)
  1 sibling, 3 replies; 11+ messages in thread
From: Marius Bakke @ 2021-09-06 10:38 UTC (permalink / raw)
  To: 50377

* 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





^ permalink raw reply	[flat|nested] 11+ messages in thread

* [bug#50377] [PATCH v3 1/2] git: 'resolve-reference' handles 'git describe'-style commit IDs.
  2021-09-06 10:38 ` [bug#50377] [PATCH v3 0/2] Support 'git describe' style commit IDs in transformations Marius Bakke
@ 2021-09-06 10:38   ` Marius Bakke
  2021-09-06 21:02     ` [bug#50377] [PATCH 0/2] Support 'git describe' style commit IDs in transformations Ludovic Courtès
  2021-09-06 10:38   ` [bug#50377] [PATCH v3 2/2] transformations: 'git describe' style commit IDs are used as version Marius Bakke
  2021-09-06 11:52   ` [bug#50377] [PATCH v3 " Xinglu Chen
  2 siblings, 1 reply; 11+ messages in thread
From: Marius Bakke @ 2021-09-06 10:38 UTC (permalink / raw)
  To: 50377

* 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@gmail.com>
 ;;; Copyright © 2018, 2019, 2020, 2021 Ludovic Courtès <ludo@gnu.org>
 ;;; Copyright © 2021 Kyle Meyer <kyle@kyleam.com>
+;;; Copyright © 2021 Marius Bakke <marius@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





^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [bug#50377] [PATCH v3 2/2] transformations: 'git describe' style commit IDs are used as version.
  2021-09-06 10:38 ` [bug#50377] [PATCH v3 0/2] Support 'git describe' style commit IDs in transformations Marius Bakke
  2021-09-06 10:38   ` [bug#50377] [PATCH v3 1/2] git: 'resolve-reference' handles 'git describe'-style commit IDs Marius Bakke
@ 2021-09-06 10:38   ` Marius Bakke
  2021-09-06 21:04     ` [bug#50377] [PATCH 0/2] Support 'git describe' style commit IDs in transformations Ludovic Courtès
  2021-09-06 11:52   ` [bug#50377] [PATCH v3 " Xinglu Chen
  2 siblings, 1 reply; 11+ messages in thread
From: Marius Bakke @ 2021-09-06 10:38 UTC (permalink / raw)
  To: 50377

* 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@gnu.org>
+;;; Copyright © 2021 Marius Bakke <marius@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@gnu.org>
+;;; Copyright © 2021 Marius Bakke <marius@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





^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [bug#50377] [PATCH v3 0/2] Support 'git describe' style commit IDs in transformations
  2021-09-06 10:38 ` [bug#50377] [PATCH v3 0/2] Support 'git describe' style commit IDs in transformations Marius Bakke
  2021-09-06 10:38   ` [bug#50377] [PATCH v3 1/2] git: 'resolve-reference' handles 'git describe'-style commit IDs Marius Bakke
  2021-09-06 10:38   ` [bug#50377] [PATCH v3 2/2] transformations: 'git describe' style commit IDs are used as version Marius Bakke
@ 2021-09-06 11:52   ` Xinglu Chen
  2 siblings, 0 replies; 11+ messages in thread
From: Xinglu Chen @ 2021-09-06 11:52 UTC (permalink / raw)
  To: Marius Bakke, 50377

[-- Attachment #1: Type: text/plain, Size: 669 bytes --]

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?

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 861 bytes --]

^ permalink raw reply	[flat|nested] 11+ messages in thread

* [bug#50377] [PATCH 0/2] Support 'git describe' style commit IDs in transformations
  2021-09-06 10:38   ` [bug#50377] [PATCH v3 1/2] git: 'resolve-reference' handles 'git describe'-style commit IDs Marius Bakke
@ 2021-09-06 21:02     ` Ludovic Courtès
  0 siblings, 0 replies; 11+ messages in thread
From: Ludovic Courtès @ 2021-09-06 21:02 UTC (permalink / raw)
  To: Marius Bakke; +Cc: 50377

Howdy!

Marius Bakke <marius@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’.




^ permalink raw reply	[flat|nested] 11+ messages in thread

* [bug#50377] [PATCH 0/2] Support 'git describe' style commit IDs in transformations
  2021-09-06 10:38   ` [bug#50377] [PATCH v3 2/2] transformations: 'git describe' style commit IDs are used as version Marius Bakke
@ 2021-09-06 21:04     ` Ludovic Courtès
  2021-09-08 16:08       ` bug#50377: " Marius Bakke
  0 siblings, 1 reply; 11+ messages in thread
From: Ludovic Courtès @ 2021-09-06 21:04 UTC (permalink / raw)
  To: Marius Bakke; +Cc: 50377

Marius Bakke <marius@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’.




^ permalink raw reply	[flat|nested] 11+ messages in thread

* bug#50377: [PATCH 0/2] Support 'git describe' style commit IDs in transformations
  2021-09-06 21:04     ` [bug#50377] [PATCH 0/2] Support 'git describe' style commit IDs in transformations Ludovic Courtès
@ 2021-09-08 16:08       ` Marius Bakke
  0 siblings, 0 replies; 11+ messages in thread
From: Marius Bakke @ 2021-09-08 16:08 UTC (permalink / raw)
  To: Ludovic Courtès; +Cc: 50377-done

[-- Attachment #1: Type: text/plain, Size: 2584 bytes --]

Ludovic Courtès <ludo@gnu.org> skriver:

> Marius Bakke <marius@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

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 247 bytes --]

^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2021-09-08 16:12 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-09-04 18:08 [bug#50377] [PATCH 0/2] Support 'git describe' style commit IDs in transformations Marius Bakke
2021-09-04 18:10 ` [bug#50377] [PATCH 1/2] git: 'resolve-reference' handles 'git describe'-style commit IDs Marius Bakke
2021-09-04 18:10   ` [bug#50377] [PATCH 2/2] transformations: 'git describe' style commit IDs are used as version Marius Bakke
2021-09-05 22:52   ` [bug#50377] [PATCH v2 1/2] git: 'resolve-reference' handles 'git describe'-style commit IDs Marius Bakke
2021-09-06 10:38 ` [bug#50377] [PATCH v3 0/2] Support 'git describe' style commit IDs in transformations Marius Bakke
2021-09-06 10:38   ` [bug#50377] [PATCH v3 1/2] git: 'resolve-reference' handles 'git describe'-style commit IDs Marius Bakke
2021-09-06 21:02     ` [bug#50377] [PATCH 0/2] Support 'git describe' style commit IDs in transformations Ludovic Courtès
2021-09-06 10:38   ` [bug#50377] [PATCH v3 2/2] transformations: 'git describe' style commit IDs are used as version Marius Bakke
2021-09-06 21:04     ` [bug#50377] [PATCH 0/2] Support 'git describe' style commit IDs in transformations Ludovic Courtès
2021-09-08 16:08       ` bug#50377: " Marius Bakke
2021-09-06 11:52   ` [bug#50377] [PATCH v3 " Xinglu Chen

Code repositories for project(s) associated with this public inbox

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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).