Merge pull request #25 from hercules-ci/dont-readdir-store

Don't readDir the store
This commit is contained in:
Robert Hensing 2019-09-18 14:12:53 +02:00 committed by GitHub
commit 93b4849d98
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -129,6 +129,7 @@ rec {
inspectDirAndUp = dirPath: let
go = p: acc:
let
parentDir = dirOf p;
dirInfo = inspectDir p;
isHighest = dirInfo.isWorkTreeRoot || p == /. || p == "/";
dirs = [dirInfo] ++ acc;
@ -138,7 +139,7 @@ rec {
else [];
in
if isHighest
if isHighest || isForbiddenDir (parentDir)
then
{
localIgnores = concatMap getIgnores dirs;
@ -146,10 +147,19 @@ rec {
inherit (dirInfo) gitDir;
}
else
go (dirOf p) dirs
go parentDir dirs
;
in go dirPath [];
# isForbiddenDir: string -> bool
#
# Some directories should never be traversed when looking for .git
# - for performance
# - to help lorri and possibly other tools that monitor which paths are read
# during evaluation
isForbiddenDir = p:
p == builtins.storeDir || p == "/";
# TODO: only readDir lazily for the .git type. Rest can be done efficiently with pathExists
inspectDir = dirPath:
let