Ensure global gitignore file is not loaded in tests

This commit is contained in:
Kovid Goyal
2025-07-09 14:31:46 +05:30
parent fd20fd23bb
commit f742009c55
4 changed files with 20 additions and 4 deletions

View File

@@ -10,6 +10,7 @@ import (
var _ = fmt.Print
type IgnoreFile interface {
Len() int // number of rules
LoadString(string) error
LoadBytes([]byte) error
LoadLines(...string) error

View File

@@ -29,6 +29,8 @@ type Gitignore struct {
line_number_offset int
}
func (g Gitignore) Len() int { return len(g.patterns) }
func (g Gitignore) IsIgnored(relpath string, ftype os.FileMode) (is_ignored bool, linenum_of_matching_rule int, pattern string) {
if os.PathSeparator != '/' {
relpath = strings.ReplaceAll(relpath, string(os.PathSeparator), "/")