diff options
| author | Simon Tournier <zimon.toutoune@gmail.com> | 2026-03-12 16:24:24 +0100 |
|---|---|---|
| committer | Simon Tournier <zimon.toutoune@gmail.com> | 2026-06-25 10:55:17 +0200 |
| commit | 7dfab8bbfc9778aa986d3311c0fa04215b4fd3d2 (patch) | |
| tree | 624f96972393f3bcbd8b28b98d5ef322409d5cc5 /tests | |
| parent | 65f0dc7468d5232a1c6ced0eb62814a6f3dcdc6e (diff) | |
channels: Support 'symref' branch with commit specification.
* guix/channels.scm (channel-reference): Allow 'symref' to store both branch
name and specific commit.
* guix/git.scm (resolve-reference, reference-available?): Adjust.
(update-cached-checkout)[ref->refspecs]: Adjust.
* guix/tests/git.scm (populate-git-repository): Add 'symbolic-ref' directive.
* tests/git.scm (update-cached-checkout, symref tag): Check considering Git
tag as symref.
(update-cached-checkout, symref pull-request): Mimick Pull Request symref and
check it.
Fixes: guix/guix#6910
Merges: guix/guix!7085
Change-Id: I33e2974aefcc15fff24c0df8ab7d24128c7f0046
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/git.scm | 72 |
1 files changed, 72 insertions, 0 deletions
diff --git a/tests/git.scm b/tests/git.scm index 9ccd04f0cdf..712b12c7fc4 100644 --- a/tests/git.scm +++ b/tests/git.scm | |||
| @@ -1,6 +1,7 @@ | |||
| 1 | ;;; GNU Guix --- Functional package management for GNU | 1 | ;;; GNU Guix --- Functional package management for GNU |
| 2 | ;;; Copyright © 2019-2020, 2022, 2024 Ludovic Courtès <ludo@gnu.org> | 2 | ;;; Copyright © 2019-2020, 2022, 2024 Ludovic Courtès <ludo@gnu.org> |
| 3 | ;;; Copyright © 2021 Xinglu Chen <public@yoctocell.xyz | 3 | ;;; Copyright © 2021 Xinglu Chen <public@yoctocell.xyz |
| 4 | ;;; Copyright © 2026 Simon Tournier <zimon.toutoune@gmail.com> | ||
| 4 | ;;; | 5 | ;;; |
| 5 | ;;; This file is part of GNU Guix. | 6 | ;;; This file is part of GNU Guix. |
| 6 | ;;; | 7 | ;;; |
| @@ -279,4 +280,75 @@ | |||
| 279 | (not (file-exists? | 280 | (not (file-exists? |
| 280 | (in-vicinity cache "stale-untracked-file"))))))))) | 281 | (in-vicinity cache "stale-untracked-file"))))))))) |
| 281 | 282 | ||
| 283 | (test-assert "update-cached-checkout, symref tag" | ||
| 284 | (call-with-temporary-directory | ||
| 285 | (lambda (cache) | ||
| 286 | (with-temporary-git-repository directory | ||
| 287 | '((add "a.txt" "A") | ||
| 288 | (commit "First commit") | ||
| 289 | (tag "v1.0" "release-1.0") | ||
| 290 | (branch "develop") | ||
| 291 | (checkout "develop") | ||
| 292 | (add "b.txt" "B") | ||
| 293 | (commit "Second commit") | ||
| 294 | (tag "v1.1" "release-1.1") | ||
| 295 | (checkout "master")) | ||
| 296 | (let* ((tag-directory (let* ((pipe (open-pipe* OPEN_READ (git-command) | ||
| 297 | "-C" directory | ||
| 298 | "rev-parse" "v1.1")) | ||
| 299 | (str (get-string-all pipe))) | ||
| 300 | (close-pipe pipe) | ||
| 301 | (string-trim-right str))) | ||
| 302 | (cached-directory commit relation | ||
| 303 | (update-cached-checkout directory | ||
| 304 | #:ref '(symref . "refs/tags/v1.1") | ||
| 305 | #:cache-directory cache)) | ||
| 306 | (head-cached (let* ((pipe (open-pipe* OPEN_READ (git-command) | ||
| 307 | "-C" cached-directory | ||
| 308 | ;; switch-to-ref doesn't dereference the Git object, | ||
| 309 | ;; thus it points to a Git tag object. | ||
| 310 | ;; And HEAD points to a Git commit object. | ||
| 311 | ;; Hence, the check is against Git tag objects. | ||
| 312 | ;; For the difference see: | ||
| 313 | ;; git show-ref --dereference v1.1 | ||
| 314 | "rev-parse" "v1.1")) | ||
| 315 | (str (get-string-all pipe))) | ||
| 316 | (close-pipe pipe) | ||
| 317 | (string-trim-right str)))) | ||
| 318 | (and (string=? commit head-cached) | ||
| 319 | (string=? tag-directory head-cached))))))) | ||
| 320 | |||
| 321 | (test-assert "update-cached-checkout, symref pull-request" | ||
| 322 | (call-with-temporary-directory | ||
| 323 | (lambda (cache) | ||
| 324 | (with-temporary-git-repository directory | ||
| 325 | '((add "a.txt" "A") | ||
| 326 | (commit "First commit") | ||
| 327 | (tag "v1.0" "release-1.0") | ||
| 328 | (branch "develop") | ||
| 329 | (checkout "develop") | ||
| 330 | (add "b.txt" "B") | ||
| 331 | (commit "Second commit") | ||
| 332 | (tag "v1.1" "release-1.1") | ||
| 333 | (symbolic-ref "refs/pull/1/head" "refs/heads/develop") | ||
| 334 | (checkout "master")) | ||
| 335 | (let* ((head-directory (let* ((pipe (open-pipe* OPEN_READ (git-command) | ||
| 336 | "-C" directory | ||
| 337 | "rev-parse" "refs/pull/1/head")) | ||
| 338 | (str (get-string-all pipe))) | ||
| 339 | (close-pipe pipe) | ||
| 340 | (string-trim-right str))) | ||
| 341 | (cached-directory commit relation | ||
| 342 | (update-cached-checkout directory | ||
| 343 | #:ref '(symref . "refs/pull/1/head") | ||
| 344 | #:cache-directory cache)) | ||
| 345 | (head-cached (let* ((pipe (open-pipe* OPEN_READ (git-command) | ||
| 346 | "-C" cached-directory | ||
| 347 | "rev-parse" "HEAD")) | ||
| 348 | (str (get-string-all pipe))) | ||
| 349 | (close-pipe pipe) | ||
| 350 | (string-trim-right str)))) | ||
| 351 | (and (string=? commit head-directory) | ||
| 352 | (string=? head-cached head-directory))))))) | ||
| 353 | |||
| 282 | (test-end "git") | 354 | (test-end "git") |
