lstree

package
v14.7.0-rc42 Latest Latest
Warning

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

Go to latest
Published: Jan 20, 2022 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrNotExist indicates that the requested tree does not exist, either because the revision
	// is invalid or because the path is not valid.
	ErrNotExist = errors.New("invalid object name")
	// ErrNotTreeish indicates that the requested revision or path does not resolve to a tree
	// object.
	ErrNotTreeish = errors.New("not treeish")
)
View Source
var ErrParse = errors.New("failed to parse git ls-tree response")

ErrParse is returned when the parse of an entry was unsuccessful

Functions

This section is empty.

Types

type Entries

type Entries []Entry

Entries holds every ls-tree Entry

func (Entries) Len

func (e Entries) Len() int

func (Entries) Less

func (e Entries) Less(i, j int) bool

Less sorts entries by type in the order [*tree *blobs *submodules]

func (Entries) Swap

func (e Entries) Swap(i, j int)

type Entry

type Entry struct {
	Mode     []byte
	Type     ObjectType
	ObjectID git.ObjectID
	Path     string
}

Entry represents a single ls-tree entry

func ListEntries added in v14.5.0

func ListEntries(
	ctx context.Context,
	repo *localrepo.Repo,
	treeish git.Revision,
	cfg *ListEntriesConfig,
) ([]*Entry, error)

ListEntries lists tree entries for the given treeish. By default, this will do a non-recursive listing starting from the root of the given treeish. This behaviour can be changed by passing a config.

type ListEntriesConfig added in v14.5.0

type ListEntriesConfig struct {
	// Recursive indicates whether the listing shall be recursive or not.
	Recursive bool
	// RelativePath is the relative path at which listing of entries should be started.
	RelativePath string
}

ListEntriesConfig is configuration that can be passed to ListEntries.

type ObjectType

type ObjectType int

ObjectType is an Enum for the type of object of the ls-tree entry, which can be can be tree, blob or commit

const (
	Tree ObjectType = iota
	Blob
	Submodule
)

Enum values for ObjectType

type Parser

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

Parser holds the necessary state for parsing the ls-tree output

func NewParser

func NewParser(src io.Reader) *Parser

NewParser returns a new Parser

func (*Parser) NextEntry

func (p *Parser) NextEntry() (*Entry, error)

NextEntry reads a tree entry as it would be written by `git ls-tree -z`.

Jump to

Keyboard shortcuts

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