From 84d9e213d2dc8b09705b0668184f33ddd0a004b1 Mon Sep 17 00:00:00 2001 From: Will Dietz Date: Tue, 9 Jan 2018 08:58:19 -0600 Subject: [PATCH 1/2] fetchGit.sh: Test we don't "corrupt" cache if invoke w/o git avail --- tests/fetchGit.sh | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/tests/fetchGit.sh b/tests/fetchGit.sh index 65d673c08..b556fe594 100644 --- a/tests/fetchGit.sh +++ b/tests/fetchGit.sh @@ -119,3 +119,16 @@ path4=$(nix eval --raw "(builtins.fetchGit $repo).outPath") # Confirm same as 'dev' branch path5=$(nix eval --raw "(builtins.fetchGit { url = $repo; ref = \"dev\"; }).outPath") [[ $path3 = $path5 ]] + + +# Nuke the cache +rm -rf $TEST_HOME/.cache/nix/git + +# Try again, but without 'git' on PATH +NIX=$(command -v nix) +# This should fail +(! PATH= $NIX eval --raw "(builtins.fetchGit { url = $repo; ref = \"dev\"; }).outPath" ) + +# Try again, with 'git' available. This should work. +path5=$(nix eval --raw "(builtins.fetchGit { url = $repo; ref = \"dev\"; }).outPath") +[[ $path3 = $path5 ]] From 428680b3076a01f278ed629aa3b1744d11a2c231 Mon Sep 17 00:00:00 2001 From: Will Dietz Date: Tue, 9 Jan 2018 09:05:18 -0600 Subject: [PATCH 2/2] fetchGit: fix creation of uninitialized cache dir, let git create it fetchGit test (as modified in previous commit) now passes. --- src/libexpr/primops/fetchGit.cc | 1 - 1 file changed, 1 deletion(-) diff --git a/src/libexpr/primops/fetchGit.cc b/src/libexpr/primops/fetchGit.cc index 0d0b11958..fb664cffb 100644 --- a/src/libexpr/primops/fetchGit.cc +++ b/src/libexpr/primops/fetchGit.cc @@ -85,7 +85,6 @@ GitInfo exportGit(ref store, const std::string & uri, Path cacheDir = getCacheDir() + "/nix/git"; if (!pathExists(cacheDir)) { - createDirs(cacheDir); runProgram("git", true, { "init", "--bare", cacheDir }); }