From debbugs-submit-bounces@debbugs.gnu.org Sat Sep 04 14:08:50 2021 Received: (at submit) by debbugs.gnu.org; 4 Sep 2021 18:08:50 +0000 Received: from localhost ([127.0.0.1]:48540 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mMa5y-0003Tm-Lo for submit@debbugs.gnu.org; Sat, 04 Sep 2021 14:08:50 -0400 Received: from lists.gnu.org ([209.51.188.17]:36080) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mMa5x-0003Te-JB for submit@debbugs.gnu.org; Sat, 04 Sep 2021 14:08:49 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:36522) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mMa5x-0006Vy-25 for guix-patches@gnu.org; Sat, 04 Sep 2021 14:08:49 -0400 Received: from fencepost.gnu.org ([2001:470:142:3::e]:39894) by eggs.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mMa5w-0001Mm-RX for guix-patches@gnu.org; Sat, 04 Sep 2021 14:08:48 -0400 Received: from host-37-191-231-185.lynet.no ([37.191.231.185]:38032 helo=localhost) by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mMa5w-0004yT-6q for guix-patches@gnu.org; Sat, 04 Sep 2021 14:08:48 -0400 From: Marius Bakke To: guix-patches@gnu.org Subject: [PATCH 0/2] Support 'git describe' style commit IDs in transformations Date: Sat, 4 Sep 2021 20:08:45 +0200 Message-Id: <20210904180845.23915-1-marius@gnu.org> X-Mailer: git-send-email 2.31.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: submit X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) 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 From debbugs-submit-bounces@debbugs.gnu.org Sat Sep 04 14:10:45 2021 Received: (at 50377) by debbugs.gnu.org; 4 Sep 2021 18:10:45 +0000 Received: from localhost ([127.0.0.1]:48545 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mMa7o-0003XE-W4 for submit@debbugs.gnu.org; Sat, 04 Sep 2021 14:10:45 -0400 Received: from eggs.gnu.org ([209.51.188.92]:48886) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mMa7n-0003Wz-Io for 50377@debbugs.gnu.org; Sat, 04 Sep 2021 14:10:44 -0400 Received: from fencepost.gnu.org ([2001:470:142:3::e]:39920) by eggs.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mMa7i-00032M-8m for 50377@debbugs.gnu.org; Sat, 04 Sep 2021 14:10:38 -0400 Received: from host-37-191-231-185.lynet.no ([37.191.231.185]:38034 helo=localhost) by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mMa7h-00059v-ST for 50377@debbugs.gnu.org; Sat, 04 Sep 2021 14:10:38 -0400 From: Marius Bakke To: 50377@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 Message-Id: <20210904181035.24161-1-marius@gnu.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210904180845.23915-1-marius@gnu.org> References: <20210904180845.23915-1-marius@gnu.org> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 50377 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) * 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 ;;; Copyright © 2018, 2019, 2020, 2021 Ludovic Courtès ;;; Copyright © 2021 Kyle Meyer +;;; Copyright © 2021 Marius Bakke ;;; ;;; 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 From debbugs-submit-bounces@debbugs.gnu.org Sat Sep 04 14:10:49 2021 Received: (at 50377) by debbugs.gnu.org; 4 Sep 2021 18:10:49 +0000 Received: from localhost ([127.0.0.1]:48548 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mMa7t-0003XW-9f for submit@debbugs.gnu.org; Sat, 04 Sep 2021 14:10:49 -0400 Received: from eggs.gnu.org ([209.51.188.92]:48902) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mMa7r-0003X4-Cu for 50377@debbugs.gnu.org; Sat, 04 Sep 2021 14:10:47 -0400 Received: from fencepost.gnu.org ([2001:470:142:3::e]:39922) by eggs.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mMa7m-00035s-8Y for 50377@debbugs.gnu.org; Sat, 04 Sep 2021 14:10:42 -0400 Received: from host-37-191-231-185.lynet.no ([37.191.231.185]:38036 helo=localhost) by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mMa7k-0005BX-Ax for 50377@debbugs.gnu.org; Sat, 04 Sep 2021 14:10:42 -0400 From: Marius Bakke To: 50377@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 Message-Id: <20210904181035.24161-2-marius@gnu.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210904181035.24161-1-marius@gnu.org> References: <20210904180845.23915-1-marius@gnu.org> <20210904181035.24161-1-marius@gnu.org> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 50377 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) * 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 +;;; Copyright © 2021 Marius Bakke ;;; ;;; 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 +;;; Copyright © 2021 Marius Bakke ;;; ;;; 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 From debbugs-submit-bounces@debbugs.gnu.org Sun Sep 05 18:52:19 2021 Received: (at 50377) by debbugs.gnu.org; 5 Sep 2021 22:52:19 +0000 Received: from localhost ([127.0.0.1]:51148 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mN0zr-0000Wc-8r for submit@debbugs.gnu.org; Sun, 05 Sep 2021 18:52:19 -0400 Received: from eggs.gnu.org ([209.51.188.92]:42164) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mN0zp-0000WM-Hm for 50377@debbugs.gnu.org; Sun, 05 Sep 2021 18:52:17 -0400 Received: from fencepost.gnu.org ([2001:470:142:3::e]:47120) by eggs.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mN0zk-0000q5-AS for 50377@debbugs.gnu.org; Sun, 05 Sep 2021 18:52:12 -0400 Received: from host-37-191-231-185.lynet.no ([37.191.231.185]:38038 helo=localhost) by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mN0zj-0003Ad-IA for 50377@debbugs.gnu.org; Sun, 05 Sep 2021 18:52:12 -0400 From: Marius Bakke To: 50377@debbugs.gnu.org Subject: Re: [bug#50377] [PATCH v2 1/2] git: 'resolve-reference' handles 'git describe'-style commit IDs. In-Reply-To: <20210904181035.24161-1-marius@gnu.org> References: <20210904180845.23915-1-marius@gnu.org> <20210904181035.24161-1-marius@gnu.org> Date: Mon, 06 Sep 2021 00:52:08 +0200 Message-ID: <87pmtmprdz.fsf@gnu.org> MIME-Version: 1.0 Content-Type: multipart/signed; boundary="==-=-="; micalg=pgp-sha512; protocol="application/pgp-signature" X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 50377 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) --==-=-= Content-Type: multipart/mixed; boundary="=-=-=" --=-=-= Content-Type: text/plain Marius Bakke 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: --=-=-= Content-Type: text/x-patch; charset=utf-8 Content-Disposition: attachment; filename=0001-git-resolve-reference-handles-git-describe-style-com.patch Content-Transfer-Encoding: quoted-printable From=209af0f5fd7d8209ffe94d9e0007f58a1a475fe4f1 Mon Sep 17 00:00:00 2001 From: Marius Bakke Date: Mon, 6 Sep 2021 00:21:51 +0200 Subject: [PATCH] git: 'resolve-reference' handles 'git describe'-style comm= it IDs. * guix/git.scm (resolve-reference): Rewrite tag-or-commit case to recognize 'git describe' style identifiers and resolve them as commits. =2D-- 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 =2D-- a/guix/git.scm +++ b/guix/git.scm @@ -2,6 +2,7 @@ ;;; Copyright =C2=A9 2017, 2020 Mathieu Othacehe ;;; Copyright =C2=A9 2018, 2019, 2020, 2021 Ludovic Court=C3=A8s ;;; Copyright =C2=A9 2021 Kyle Meyer +;;; Copyright =C2=A9 2021 Marius Bakke ;;; ;;; 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) =2D (if (or (> (string-length str) 40) =2D (not (string-every char-set:hex-digit str))) =2D (resolve `(tag . ,str)) ;definitely a tag =2D (catch 'git-error =2D (lambda () =2D (resolve `(tag . ,str))) =2D (lambda _ =2D ;; There's no such tag, so it must be a commit ID. =2D (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)))) =2D-=20 2.31.1 --=-=-=-- --==-=-= Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iIUEARYKAC0WIQRNTknu3zbaMQ2ddzTocYulkRQQdwUCYTVKGA8cbWFyaXVzQGdu dS5vcmcACgkQ6HGLpZEUEHdqUgEAn/KBuJVZlKIxYrCFM1wFvHWEXUeFypdbOGpn pquIx9oA/iNtoBXjhDVN3iH3GrkVMP6cmJcuaDsC5yBw8AEGjBUI =PU6n -----END PGP SIGNATURE----- --==-=-=-- From debbugs-submit-bounces@debbugs.gnu.org Mon Sep 06 06:39:00 2021 Received: (at 50377) by debbugs.gnu.org; 6 Sep 2021 10:39:00 +0000 Received: from localhost ([127.0.0.1]:52058 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mNC1k-0002lH-Dv for submit@debbugs.gnu.org; Mon, 06 Sep 2021 06:39:00 -0400 Received: from eggs.gnu.org ([209.51.188.92]:36366) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mNC1j-0002l3-GF for 50377@debbugs.gnu.org; Mon, 06 Sep 2021 06:39:00 -0400 Received: from fencepost.gnu.org ([2001:470:142:3::e]:35076) by eggs.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mNC1e-0001nU-9p for 50377@debbugs.gnu.org; Mon, 06 Sep 2021 06:38:54 -0400 Received: from host-37-191-231-185.lynet.no ([37.191.231.185]:38042 helo=localhost) by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mNC1d-0008F8-Ml for 50377@debbugs.gnu.org; Mon, 06 Sep 2021 06:38:54 -0400 From: Marius Bakke To: 50377@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 Message-Id: <20210906103846.14941-2-marius@gnu.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210906103846.14941-1-marius@gnu.org> References: <20210906103846.14941-1-marius@gnu.org> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 50377 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) * 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 ;;; Copyright © 2018, 2019, 2020, 2021 Ludovic Courtès ;;; Copyright © 2021 Kyle Meyer +;;; Copyright © 2021 Marius Bakke ;;; ;;; 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 From debbugs-submit-bounces@debbugs.gnu.org Mon Sep 06 06:39:06 2021 Received: (at 50377) by debbugs.gnu.org; 6 Sep 2021 10:39:06 +0000 Received: from localhost ([127.0.0.1]:52062 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mNC1p-0002m7-NG for submit@debbugs.gnu.org; Mon, 06 Sep 2021 06:39:06 -0400 Received: from eggs.gnu.org ([209.51.188.92]:36376) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mNC1n-0002l9-Sn for 50377@debbugs.gnu.org; Mon, 06 Sep 2021 06:39:04 -0400 Received: from fencepost.gnu.org ([2001:470:142:3::e]:35078) by eggs.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mNC1i-0001qW-MH for 50377@debbugs.gnu.org; Mon, 06 Sep 2021 06:38:58 -0400 Received: from host-37-191-231-185.lynet.no ([37.191.231.185]:38044 helo=localhost) by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mNC1g-0000IT-IR for 50377@debbugs.gnu.org; Mon, 06 Sep 2021 06:38:58 -0400 From: Marius Bakke To: 50377@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 Message-Id: <20210906103846.14941-3-marius@gnu.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210906103846.14941-1-marius@gnu.org> References: <20210906103846.14941-1-marius@gnu.org> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 50377 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) * 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 +;;; Copyright © 2021 Marius Bakke ;;; ;;; 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 +;;; Copyright © 2021 Marius Bakke ;;; ;;; 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 From debbugs-submit-bounces@debbugs.gnu.org Mon Sep 06 06:39:08 2021 Received: (at 50377) by debbugs.gnu.org; 6 Sep 2021 10:39:08 +0000 Received: from localhost ([127.0.0.1]:52064 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mNC1s-0002mN-4p for submit@debbugs.gnu.org; Mon, 06 Sep 2021 06:39:08 -0400 Received: from eggs.gnu.org ([209.51.188.92]:36356) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mNC1f-0002kx-Tg for 50377@debbugs.gnu.org; Mon, 06 Sep 2021 06:39:06 -0400 Received: from fencepost.gnu.org ([2001:470:142:3::e]:35074) by eggs.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mNC1a-0001kE-NI for 50377@debbugs.gnu.org; Mon, 06 Sep 2021 06:38:50 -0400 Received: from host-37-191-231-185.lynet.no ([37.191.231.185]:38040 helo=localhost) by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mNC1a-0007dt-7H for 50377@debbugs.gnu.org; Mon, 06 Sep 2021 06:38:50 -0400 From: Marius Bakke To: 50377@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 Message-Id: <20210906103846.14941-1-marius@gnu.org> X-Mailer: git-send-email 2.31.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 50377 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) * 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 From debbugs-submit-bounces@debbugs.gnu.org Mon Sep 06 07:52:37 2021 Received: (at 50377) by debbugs.gnu.org; 6 Sep 2021 11:52:37 +0000 Received: from localhost ([127.0.0.1]:52219 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mNDAy-0004sa-Qg for submit@debbugs.gnu.org; Mon, 06 Sep 2021 07:52:36 -0400 Received: from h87-96-130-155.cust.a3fiber.se ([87.96.130.155]:37368 helo=mail.yoctocell.xyz) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mNDAw-0004sG-Rj for 50377@debbugs.gnu.org; Mon, 06 Sep 2021 07:52:35 -0400 From: Xinglu Chen DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=yoctocell.xyz; s=mail; t=1630929148; bh=aNYrxZms1nDdpHzOse0AyiUA3KCmTLpnF+BCVr4rcuQ=; h=From:To:Subject:In-Reply-To:References:Date; b=VMJkgsJ9L/gnlDQhb2mT1IdW4Gx+tDyrXAhND06annSVqZ8HavlxWBhYEk9oytYwq ZMn8iBmmcGJDsji0HVruXMNLsW1Snk3wze2sy08VqYkM4zhQuhddzdepBLpmkl/mrP j3stsr42cIrgrQV5dQ7EwqG+bi18h0TT9MTBb5No= To: Marius Bakke , 50377@debbugs.gnu.org Subject: Re: [bug#50377] [PATCH v3 0/2] Support 'git describe' style commit IDs in transformations In-Reply-To: <20210906103846.14941-1-marius@gnu.org> References: <20210904180845.23915-1-marius@gnu.org> <20210906103846.14941-1-marius@gnu.org> Date: Mon, 06 Sep 2021 13:52:27 +0200 Message-ID: <8735qh3oqs.fsf@yoctocell.xyz> MIME-Version: 1.0 Content-Type: multipart/signed; boundary="=-=-="; micalg=pgp-sha256; protocol="application/pgp-signature" X-Spam-Score: 2.9 (++) X-Spam-Report: Spam detection software, running on the system "debbugs.gnu.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: 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 confi [...] Content analysis details: (2.9 points, 10.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 SPF_PASS SPF: sender matches SPF record 2.0 PDS_OTHER_BAD_TLD Untrustworthy TLDs [URI: yoctocell.xyz (xyz)] 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record 0.5 FROM_SUSPICIOUS_NTLD From abused NTLD 0.4 RDNS_DYNAMIC Delivered to internal network by host with dynamic-looking rDNS 0.0 PDS_RDNS_DYNAMIC_FP RDNS_DYNAMIC with FP steps X-Debbugs-Envelope-To: 50377 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: 2.9 (++) X-Spam-Report: Spam detection software, running on the system "debbugs.gnu.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: 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 confi [...] Content analysis details: (2.9 points, 10.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 SPF_PASS SPF: sender matches SPF record 2.0 PDS_OTHER_BAD_TLD Untrustworthy TLDs [URI: yoctocell.xyz (xyz)] 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record 0.5 FROM_SUSPICIOUS_NTLD From abused NTLD 0.4 RDNS_DYNAMIC Delivered to internal network by host with dynamic-looking rDNS 1.0 BULK_RE_SUSP_NTLD Precedence bulk and RE: from a suspicious TLD -1.0 MAILING_LIST_MULTI Multiple indicators imply a widely-seen list manager 0.0 PDS_RDNS_DYNAMIC_FP RDNS_DYNAMIC with FP steps --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable 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=E2=80=99t looked at the patch itself, but maybe it=E2=80=99s worthi= ng mentioning this in the =E2=80=9C9.1.2 Package Transformation Options=E2=80=9D section = in the manual? --=-=-= Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQJJBAEBCAAzFiEEAVhh4yyK5+SEykIzrPUJmaL7XHkFAmE2APsVHHB1YmxpY0B5 b2N0b2NlbGwueHl6AAoJEKz1CZmi+1x5hB0P/0T4Y+WhLu93NQJtZUS2SoU5CLKF wRI7LdMxQ4ExWHmMO9QP21LiJnDGEp/xc+YA/A0PCVB8IjDOwEZJeInXm1HxUHFX 1Oz8Glbv/HWw+5fmT8vA1ppTnSTgyM7EKQEU8sr0NSGwT7x404fe81x4mulOBZPv M8IEteWURE5IAaO1Vvwd25gnSGvkiYOQ3n16VxIhZnsfAFYY310/RrW1UWKzkeMS NqLC9VauA6l2LwgsKKSz5vW1Q45GdJgGGXuzSx3WOakidZcWrPOC9XyILsR8CRLJ 0uthJvHqAwGTIqU5vGaa3sxIY0WT9+F8+XA4tm59pzwvd75RON8X7O8M5WWy1Bpq sMhq00qMHtyL+nNrztqAFHL/OyIdDhrUTslyfM3zgQnNH/0N1Mds3dcH1rUTZuMQ I97Z2oVBLyHFcJ52kzjriQ8UVLKO7jKzO+6Nz2HufECYg9Ipcpls0aAijGKjmtq4 rIPJhq9vc0jOjDzEpPAVxZ4AQwcm/stwL/PZQJS64o9GzV4+K0b0gjaRoSU9NRdU OIkRULrWrap9pBf1ov+nxiSWN4lZjm2QMVanUJSbHFe/DnvzJgFl1/GXA1wFL1hN EboaqcS+Ng43hR2aKiRnIfYfjVI5z1kMm2D5WQrMEopVf1WBOrPIM4SiW8tjJ8Js HfSv32O4aGZ4ES1Z =4Za2 -----END PGP SIGNATURE----- --=-=-=-- From debbugs-submit-bounces@debbugs.gnu.org Mon Sep 06 17:03:03 2021 Received: (at 50377) by debbugs.gnu.org; 6 Sep 2021 21:03:03 +0000 Received: from localhost ([127.0.0.1]:54600 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mNLle-000749-UK for submit@debbugs.gnu.org; Mon, 06 Sep 2021 17:03:03 -0400 Received: from eggs.gnu.org ([209.51.188.92]:46020) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mNLld-00073f-Lg for 50377@debbugs.gnu.org; Mon, 06 Sep 2021 17:03:01 -0400 Received: from fencepost.gnu.org ([2001:470:142:3::e]:53406) by eggs.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mNLlY-0004kf-EH for 50377@debbugs.gnu.org; Mon, 06 Sep 2021 17:02:56 -0400 Received: from [2a01:e0a:1d:7270:af76:b9b:ca24:c465] (port=35330 helo=ribbon) by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mNLlT-0002D0-2Y; Mon, 06 Sep 2021 17:02:55 -0400 From: =?utf-8?Q?Ludovic_Court=C3=A8s?= To: Marius Bakke Subject: Re: bug#50377: [PATCH 0/2] Support 'git describe' style commit IDs in transformations References: <20210906103846.14941-1-marius@gnu.org> <20210906103846.14941-2-marius@gnu.org> Date: Mon, 06 Sep 2021 23:02:49 +0200 In-Reply-To: <20210906103846.14941-2-marius@gnu.org> (Marius Bakke's message of "Mon, 6 Sep 2021 12:38:45 +0200") Message-ID: <87pmtl76yu.fsf_-_@gnu.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.2 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 50377 Cc: 50377@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) Howdy! Marius Bakke skribis: > * guix/git.scm (resolve-reference): Rewrite tag-or-commit case to recogni= ze > 'git describe' style identifiers and resolve them as commits. LGTM! Ludo=E2=80=99. From debbugs-submit-bounces@debbugs.gnu.org Mon Sep 06 17:04:56 2021 Received: (at 50377) by debbugs.gnu.org; 6 Sep 2021 21:04:56 +0000 Received: from localhost ([127.0.0.1]:54604 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mNLnU-00076o-8L for submit@debbugs.gnu.org; Mon, 06 Sep 2021 17:04:56 -0400 Received: from eggs.gnu.org ([209.51.188.92]:46390) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mNLnS-00076a-Rk for 50377@debbugs.gnu.org; Mon, 06 Sep 2021 17:04:55 -0400 Received: from fencepost.gnu.org ([2001:470:142:3::e]:53450) by eggs.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mNLnN-0005xt-Ls for 50377@debbugs.gnu.org; Mon, 06 Sep 2021 17:04:49 -0400 Received: from [2a01:e0a:1d:7270:af76:b9b:ca24:c465] (port=35334 helo=ribbon) by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mNLnN-0003Si-CR; Mon, 06 Sep 2021 17:04:49 -0400 From: =?utf-8?Q?Ludovic_Court=C3=A8s?= To: Marius Bakke Subject: Re: bug#50377: [PATCH 0/2] Support 'git describe' style commit IDs in transformations References: <20210906103846.14941-1-marius@gnu.org> <20210906103846.14941-3-marius@gnu.org> Date: Mon, 06 Sep 2021 23:04:47 +0200 In-Reply-To: <20210906103846.14941-3-marius@gnu.org> (Marius Bakke's message of "Mon, 6 Sep 2021 12:38:46 +0200") Message-ID: <87lf4976vk.fsf_-_@gnu.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.2 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 50377 Cc: 50377@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) Marius Bakke 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"): N= ew > 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 li= ke "v1.0" > + (else > + (string-append "git." > + (if (< (string-length commit) 7) > + commit > + (string-take commit 7)))))) For clarity, I=E2=80=99d extract this as a =E2=80=98commit->version-string= =E2=80=99 procedure. Like Xinglu writes, it=E2=80=99d be great to add a sentence in the manual a= bout these IDs. Apart from that, it=E2=80=99s a good idea and it LGTM! Thanks, Ludo=E2=80=99. From debbugs-submit-bounces@debbugs.gnu.org Wed Sep 08 12:08:25 2021 Received: (at 50377-done) by debbugs.gnu.org; 8 Sep 2021 16:08:25 +0000 Received: from localhost ([127.0.0.1]:33399 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mO07c-00028T-OT for submit@debbugs.gnu.org; Wed, 08 Sep 2021 12:08:24 -0400 Received: from eggs.gnu.org ([209.51.188.92]:54580) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mO07b-00028E-Lu for 50377-done@debbugs.gnu.org; Wed, 08 Sep 2021 12:08:23 -0400 Received: from fencepost.gnu.org ([2001:470:142:3::e]:51860) by eggs.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mO07W-0004QA-Ac; Wed, 08 Sep 2021 12:08:18 -0400 Received: from host-37-191-231-185.lynet.no ([37.191.231.185]:38052 helo=localhost) by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mO07V-0001ql-6Y; Wed, 08 Sep 2021 12:08:17 -0400 From: Marius Bakke To: Ludovic =?utf-8?Q?Court=C3=A8s?= Subject: Re: bug#50377: [PATCH 0/2] Support 'git describe' style commit IDs in transformations In-Reply-To: <87lf4976vk.fsf_-_@gnu.org> References: <20210906103846.14941-1-marius@gnu.org> <20210906103846.14941-3-marius@gnu.org> <87lf4976vk.fsf_-_@gnu.org> Date: Wed, 08 Sep 2021 18:08:14 +0200 Message-ID: <87lf476oep.fsf@gnu.org> MIME-Version: 1.0 Content-Type: multipart/signed; boundary="=-=-="; micalg=pgp-sha512; protocol="application/pgp-signature" X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 50377-done Cc: 50377-done@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Ludovic Court=C3=A8s skriver: > Marius Bakke 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 revisio= n) >> + (string-every char-set:hex-digit >> + (string-drop g+commit = 1)))) >> + (_ #f))) >> + ;; This looks like a 'git describe' style ID. Dr= op >> + ;; 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 l= ike "v1.0" >> + (else >> + (string-append "git." >> + (if (< (string-length commit) 7) >> + commit >> + (string-take commit 7)))))) > > For clarity, I=E2=80=99d extract this as a =E2=80=98commit->version-strin= g=E2=80=99 procedure. > > Like Xinglu writes, it=E2=80=99d 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 I= Ds. 16ef7b4938 transformations: Git tags and 'git describe' style IDs are use= d as version. Thanks, Marius --=-=-= Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iIUEARYKAC0WIQRNTknu3zbaMQ2ddzTocYulkRQQdwUCYTjf7g8cbWFyaXVzQGdu dS5vcmcACgkQ6HGLpZEUEHeXPAEA0Sx3OdL8ncu1he5ExARMyYKv3ogMf4B0I87q DzmuqzEA/3aX9gvgDXvZKrVdqPJZJrmy+zHqMdXoEk3cJCFyde0H =JlKG -----END PGP SIGNATURE----- --=-=-=-- From unknown Tue Jun 24 06:58:00 2025 Received: (at fakecontrol) by fakecontrolmessage; To: internal_control@debbugs.gnu.org From: Debbugs Internal Request Subject: Internal Control Message-Id: bug archived. Date: Thu, 07 Oct 2021 11:24:05 +0000 User-Agent: Fakemail v42.6.9 # This is a fake control message. # # The action: # bug archived. thanks # This fakemail brought to you by your local debbugs # administrator