Finish up gitignore implementation

This commit is contained in:
Kovid Goyal
2025-07-08 12:03:58 +05:30
parent 4383398f25
commit c346735c74
3 changed files with 160 additions and 7 deletions

25
tools/ignorefiles/api.go Normal file
View File

@@ -0,0 +1,25 @@
package ignorefiles
import (
"fmt"
"io"
"io/fs"
)
var _ = fmt.Print
type IgnoreFile interface {
LoadString(string) error
LoadBytes([]byte) error
LoadLines(...string) error
LoadFile(io.Reader) error
LoadPath(string) error
// relpath is the path relative to the directory containing the ignorefile.
// When is_ignored is true, linenum_of_matching_rule will be the line
// number of the rule causing relpath to be ignored and pattern is the
// textual representation of the matching pattern.
IsIgnored(relpath string, ftype fs.FileMode) (is_ignored bool, linenum_of_matching_rule int, pattern string)
}
func NewGitignore() IgnoreFile { return &Gitignore{index_of_last_negated_rule: -1} }