diff options
author | Eelco Dolstra <edolstra@gmail.com> | 2020-12-22 16:39:32 +0100 |
---|---|---|
committer | Eelco Dolstra <edolstra@gmail.com> | 2020-12-22 16:39:32 +0100 |
commit | f4a9fb67da5bc55221be451556710dfacb39eda0 (patch) | |
tree | 91c3d568e09772b714dba86fa66ebc9eea6eae74 /tests | |
parent | e27044216bf597710893e0366dbff60efbdaf0a6 (diff) | |
parent | 897ae235fc2cef0ce711470a7b620241d82a1b09 (diff) |
Merge branch 'git-rev-error' of https://github.com/Ma27/nix into master
Diffstat (limited to 'tests')
-rw-r--r-- | tests/fetchGit.sh | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/tests/fetchGit.sh b/tests/fetchGit.sh index 76390fa59..1e8963d76 100644 --- a/tests/fetchGit.sh +++ b/tests/fetchGit.sh @@ -41,6 +41,19 @@ export _NIX_FORCE_HTTP=1 path=$(nix eval --impure --raw --expr "(builtins.fetchGit file://$repo).outPath") [[ $(cat $path/hello) = world ]] +# Fetch a rev from another branch +git -C $repo checkout -b devtest +echo "different file" >> $TEST_ROOT/git/differentbranch +git -C $repo add differentbranch +git -C $repo commit -m 'Test2' +git -C $repo checkout master +devrev=$(git -C $repo rev-parse devtest) +out=$(nix eval --impure --raw --expr "builtins.fetchGit { url = file://$repo; rev = \"$devrev\"; }" 2>&1) || status=$? +[[ $status == 1 ]] +[[ $out =~ 'Cannot find Git revision' ]] + +[[ $(nix eval --raw --expr "builtins.readFile (builtins.fetchGit { url = file://$repo; rev = \"$devrev\"; allRefs = true; } + \"/differentbranch\")") = 'different file' ]] + # In pure eval mode, fetchGit without a revision should fail. [[ $(nix eval --impure --raw --expr "builtins.readFile (fetchGit file://$repo + \"/hello\")") = world ]] (! nix eval --raw --expr "builtins.readFile (fetchGit file://$repo + \"/hello\")") |