aboutsummaryrefslogtreecommitdiff
path: root/tests/fetchGit.sh
diff options
context:
space:
mode:
authorWill Dietz <w@wdtz.org>2017-12-22 14:18:29 -0600
committerWill Dietz <w@wdtz.org>2017-12-22 15:29:52 -0600
commit2e6f06c37e26a5ac5be35fe18f283a1b26de64bf (patch)
treeac324b128560f6f1610076ab08b0a8325f6dad30 /tests/fetchGit.sh
parentaa43cbb7646e880f871df4280f8a1909520136f0 (diff)
fetchGit: Fix handling of local repo when not using 'master' branch
Add tests checking this behavior.
Diffstat (limited to 'tests/fetchGit.sh')
-rw-r--r--tests/fetchGit.sh26
1 files changed, 26 insertions, 0 deletions
diff --git a/tests/fetchGit.sh b/tests/fetchGit.sh
index 09e4f7426..65d673c08 100644
--- a/tests/fetchGit.sh
+++ b/tests/fetchGit.sh
@@ -93,3 +93,29 @@ git -C $repo add hello
git -C $repo commit -m 'Bla4'
rev3=$(git -C $repo rev-parse HEAD)
nix eval --tarball-ttl 3600 "(builtins.fetchGit { url = $repo; rev = \"$rev3\"; })" >/dev/null
+
+# Update 'path' to reflect latest master
+path=$(nix eval --raw "(builtins.fetchGit file://$repo).outPath")
+
+# Check behavior when non-master branch is used
+git -C $repo checkout $rev2 -b dev
+echo dev > $repo/hello
+
+# File URI uses 'master' unless specified otherwise
+path2=$(nix eval --raw "(builtins.fetchGit file://$repo).outPath")
+[[ $path = $path2 ]]
+
+# Using local path with branch other than 'master' should work when clean or dirty
+path3=$(nix eval --raw "(builtins.fetchGit $repo).outPath")
+# (check dirty-tree handling was used)
+[[ $(nix eval --raw "(builtins.fetchGit $repo).rev") = 0000000000000000000000000000000000000000 ]]
+
+# Committing shouldn't change store path, or switch to using 'master'
+git -C $repo commit -m 'Bla5' -a
+path4=$(nix eval --raw "(builtins.fetchGit $repo).outPath")
+[[ $(cat $path4/hello) = dev ]]
+[[ $path3 = $path4 ]]
+
+# Confirm same as 'dev' branch
+path5=$(nix eval --raw "(builtins.fetchGit { url = $repo; ref = \"dev\"; }).outPath")
+[[ $path3 = $path5 ]]