File: api.go

package info (click to toggle)
kitty 0.45.0-2
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 27,476 kB
  • sloc: ansic: 84,285; python: 57,992; objc: 5,432; sh: 1,333; xml: 364; makefile: 144; javascript: 78
file content (32 lines) | stat: -rw-r--r-- 904 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
package ignorefiles

import (
	"fmt"
	"io"
	"io/fs"
	"sync"
)

var _ = fmt.Print

type IgnoreFile interface {
	Len() int // number of rules
	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 the result is due to a rule matching, linenum_of_matching_rule is
	// >=0 and pattern is the textual representation of the rule. Otherwise
	// linenum_of_matching_rule is -1 and pattern is the empty string.
	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} }

// The global gitignore from ~/.config/git/ignore
var GlobalGitignore = sync.OnceValue(func() IgnoreFile {
	return get_global_gitignore()
})