Merge pull request #11 from hercules-ci/git-worktree

Support git worktrees in fetchgit logic
This commit is contained in:
Eelco Dolstra 2020-10-27 12:08:32 +01:00 committed by GitHub
commit 19576c2aea
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -74,16 +74,15 @@ let
in outputs; in outputs;
rootSrc = let rootSrc = let
dir = builtins.readDir src;
gitDir = builtins.readDir (src + "/.git");
isGitDir = dir ? ".git" && dir.".git" == "directory";
isShallow = gitDir ? "shallow";
# Try to clean the source tree by using fetchGit, if this source # Try to clean the source tree by using fetchGit, if this source
# tree is a valid git repository. # tree is a valid git repository.
tryFetchGit = src: tryFetchGit = src:
if isGitDir && !isShallow if isGit && !isShallow
then builtins.fetchGit src then builtins.fetchGit src
else { outPath = 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 in
(if src ? outPath then src else tryFetchGit src) (if src ? outPath then src else tryFetchGit src)