GNU bug report logs -
#50377
[PATCH 0/2] Support 'git describe' style commit IDs in transformations
Previous Next
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.
Full log
Message #17 received at 50377 <at> debbugs.gnu.org (full text, mbox):
* 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
This bug report was last modified 3 years and 261 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.