summaryrefslogtreecommitdiff
path: root/tests/git.scm
diff options
context:
space:
mode:
authorLudovic Courtès <ludo@gnu.org>2022-10-11 11:16:23 +0200
committerLudovic Courtès <ludo@gnu.org>2022-10-17 09:37:27 +0200
commit46f7011591601b4783b2dc2c7252c41564ca0140 (patch)
tree220511d64fdf990f0c770aea605e8490655f2ae8 /tests/git.scm
parenteec920ba93ecb086366576e31b785962fbaf81c2 (diff)
git: 'update-cached-checkout' returns the commit ID when given a tag.
Previously, starting with commit efa578ecaece67366b4b0e2266de7c2faaa4ae54, 'update-cached-checkout' would return the OID of the annotated tag the tag points to. With this change it returns the OID of the commit object in all cases. * guix/git.scm (resolve-reference): In the 'tag' case, call 'tag-target-id' and 'tag-lookup' when OID designates an annotated tag. * tests/git.scm ("update-cached-checkout, tag"): New test.
Diffstat (limited to 'tests/git.scm')
-rw-r--r--tests/git.scm32
1 files changed, 31 insertions, 1 deletions
diff --git a/tests/git.scm b/tests/git.scm
index ca59d2a33e5..9c944d65b1b 100644
--- a/tests/git.scm
+++ b/tests/git.scm
@@ -22,8 +22,12 @@
22 #:use-module (guix git) 22 #:use-module (guix git)
23 #:use-module (guix tests git) 23 #:use-module (guix tests git)
24 #:use-module (guix build utils) 24 #:use-module (guix build utils)
25 #:use-module ((guix utils) #:select (call-with-temporary-directory))
25 #:use-module (srfi srfi-1) 26 #:use-module (srfi srfi-1)
26 #:use-module (srfi srfi-64)) 27 #:use-module (srfi srfi-64)
28 #:use-module (srfi srfi-71)
29 #:use-module (ice-9 popen)
30 #:use-module (ice-9 textual-ports))
27 31
28;; Test the (guix git) tools. 32;; Test the (guix git) tools.
29 33
@@ -239,4 +243,30 @@
239 (tag "v1.1" "Release 1.1")) 243 (tag "v1.1" "Release 1.1"))
240 (remote-refs directory #:tags? #t))) 244 (remote-refs directory #:tags? #t)))
241 245
246(unless (which (git-command)) (test-skip 1))
247(test-assert "update-cached-checkout, tag"
248 (call-with-temporary-directory
249 (lambda (cache)
250 (with-temporary-git-repository directory
251 '((add "a.txt" "A")
252 (commit "First commit")
253 (tag "v1.0" "release-1.0")
254 (branch "develop")
255 (checkout "develop")
256 (add "b.txt" "B")
257 (commit "Second commit")
258 (tag "v1.1" "release-1.1"))
259 (let ((directory commit relation
260 (update-cached-checkout directory
261 #:ref '(tag . "v1.1")
262 #:cache-directory cache))
263 (head (let* ((pipe (open-pipe* OPEN_READ (git-command)
264 "-C" directory
265 "rev-parse" "HEAD"))
266 (str (get-string-all pipe)))
267 (close-pipe pipe)
268 (string-trim-right str))))
269 ;; COMMIT should be the ID of the commit object, not that of the tag.
270 (string=? commit head))))))
271
242(test-end "git") 272(test-end "git")