mirror of
https://github.com/octoleo/syncthing.git
synced 2025-02-02 03:48:26 +00:00
lib/ignore: Match directory contents for patterns ending in / (fixes #3639)
Appends "**" to patterns with a terminal slash, so that directory contents are ignored, but not the directory itself.
This commit is contained in:
parent
2a2177e7fa
commit
fe9c2b9857
@ -345,7 +345,7 @@ func parseIgnoreFile(fd io.Reader, currentFile string, seen map[string]bool) ([]
|
||||
case strings.HasSuffix(line, "/**"):
|
||||
err = addPattern(line)
|
||||
case strings.HasSuffix(line, "/"):
|
||||
err = addPattern(line)
|
||||
err = addPattern(line + "**")
|
||||
default:
|
||||
err = addPattern(line)
|
||||
if err == nil {
|
||||
|
@ -718,3 +718,22 @@ func TestIssue3174(t *testing.T) {
|
||||
t.Error("Should match")
|
||||
}
|
||||
}
|
||||
|
||||
func TestIssue3639(t *testing.T) {
|
||||
stignore := `
|
||||
foo/
|
||||
`
|
||||
pats := New(true)
|
||||
err := pats.Parse(bytes.NewBufferString(stignore), ".stignore")
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
if !pats.Match("foo/bar").IsIgnored() {
|
||||
t.Error("Should match 'foo/bar'")
|
||||
}
|
||||
|
||||
if pats.Match("foo").IsIgnored() {
|
||||
t.Error("Should not match 'foo'")
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user