Simplify rootSrc fetchGit logic

This commit is contained in:
Robert Hensing 2020-10-27 11:48:33 +01:00
parent 64de97c480
commit 5ad681b894

View file

@ -74,18 +74,15 @@ let
in outputs;
rootSrc = let
dir = builtins.readDir src;
gitDir = builtins.readDir (src + "/.git");
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 isGit && !isShallow
then builtins.fetchGit src
else { outPath = src; };
# NB git worktrees have a file for .git, so we don't check the type of .git
isGit = builtins.pathExists (src + "/.git");
isShallow = builtins.pathExists (src + "/.git/shallow");
in
(if src ? outPath then src else tryFetchGit src)