simplify del/reset commands by using readWriteTruncater interface.

remove the type assertions

update the tests:
the tests now check output as well as file contents separately.
This commit is contained in:
2026-04-07 01:22:56 +01:00
parent c2eab8576e
commit a149ce347b
7 changed files with 86 additions and 89 deletions

View File

@@ -7,6 +7,13 @@ import (
"strings"
)
// readWriteTruncater is the interface satisfied by *os.File that allows
// reading, writing, seeking, and truncating — the operations needed to rewrite the exclude file.
type readWriteTruncater interface {
io.ReadWriteSeeker
Truncate(size int64) error
}
// readExistingPatterns reads the existing patterns from the exclude file, ignoring comments and empty lines
func readExistingPatterns(f io.Reader) ([]string, error) {
var patterns []string