forked from lix-project/lix
Merge branch 'better-git-cache' of https://github.com/graham-at-target/nix
This commit is contained in:
commit
3f4de91d80
|
@ -3,6 +3,7 @@
|
||||||
#include "download.hh"
|
#include "download.hh"
|
||||||
#include "store-api.hh"
|
#include "store-api.hh"
|
||||||
#include "pathlocks.hh"
|
#include "pathlocks.hh"
|
||||||
|
#include "hash.hh"
|
||||||
|
|
||||||
#include <sys/time.h>
|
#include <sys/time.h>
|
||||||
|
|
||||||
|
@ -84,9 +85,10 @@ GitInfo exportGit(ref<Store> store, const std::string & uri,
|
||||||
if (rev != "" && !std::regex_match(rev, revRegex))
|
if (rev != "" && !std::regex_match(rev, revRegex))
|
||||||
throw Error("invalid Git revision '%s'", rev);
|
throw Error("invalid Git revision '%s'", rev);
|
||||||
|
|
||||||
Path cacheDir = getCacheDir() + "/nix/git";
|
Path cacheDir = getCacheDir() + "/nix/gitv2/" + hashString(htSHA256, uri).to_string(Base32, false);
|
||||||
|
|
||||||
if (!pathExists(cacheDir)) {
|
if (!pathExists(cacheDir)) {
|
||||||
|
createDirs(dirOf(cacheDir));
|
||||||
runProgram("git", true, { "init", "--bare", cacheDir });
|
runProgram("git", true, { "init", "--bare", cacheDir });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -9,7 +9,7 @@ clearStore
|
||||||
|
|
||||||
repo=$TEST_ROOT/git
|
repo=$TEST_ROOT/git
|
||||||
|
|
||||||
rm -rf $repo ${repo}-tmp $TEST_HOME/.cache/nix/git
|
rm -rf $repo ${repo}-tmp $TEST_HOME/.cache/nix/gitv2
|
||||||
|
|
||||||
git init $repo
|
git init $repo
|
||||||
git -C $repo config user.email "foobar@example.com"
|
git -C $repo config user.email "foobar@example.com"
|
||||||
|
@ -129,7 +129,7 @@ path5=$(nix eval --raw "(builtins.fetchGit { url = $repo; ref = \"dev\"; }).outP
|
||||||
|
|
||||||
|
|
||||||
# Nuke the cache
|
# Nuke the cache
|
||||||
rm -rf $TEST_HOME/.cache/nix/git
|
rm -rf $TEST_HOME/.cache/nix/gitv2
|
||||||
|
|
||||||
# Try again, but without 'git' on PATH
|
# Try again, but without 'git' on PATH
|
||||||
NIX=$(command -v nix)
|
NIX=$(command -v nix)
|
||||||
|
|
Loading…
Reference in a new issue