From: Marius Bakke <marius@gnu.org>
To: 50377@debbugs.gnu.org
Subject: [bug#50377] [PATCH v2 1/2] git: 'resolve-reference' handles 'git describe'-style commit IDs.
Date: Mon, 06 Sep 2021 00:52:08 +0200 [thread overview]
Message-ID: <87pmtmprdz.fsf@gnu.org> (raw)
In-Reply-To: <20210904181035.24161-1-marius@gnu.org>
[-- 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 --]
next prev parent reply other threads:[~2021-09-05 22:53 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
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 ` Marius Bakke [this message]
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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://guix.gnu.org/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87pmtmprdz.fsf@gnu.org \
--to=marius@gnu.org \
--cc=50377@debbugs.gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this 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).