diff options
| author | tv <tv@krebsco.de> | 2026-11-13 14:01:19 +0000 |
|---|---|---|
| committer | tv <tv@krebsco.de> | 2026-11-13 15:06:32 +0100 |
| commit | 36cfd6b9fa8d729172f90e8fdd507349905d4f11 (patch) | |
| tree | 93424f012ce3b538eab7550429cc654331476d25 /tests/scenarios.nix | |
| parent | 494b3127d82ea8139a6937a1064ea58f62bfe4bf (diff) | |
populate: follow branches and tags of git sources
A ref that consists of 4 to 40 hex digits is a commit, which populate
fetches only if the work tree lacks it, unless fetchAlways is set. Any
other ref is a branch or tag, which populate fetches on every run,
resetting the work tree to the commit fetched. Resetting to the name
itself resolves to a local branch, which fetching doesn't move.
Diffstat (limited to 'tests/scenarios.nix')
| -rw-r--r-- | tests/scenarios.nix | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/tests/scenarios.nix b/tests/scenarios.nix index 4e869dc..e618fcd 100644 --- a/tests/scenarios.nix +++ b/tests/scenarios.nix @@ -595,6 +595,40 @@ assert !(krops.isLocalTarget (targets.remote "/")); } ]; })) targetKinds + # Branches and tags follow the server: a branch that moves between two + # deploys, and a tag, with full and shallow clones. + ++ concatMap (targetKind: map (shallow: scenario { + name = "git-${targetKind}-shallow${if shallow then "1" else "0"}-refs"; + inherit targetKind; + prepareDeployer = '' + git -C /fixtures/git/gitsrc.git update-ref refs/heads/moving ${gitFirst} + git -C /fixtures/git/gitsrc.git update-ref refs/tags/first ${gitFirst} + ''; + phases = [ + { + sources.x.git = { url = gitUrl; ref = "moving"; inherit shallow; }; + check = '' + expect_eq HEAD "$(git -C "$T"/x rev-parse HEAD)" ${gitFirst} + ''; + mutateDeployer = '' + git -C /fixtures/git/gitsrc.git update-ref refs/heads/moving ${gitHead} + ''; + } + { + sources.x.git = { url = gitUrl; ref = "moving"; inherit shallow; }; + check = '' + expect_eq HEAD "$(git -C "$T"/x rev-parse HEAD)" ${gitHead} + ''; + } + { + sources.x.git = { url = gitUrl; ref = "first"; inherit shallow; }; + check = '' + expect_eq HEAD "$(git -C "$T"/x rev-parse HEAD)" ${gitFirst} + ''; + } + ]; + }) [ false true ]) targetKinds + # A git source stops drawing inputs: its lock file, which Nix created and # staged, goes, so the work tree is as the commit has it. ++ map (targetKind: scenario { |
