go-git.v4: gopkg.in/src-d/go-git.v4/plumbing/format/gitattributes Index | Files

package gitattributes

import "gopkg.in/src-d/go-git.v4/plumbing/format/gitattributes"

Index

Package Files

attributes.go dir.go matcher.go pattern.go

Variables

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

type Attribute Uses

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

type MatchAttribute Uses

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

func LoadGlobalPatterns Uses

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 Uses

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 Uses

func ParseAttributesLine(line string, domain []string, allowMacro bool) (m MatchAttribute, err error)

ParseAttributesLine parses a gitattribute line, extracting path pattern and attributes.

func ReadAttributes Uses

func ReadAttributes(r io.Reader, domain []string, allowMacro bool) (attributes []MatchAttribute, err error)

ReadAttributes reads patterns and attributes from the gitattributes format.

func ReadAttributesFile Uses

func ReadAttributesFile(fs billy.Filesystem, path []string, attributesFile string, allowMacro bool) ([]MatchAttribute, error)

func ReadPatterns Uses

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 Uses

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 Uses

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 Uses

type MatcherOptions struct{}

type Pattern Uses

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

Pattern defines a gitattributes pattern.

func ParsePattern Uses

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

ParsePattern parses a gitattributes pattern string into the Pattern structure.

Package gitattributes imports 10 packages (graph). Updated 2019-08-01. Refresh now. Tools for package owners.