lib/ignore: Only handle lines prefixed with #include specially (fixes #4680)
GitHub-Pull-Request: https://github.com/syncthing/syncthing/pull/4684 LGTM: AudriusButkevicius, calmh
This commit is contained in:
@@ -186,7 +186,6 @@ func TestBadPatterns(t *testing.T) {
|
||||
"**/[",
|
||||
"#include nonexistent",
|
||||
"#include .stignore",
|
||||
"!#include makesnosense",
|
||||
}
|
||||
|
||||
for _, pat := range badPatterns {
|
||||
@@ -930,3 +929,30 @@ func TestDuplicateLines(t *testing.T) {
|
||||
t.Fatalf("Parsed patterns differ when manually removing duplicate lines")
|
||||
}
|
||||
}
|
||||
|
||||
func TestIssue4680(t *testing.T) {
|
||||
stignore := `
|
||||
#snapshot
|
||||
`
|
||||
|
||||
testcases := []struct {
|
||||
file string
|
||||
matches bool
|
||||
}{
|
||||
{"#snapshot", true},
|
||||
{"#snapshot/foo", true},
|
||||
}
|
||||
|
||||
pats := New(fs.NewFilesystem(fs.FilesystemTypeBasic, "."), WithCache(true))
|
||||
err := pats.Parse(bytes.NewBufferString(stignore), ".stignore")
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
for _, tc := range testcases {
|
||||
res := pats.Match(tc.file).IsIgnored()
|
||||
if res != tc.matches {
|
||||
t.Errorf("Matches(%q) == %v, expected %v", tc.file, res, tc.matches)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user