commit
0552944ada
3 changed files with 23 additions and 14 deletions
|
|
@ -24,20 +24,25 @@ rec {
|
|||
basePathStr = toString basePath;
|
||||
in
|
||||
path: type: let
|
||||
localPath = removePrefix basePathStr (toString path);
|
||||
localPathElements = splitString "/" localPath;
|
||||
getPatterns = patternTree: pathElems:
|
||||
if length pathElems == 0
|
||||
then patternTree
|
||||
else let hd = head pathElems; in
|
||||
if hd == "" || hd == "."
|
||||
then getPatterns patternTree (tail pathElems)
|
||||
else if hasAttr hd patternTree
|
||||
then getPatterns patternTree."${hd}" (tail pathElems)
|
||||
else patternTree # Files are not in the tree, so we return the
|
||||
# most patterns we could find here.
|
||||
;
|
||||
in parse-gitignore.runFilterPattern' (getPatterns patternsBelowP localPathElements)."/patterns" path type;
|
||||
localDirPath = removePrefix basePathStr (toString (dirOf path));
|
||||
localDirPathElements = splitString "/" localDirPath;
|
||||
in parse-gitignore.runFilterPattern' (getPatterns patternsBelowP localDirPathElements)."/patterns" path type;
|
||||
|
||||
getPatterns =
|
||||
patternTree: pathElems:
|
||||
if length pathElems == 0
|
||||
then patternTree
|
||||
else let hd = head pathElems; in
|
||||
if hd == "" || hd == "."
|
||||
then getPatterns patternTree (tail pathElems)
|
||||
else
|
||||
if hasAttr hd patternTree
|
||||
then getPatterns patternTree."${hd}" (tail pathElems)
|
||||
else
|
||||
# Files are not in the tree, so we return the
|
||||
# most patterns we could find here.
|
||||
patternTree;
|
||||
|
||||
|
||||
#####
|
||||
# Constructing a tree of patterns per non-ignored subdirectory, recursively
|
||||
|
|
|
|||
|
|
@ -20,5 +20,6 @@ in
|
|||
subdir-3 = runner.makeTest { name = "subdir-3"; rootDir = testdata.sourceUnfiltered + "/test-tree"; subpath = "3-wildcards"; };
|
||||
subdir-4 = runner.makeTest { name = "subdir-4"; rootDir = testdata.sourceUnfiltered + "/test-tree"; subpath = "4-escapes"; };
|
||||
subdir-9 = runner.makeTest { name = "subdir-9"; rootDir = testdata.sourceUnfiltered + "/test-tree"; subpath = "9-expected"; };
|
||||
subdir-10 = runner.makeTest { name = "subdir-10"; rootDir = testdata.sourceUnfiltered + "/test-tree"; subpath = "10-subdir-ignoring-itself"; };
|
||||
|
||||
}
|
||||
|
|
@ -30,6 +30,9 @@ let
|
|||
touches 5-directory {1,2,3,4,5,^,$,^$,$^,[,[[,],]],]]],ab,bb,\\,\\\\}
|
||||
|
||||
touches 9-expected {unfiltered,filtered-via-aux-{filter,ignore,filepath}}
|
||||
|
||||
touches 10-subdir-ignoring-itself/foo {foo,bar}
|
||||
echo foo >10-subdir-ignoring-itself/foo/.gitignore
|
||||
); }
|
||||
|
||||
create-tree "$1"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue