mirror of
https://github.com/octoleo/syncthing.git
synced 2024-11-09 14:50:56 +00:00
lib/ignores: Update lines even if patterns didn't change (fixes #4689)
GitHub-Pull-Request: https://github.com/syncthing/syncthing/pull/4690
This commit is contained in:
parent
93b5180e62
commit
885e3f19bd
@ -156,6 +156,8 @@ func (m *Matcher) parseLocked(r io.Reader, file string) error {
|
|||||||
// Error is saved and returned at the end. We process the patterns
|
// Error is saved and returned at the end. We process the patterns
|
||||||
// (possibly blank) anyway.
|
// (possibly blank) anyway.
|
||||||
|
|
||||||
|
m.lines = lines
|
||||||
|
|
||||||
newHash := hashPatterns(patterns)
|
newHash := hashPatterns(patterns)
|
||||||
if newHash == m.curHash {
|
if newHash == m.curHash {
|
||||||
// We've already loaded exactly these patterns.
|
// We've already loaded exactly these patterns.
|
||||||
@ -163,7 +165,6 @@ func (m *Matcher) parseLocked(r io.Reader, file string) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
m.curHash = newHash
|
m.curHash = newHash
|
||||||
m.lines = lines
|
|
||||||
m.patterns = patterns
|
m.patterns = patterns
|
||||||
if m.withCache {
|
if m.withCache {
|
||||||
m.matches = newCache(patterns)
|
m.matches = newCache(patterns)
|
||||||
|
@ -956,3 +956,28 @@ func TestIssue4680(t *testing.T) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestIssue4689(t *testing.T) {
|
||||||
|
stignore := `// orig`
|
||||||
|
|
||||||
|
pats := New(fs.NewFilesystem(fs.FilesystemTypeBasic, "."), WithCache(true))
|
||||||
|
err := pats.Parse(bytes.NewBufferString(stignore), ".stignore")
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
if lines := pats.Lines(); len(lines) != 1 || lines[0] != "// orig" {
|
||||||
|
t.Fatalf("wrong lines parsing original comment:\n%q", lines)
|
||||||
|
}
|
||||||
|
|
||||||
|
stignore = `// new`
|
||||||
|
|
||||||
|
err = pats.Parse(bytes.NewBufferString(stignore), ".stignore")
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
if lines := pats.Lines(); len(lines) != 1 || lines[0] != "// new" {
|
||||||
|
t.Fatalf("wrong lines parsing changed comment:\n%v", lines)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user