Skip to content

Commit a7a6c4f

Browse files
committed
Test against NixOS#10773
1 parent 5217e30 commit a7a6c4f

1 file changed

Lines changed: 13 additions & 0 deletions

File tree

tests/functional/fetchGit.sh

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,19 @@ git -C "$repo" commit -m 'Bla4'
161161
rev3=$(git -C "$repo" rev-parse HEAD)
162162
nix eval --tarball-ttl 3600 --expr "builtins.fetchGit { url = $repo; rev = \"$rev3\"; }" >/dev/null
163163

164+
# Fetching a rev that is already cached should not hit the network,
165+
# even when the cached HEAD ref has expired (NixOS/nix#10773).
166+
export _NIX_FORCE_HTTP=1
167+
nix eval --expr "builtins.fetchGit { url = file://$repo; rev = \"$rev3\"; }" >/dev/null
168+
# Make the repo unavailable so any network access triggers a warning.
169+
mv "$repo" "${repo}"-tmp
170+
path6=$(nix eval --tarball-ttl 0 --raw --expr "(builtins.fetchGit { url = file://$repo; rev = \"$rev3\"; }).outPath" 2>"$TEST_ROOT/stderr-10773")
171+
[[ $(cat "$path6"/hello) = delft ]]
172+
# The old code would try to resolve HEAD here and emit this warning.
173+
(! grep -q "could not get HEAD ref" < "$TEST_ROOT/stderr-10773")
174+
mv "${repo}"-tmp "$repo"
175+
unset _NIX_FORCE_HTTP
176+
164177
# Update 'path' to reflect latest master
165178
path=$(nix eval --impure --raw --expr "(builtins.fetchGit file://$repo).outPath")
166179

0 commit comments

Comments
 (0)