Fix ** matching
This commit is contained in:
parent
bde347457c
commit
4383398f25
2 changed files with 22 additions and 1 deletions
|
|
@ -65,7 +65,7 @@ func anchored_full_match(path string, parts []string) bool {
|
|||
for pos <= last && path != "" {
|
||||
var name string
|
||||
name, path, _ = strings.Cut(path, "/")
|
||||
switch name {
|
||||
switch parts[pos] {
|
||||
case "**":
|
||||
for pos+1 < len(parts) && parts[pos+1] == "**" {
|
||||
pos++
|
||||
|
|
@ -73,6 +73,7 @@ func anchored_full_match(path string, parts []string) bool {
|
|||
if pos == last {
|
||||
return true
|
||||
}
|
||||
pos++
|
||||
for {
|
||||
matches, err := filepath.Match(parts[pos], name)
|
||||
if err != nil {
|
||||
|
|
|
|||
|
|
@ -65,6 +65,26 @@ func TestGitignore(t *testing.T) {
|
|||
{"foo.*", []ptest{
|
||||
{"foo.txt", true}, {"foo", false}, {"a/foo.x", true}, {"foo.", true},
|
||||
}},
|
||||
|
||||
{"**", []ptest{
|
||||
{"foo", true}, {"x/foo", true}, {"foo/x", true},
|
||||
}},
|
||||
|
||||
{"**/foo", []ptest{
|
||||
{"foo", true}, {"x/foo", true}, {"foo/x", false},
|
||||
}},
|
||||
{"**/foo/bar", []ptest{
|
||||
{"foo", false}, {"x/foo", false}, {"foo/bar", true}, {"a/foo/bar", true}, {"foo/bar/a", false},
|
||||
}},
|
||||
{"foo/**", []ptest{
|
||||
{"foo", false}, {"x/foo", false}, {"foo/bar", true}, {"foo/bar/a", true}, {"foo/bar/a/", true},
|
||||
}},
|
||||
{"a/**/b", []ptest{
|
||||
{"a/b", true}, {"a/x/b", true}, {"a/x/y/b", true}, {"x/a/b", false}, {"a/b/x", false},
|
||||
}},
|
||||
{"a/**/b/**/c", []ptest{
|
||||
{"a/b/c", true}, {"a/x/b/c", true}, {"a/x/y/b/m/n/c", true},
|
||||
}},
|
||||
} {
|
||||
p, skipped := CompileGitIgnoreLine(x.line)
|
||||
if skipped {
|
||||
|
|
|
|||
Loading…
Reference in a new issue