Use fetchGit on git worktrees

Git worktrees have a file for .git and can be loaded with fetchGit.
This commit is contained in:
Robert Hensing 2020-10-27 11:42:44 +01:00
parent 94cf59784c
commit 64de97c480

View file

@ -76,12 +76,14 @@ let
rootSrc = let
dir = builtins.readDir src;
gitDir = builtins.readDir (src + "/.git");
isGitDir = dir ? ".git" && dir.".git" == "directory";
isShallow = gitDir ? "shallow";
isGit = dir ? ".git";
isGitDir = isGit && dir.".git" == "directory";
isShallow = isGitDir && gitDir ? "shallow";
# Try to clean the source tree by using fetchGit, if this source
# tree is a valid git repository.
# NB git worktrees have a file for .git, so we don't check the type of .git
tryFetchGit = src:
if isGitDir && !isShallow
if isGit && !isShallow
then builtins.fetchGit src
else { outPath = src; };