gitattributes

package
v5.4.4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 22, 2021 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrMacroNotAllowed      = errors.New("macro not allowed")
	ErrInvalidAttributeName = errors.New("Invalid attribute name")
)

Functions

This section is empty.

Types

type Attribute

type Attribute interface {
	Name() string
	IsSet() bool
	IsUnset() bool
	IsUnspecified() bool
	IsValueSet() bool
	Value() string
	String() string
}

type MatchAttribute

type MatchAttribute struct {
	Name       string
	Pattern    Pattern
	Attributes []Attribute
}

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{}

type Pattern

type Pattern interface {
	// Match matches the given path to the pattern.
	Match(path []string) bool
}

Pattern defines a gitattributes pattern.

func ParsePattern

func ParsePattern(p string, domain []string) Pattern

ParsePattern parses a gitattributes pattern string into the Pattern structure.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL