[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
04/11: git: Add ‘tag->commit’ and use it in (guix channels).
From: |
guix-commits |
Subject: |
04/11: git: Add ‘tag->commit’ and use it in (guix channels). |
Date: |
Mon, 15 Apr 2024 17:40:55 -0400 (EDT) |
civodul pushed a commit to branch master
in repository guix.
commit 96d2de01853a5955ad882a565c903e1b1689b4f0
Author: Ludovic Courtès <ludo@gnu.org>
AuthorDate: Sun Mar 31 23:31:21 2024 +0200
git: Add ‘tag->commit’ and use it in (guix channels).
* guix/git.scm (tag->commit): New procedure, taken from…
(resolve-reference): … here. Use it in the ‘tag’ case.
* guix/channels.scm (resolve-channel-news-entry-tag): Use ‘tag->commit’
instead of custom code.
Change-Id: I46ea387345dc1b695ce0702991a52d0cde29e2f0
---
guix/channels.scm | 11 +++--------
guix/git.scm | 24 +++++++++++++++---------
2 files changed, 18 insertions(+), 17 deletions(-)
diff --git a/guix/channels.scm b/guix/channels.scm
index 0b776ab211..70608561f9 100644
--- a/guix/channels.scm
+++ b/guix/channels.scm
@@ -26,6 +26,7 @@
commit-difference
repository-info
commit-short-id
+ tag->commit
with-repository)
#:autoload (guix git-authenticate) (authenticate-repository)
#:autoload (guix openpgp) (openpgp-public-key-fingerprint
@@ -1148,14 +1149,8 @@ the field its 'tag' refers to. A 'git-error' exception
is raised if the tag
cannot be found."
(if (channel-news-entry-commit entry)
entry
- (let* ((tag (channel-news-entry-tag entry))
- (reference (reference-lookup repository
- (string-append "refs/tags/" tag)))
- (target (reference-target reference))
- (oid (let ((obj (object-lookup repository target)))
- (if (= OBJ-TAG (object-type obj)) ;annotated tag?
- (tag-target-id (tag-lookup repository target))
- target))))
+ (let* ((tag (channel-news-entry-tag entry))
+ (oid (object-id (tag->commit repository tag))))
(channel-news-entry (oid->string oid) tag
(channel-news-entry-title entry)
(channel-news-entry-body entry)))))
diff --git a/guix/git.scm b/guix/git.scm
index eab84ea798..8e1d863976 100644
--- a/guix/git.scm
+++ b/guix/git.scm
@@ -68,6 +68,7 @@
commit-descendant?
commit-id?
commit-short-id
+ tag->commit
remote-refs
@@ -237,6 +238,19 @@ is a tag name. This is based on a simple heuristic so use
with care!"
(define commit-short-id
(compose (cut string-take <> 7) oid->string commit-id))
+(define (tag->commit repository tag)
+ "Resolve TAG in REPOSITORY and return the corresponding object, usually a
+commit."
+ (let* ((oid (reference-name->oid repository
+ (string-append "refs/tags/" tag)))
+ (obj (object-lookup repository oid)))
+ ;; OID may designate an "annotated tag" object or a "commit" object.
+ ;; Return the commit object in both cases.
+ (if (= OBJ-TAG (object-type obj))
+ (object-lookup repository
+ (tag-target-id (tag-lookup repository oid)))
+ obj)))
+
(define (resolve-reference repository ref)
"Resolve the branch, commit or tag specified by REF, and return the
corresponding Git object."
@@ -283,15 +297,7 @@ corresponding Git object."
;; 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)))
- (obj (object-lookup repository oid)))
- ;; OID may designate an "annotated tag" object or a "commit" object.
- ;; Return the commit object in both cases.
- (if (= OBJ-TAG (object-type obj))
- (object-lookup repository
- (tag-target-id (tag-lookup repository oid)))
- obj))))))
+ (tag->commit repository tag)))))
(define (switch-to-ref repository ref)
"Switch to REPOSITORY's branch, commit or tag specified by REF. Return the
- 05/11: channels: Autoload (git …) modules., (continued)
- 05/11: channels: Autoload (git …) modules., guix-commits, 2024/04/15
- 06/11: guix system: Autoload some more., guix-commits, 2024/04/15
- 11/11: Autoload (gcrypt hash)., guix-commits, 2024/04/15
- 10/11: Autoload (guix build syscalls)., guix-commits, 2024/04/15
- 01/11: channels: Use SRFI-71 instead of SRFI-11., guix-commits, 2024/04/15
- 03/11: channels: Move ‘commit-short-id’ to (guix git)., guix-commits, 2024/04/15
- 08/11: guix: Delay loading of (gnutls)., guix-commits, 2024/04/15
- 09/11: ui: Delay use of (guix build syscalls)., guix-commits, 2024/04/15
- 02/11: git: Add ‘repository-info’ and use it in (guix channels)., guix-commits, 2024/04/15
- 07/11: utils: Don’t re-export ‘call-with-temporary-output-file’., guix-commits, 2024/04/15
- 04/11: git: Add ‘tag->commit’ and use it in (guix channels).,
guix-commits <=