summaryrefslogtreecommitdiff
path: root/guix
diff options
context:
space:
mode:
authorLudovic Courtès <ludo@gnu.org>2025-06-08 17:41:20 +0200
committerLudovic Courtès <ludo@gnu.org>2025-06-22 23:45:36 +0200
commit0ec5cab132599cf644f0697c5f189366c1ebc773 (patch)
treec3971f47bf91fca1bc132323f6e832fcc85b1f8a /guix
parent56eb949f3b4d10c1d8738eae96ac247b74bf20b9 (diff)
git authenticate: Gracefully handle passing an annotated tag to ‘--end’.
Partly fixes <https://issues.guix.gnu.org/74583>. Previously, passing an annotated tag to ‘--end’, as can happen when ‘guix git authenticate’ is invoked by the pre-push hook when pushing tags, would lead to an error: guix git: error: Git error: the requested type does not match the type in the ODB * guix/scripts/git/authenticate.scm (ensure-commit-id): New procedure. (guix-git-authenticate): Use it. * tests/guix-git-authenticate.sh: Test with $v1_2_0_annotated_tag. Change-Id: I22e8eb665609522c80c1f0dcb9e77a46c23c0c3c
Diffstat (limited to 'guix')
-rw-r--r--guix/scripts/git/authenticate.scm10
1 files changed, 9 insertions, 1 deletions
diff --git a/guix/scripts/git/authenticate.scm b/guix/scripts/git/authenticate.scm
index 3bc72a70b1..5f05428461 100644
--- a/guix/scripts/git/authenticate.scm
+++ b/guix/scripts/git/authenticate.scm
@@ -233,6 +233,14 @@ known-broken version is installed."
(display %pre-push-hook port)
(chmod port #o755)))))
+(define (ensure-commit-id repository oid)
+ "If OID refers to an annotated tag, return its target commit; otherwise
+return OID."
+ (let ((obj (object-lookup repository oid)))
+ (if (= OBJ-TAG (object-type obj))
+ (tag-target-id (tag-lookup repository oid))
+ oid)))
+
(define (show-stats stats)
"Display STATS, an alist containing commit signing stats as returned by
'authenticate-repository'."
@@ -337,7 +345,7 @@ expected COMMIT and SIGNER~%")))
(end (match (assoc-ref options 'end-commit)
(#f (reference-target
(repository-head repository)))
- (oid oid)))
+ (oid (ensure-commit-id repository oid))))
(history (match (assoc-ref options 'historical-authorizations)
(#f '())
(file (call-with-input-file file