Documentation ¶
Index ¶
- Variables
- type Attribute
- type MatchAttribute
- func LoadGlobalPatterns(fs billy.Filesystem) (attributes []MatchAttribute, err error)
- func LoadSystemPatterns(fs billy.Filesystem) (attributes []MatchAttribute, err error)
- func ParseAttributesLine(line string, domain []string, allowMacro bool) (m MatchAttribute, err error)
- func ReadAttributes(r io.Reader, domain []string, allowMacro bool) (attributes []MatchAttribute, err error)
- func ReadAttributesFile(fs billy.Filesystem, path []string, attributesFile string, allowMacro bool) ([]MatchAttribute, error)
- func ReadPatterns(fs billy.Filesystem, path []string) (attributes []MatchAttribute, err error)
- type Matcher
- type MatcherOptions
- type Pattern
Constants ¶
This section is empty.
Variables ¶
var ( ErrMacroNotAllowed = errors.New("macro not allowed") ErrInvalidAttributeName = errors.New("Invalid attribute name") )
Functions ¶
This section is empty.
Types ¶
type MatchAttribute ¶
func LoadGlobalPatterns ¶
func LoadGlobalPatterns(fs billy.Filesystem) (attributes []MatchAttribute, err error)
LoadGlobalPatterns loads gitattributes patterns and attributes from the gitattributes file declared in a user's ~/.gitconfig file. If the ~/.gitconfig file does not exist the function will return nil. If the core.attributesFile property is not declared, the function will return nil. If the file pointed to by the core.attributesfile property does not exist, the function will return nil. The function assumes fs is rooted at the root filesystem.
func LoadSystemPatterns ¶
func LoadSystemPatterns(fs billy.Filesystem) (attributes []MatchAttribute, err error)
LoadSystemPatterns loads gitattributes patterns and attributes from the gitattributes file declared in a system's /etc/gitconfig file. If the /etc/gitconfig file does not exist the function will return nil. If the core.attributesfile property is not declared, the function will return nil. If the file pointed to by the core.attributesfile property does not exist, the function will return nil. The function assumes fs is rooted at the root filesystem.
func ParseAttributesLine ¶
func ParseAttributesLine(line string, domain []string, allowMacro bool) (m MatchAttribute, err error)
ParseAttributesLine parses a gitattribute line, extracting path pattern and attributes.
func ReadAttributes ¶
func ReadAttributes(r io.Reader, domain []string, allowMacro bool) (attributes []MatchAttribute, err error)
ReadAttributes reads patterns and attributes from the gitattributes format.
func ReadAttributesFile ¶
func ReadAttributesFile(fs billy.Filesystem, path []string, attributesFile string, allowMacro bool) ([]MatchAttribute, error)
func ReadPatterns ¶
func ReadPatterns(fs billy.Filesystem, path []string) (attributes []MatchAttribute, err error)
ReadPatterns reads gitattributes patterns recursively through the directory structure. The result is in ascending order of priority (last higher).
The .gitattribute file in the root directory will allow custom macro definitions. Custom macro definitions in other directories .gitattributes will return an error.
type Matcher ¶
type Matcher interface { // Match matches patterns in the order of priorities. Match(path []string, attributes []string) (map[string]Attribute, bool) }
Matcher defines a global multi-pattern matcher for gitattributes patterns
func NewMatcher ¶
func NewMatcher(stack []MatchAttribute) Matcher
NewMatcher constructs a new matcher. Patterns must be given in the order of increasing priority. That is the most generic settings files first, then the content of the repo .gitattributes, then content of .gitattributes down the path.
type MatcherOptions ¶
type MatcherOptions struct{}