gitattr

package
v3.5.1 Latest Latest
Warning

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

Go to latest
Published: Mar 7, 2024 License: BSD-3-Clause, MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Attr

type Attr struct {
	// K is the name of the attribute. It is commonly, "filter", "diff",
	// "merge", or "text".
	//
	// It will never contain the special "false" shorthand ("-"), or the
	// unspecify declarative ("!").
	K string
	// V is the value held by that attribute. It is commonly "lfs", or
	// "false", indicating the special value given by a "-"-prefixed name.
	V string
	// Unspecified indicates whether or not this attribute was explicitly
	// unset by prefixing the keyname with "!".
	Unspecified bool
}

Attr is a single attribute that may be applied to a file.

type Line

type Line interface {
	Attrs() []*Attr
}

func ParseLines

func ParseLines(r io.Reader) ([]Line, string, error)

ParseLines parses the given io.Reader "r" line-wise as if it were the contents of a .gitattributes file.

If an error was encountered, it will be returned and the []*Line should be considered unusable.

type MacroLine added in v3.4.0

type MacroLine interface {
	Macro() string
	Line
}

type MacroProcessor

type MacroProcessor struct {
	// contains filtered or unexported fields
}

func NewMacroProcessor

func NewMacroProcessor() *MacroProcessor

NewMacroProcessor returns a new MacroProcessor object for parsing macros.

func (*MacroProcessor) ProcessLines

func (mp *MacroProcessor) ProcessLines(lines []Line, readMacros bool) []PatternLine

ProcessLines reads the specified lines, returning a new set of lines which all have a valid pattern. If readMacros is true, it additionally loads any macro lines as it reads them.

type PatternLine added in v3.4.0

type PatternLine interface {
	Pattern() *wildmatch.Wildmatch
	Line
}

type Tree

type Tree struct {
	// Lines are the lines of the .gitattributes at this level of the tree.
	Lines []Line
	// Children are the named child directories in the repository.
	Children map[string]*Tree
}

Tree represents the .gitattributes file at one layer of the tree in a Git repository.

func New

func New(db *gitobj.ObjectDatabase, t *gitobj.Tree) (*Tree, error)

New constructs a *Tree starting at the given tree "t" and reading objects from the given ObjectDatabase. If a tree was not able to be read, an error will be propagated up accordingly.

func (*Tree) Applied

func (t *Tree) Applied(to string) []*Attr

Applied returns a slice of attributes applied to the given path, relative to the receiving tree. It traverse through sub-trees in a topological ordering, if there are relevant .gitattributes matching that path.

Jump to

Keyboard shortcuts

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