Commit Graph
14 Commits
Author SHA1 Message Date
Simon Tournier f729199e7b tests: git: Avoid duplicated helper code.
* tests/git.scm (git): New procedure.
("update-cached-checkout, tag",
"update-cached-checkout, recursive submodules follow ref",
"update-cached-checkout, symref tag",
"update-cached-checkout, symref pull-request"): Use it.

Change-Id: I85aa14e729be1efe691418e74e37d6ae1fd3e633
2026-07-06 12:00:49 +02:00
Simon Tournier 1178100657 tests: git: Avoid nested checks for submodules.
Follow up of 8d27b1158d discussed in #9231.

* tests/git.scm ("update-cached-checkout, recursive submodules follow ref"):
Replace the nested 'let' by 'let*'.

Merges: #9683
Change-Id: Ibd212bbd2b6fbf02f6fcae0ecb21922686b5f8bc
2026-07-06 12:00:25 +02:00
Phillip Davis 8d27b1158d git: Update submodules after switching cached checkout.
Previously, update-cached-checkout updated submodules before switching the
cached parent checkout to the requested ref.  A second recursive update could
therefore update submodules according to the previously checked-out parent
tree, then reset the parent to a ref whose gitlinks name different submodule
commits, leaving submodule worktrees stale.

* guix/git.scm (update-cached-checkout): Update submodules after switching to the requested ref.
* tests/git.scm ("update-cached-checkout, recursive submodules follow ref"): New test.

Signed-off-by: Ludovic Courtès <ludo@gnu.org>
Fixes: guix/guix#7741
Merges: #9231
2026-07-02 19:17:18 +02:00
Simon Tournier ba3f2687ca tests: git: Improve Git tag check.
Without running 'checkout' as the last Git directives to one branch that
doesn't own the Git tag, the test is trivial thus poorly relevant.  This
change checks that 'update-cached-checkout' and that the 'cached-directory'
return both the correct Git object identifier matching the upstream Git object
identifier of the Git tag.

* tests/git.scm ("update-cached-checkout, tag"): Switch to 'master' branch and
improve the checks.

Fixes: guix/guix#9340
Merges: guix/guix!9341
Change-Id: I698f94858a4247b8bdcc54758f38f3623890b6af
2026-06-30 12:08:09 +02:00
Simon Tournier 7dfab8bbfc 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
2026-06-25 10:55:17 +02:00
Ludovic CourtèsandRicardo Wurmus 58e268c2e3 git: Remove untracked files from cached checkouts.
Cached checkouts could end up with stale untracked files, for example
because the checkout was interrupted.  As a result, when this happens
for the Guix checkout, users would not get substitutes for ‘guix pull’.

* guix/git.scm (delete-untracked-files): New procedure.
(switch-to-ref): Use it.
* tests/git.scm ("update-cached-checkout, untracked files removed"): New
test.

Co-authored-by: Ricardo Wurmus <rekado@elephly.net>
Change-Id: Iccbe644ade396ad27a037db7e0ef1c2a68ef91ce
2024-07-18 17:31:19 +02:00
Ludovic Courtès ba21eeb565 tests: Assume ‘git’ is always available.
* tests/channels.scm (gpg+git-available?): Check for ‘gpg-command’
only.
Remove all ‘test-skip’ statements.
* tests/derivations.scm: Likewise.
* tests/git-authenticate.scm: Likewise.
* tests/git.scm: Likewise.
* tests/import-git.scm: Likewise.
2023-09-26 17:36:59 +02:00
Ludovic Courtès 46f7011591 git: 'update-cached-checkout' returns the commit ID when given a tag.
Previously, starting with commit
efa578ecae, '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.
2022-10-17 09:37:27 +02:00
Ludovic Courtès 87d49346f3 git: Add 'commit-descendant?'.
* guix/git.scm (commit-descendant?): New procedure.
* tests/git.scm ("commit-descendant?"): New test.
2022-02-14 11:23:07 +01:00
Xinglu ChenandSarah Morgensen 59ee10754e import: Add 'generic-git' updater.
* guix/git.scm (ls-remote-refs): New procedure.
* tests/git.scm ("remote-refs" "remote-refs: only tags"): New tests.
* guix/import/git.scm: New file.
* doc/guix.texi (Invoking guix refresh): Document it.
* tests/import-git.scm: New test file.
* Makefile.am (MODULES, SCM_TESTS): Register the new files.

Co-authored-by: Sarah Morgensen <iskarian@mgsn.dev>
Signed-off-by: Ludovic Courtès <ludo@gnu.org>
2021-09-18 19:37:45 +02:00
Ludovic Courtès 72357e2170 git: 'commit-difference' really excludes the ancestors of #:excluded.
* guix/git.scm (commit-difference): Initialize VISITED to the closure of
OLD and EXCLUDED, as written in the docstring.
* tests/git.scm ("commit-difference, excluded commits"): Adjust
accordingly.
2020-06-09 00:34:52 +02:00
Ludovic Courtès c098c11be8 git: Add 'commit-relation'.
* guix/git.scm (commit-relation): New procedure.
* tests/git.scm ("commit-relation"): New test.
2020-05-25 00:00:28 +02:00
Ludovic Courtès 785af04a75 git: 'commit-difference' takes a list of excluded commits.
* guix/git.scm (commit-closure): Add 'visited' optional parameter.
(commit-difference): Add 'excluded' optional parameter; pass second
argument to 'commit-closure'.
* tests/git.scm ("commit-difference, excluded commits"): New test.
2019-12-27 13:52:49 +01:00
Ludovic Courtès 873f6f1334 git: Add 'commit-difference'.
* guix/git.scm (commit-closure, commit-difference): New procedures.
* guix/tests/git.scm, tests/git.scm: New files.
* Makefile.am (dist_noinst_DATA): Add guix/tests/git.scm.
(SCM_TESTS): Add tests/git.scm.
2019-09-23 10:38:43 +02:00