Merge pull request #19 from hercules-ci/issue-18

Issue 18
This commit is contained in:
Domen Kožar 2019-09-06 14:07:36 +02:00 committed by GitHub
commit 0552944ada
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 23 additions and 14 deletions

View file

@ -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

View file

@ -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"; };
}

View file

@ -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"