lib/ignore: Ignore duplicate lines in .stignore
GitHub-Pull-Request: https://github.com/syncthing/syncthing/pull/4350 LGTM: AudriusButkevicius, calmh
This commit is contained in:
@@ -872,6 +872,7 @@ func TestLines(t *testing.T) {
|
||||
|
||||
!/a
|
||||
/*
|
||||
!/a
|
||||
`
|
||||
|
||||
pats := New(fs.NewFilesystem(fs.FilesystemTypeBasic, "."), WithCache(true))
|
||||
@@ -886,6 +887,7 @@ func TestLines(t *testing.T) {
|
||||
"",
|
||||
"!/a",
|
||||
"/*",
|
||||
"!/a",
|
||||
"",
|
||||
}
|
||||
|
||||
@@ -898,5 +900,33 @@ func TestLines(t *testing.T) {
|
||||
t.Fatalf("Lines()[%d] == %s, expected %s", i, lines[i], expectedLines[i])
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
func TestDuplicateLines(t *testing.T) {
|
||||
stignore := `
|
||||
!/a
|
||||
/*
|
||||
!/a
|
||||
`
|
||||
stignoreFiltered := `
|
||||
!/a
|
||||
/*
|
||||
`
|
||||
|
||||
pats := New(fs.NewFilesystem(fs.FilesystemTypeBasic, "testdata"), WithCache(true))
|
||||
|
||||
err := pats.Parse(bytes.NewBufferString(stignore), ".stignore")
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
patsLen := len(pats.patterns)
|
||||
|
||||
err = pats.Parse(bytes.NewBufferString(stignoreFiltered), ".stignore")
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
if patsLen != len(pats.patterns) {
|
||||
t.Fatalf("Parsed patterns differ when manually removing duplicate lines")
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user