go-git.v4: gopkg.in/src-d/go-git.v4/plumbing/object Index | Files | Directories

package object

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

Package object contains implementations of all Git objects and utility functions to work with them.

Index

Package Files

blob.go change.go change_adaptor.go commit.go commit_walker.go commit_walker_bfs.go commit_walker_bfs_filtered.go commit_walker_ctime.go commit_walker_file.go common.go difftree.go file.go merge_base.go object.go patch.go tag.go tree.go treenoder.go

Constants

const DateFormat = "Mon Jan 02 15:04:05 2006 -0700"

DateFormat is the format being used in the original git implementation

Variables

var (
    ErrMaxTreeDepth      = errors.New("maximum tree depth exceeded")
    ErrFileNotFound      = errors.New("file not found")
    ErrDirectoryNotFound = errors.New("directory not found")
    ErrEntryNotFound     = errors.New("entry not found")
)

New errors defined by this package.

var (
    ErrCanceled = errors.New("operation canceled")
)
var ErrParentNotFound = errors.New("commit parent not found")
var ErrUnsupportedObject = errors.New("unsupported object type")

ErrUnsupportedObject trigger when a non-supported object is being decoded.

func NewTreeRootNode Uses

func NewTreeRootNode(t *Tree) noder.Noder

NewTreeRootNode returns the root node of a Tree

type Blob Uses

type Blob struct {
    // Hash of the blob.
    Hash plumbing.Hash
    // Size of the (uncompressed) blob.
    Size int64
    // contains filtered or unexported fields
}

Blob is used to store arbitrary data - it is generally a file.

func DecodeBlob Uses

func DecodeBlob(o plumbing.EncodedObject) (*Blob, error)

DecodeObject decodes an encoded object into a *Blob.

func GetBlob Uses

func GetBlob(s storer.EncodedObjectStorer, h plumbing.Hash) (*Blob, error)

GetBlob gets a blob from an object storer and decodes it.

func (*Blob) Decode Uses

func (b *Blob) Decode(o plumbing.EncodedObject) error

Decode transforms a plumbing.EncodedObject into a Blob struct.

func (*Blob) Encode Uses

func (b *Blob) Encode(o plumbing.EncodedObject) (err error)

Encode transforms a Blob into a plumbing.EncodedObject.

func (*Blob) ID Uses

func (b *Blob) ID() plumbing.Hash

ID returns the object ID of the blob. The returned value will always match the current value of Blob.Hash.

ID is present to fulfill the Object interface.

func (*Blob) Reader Uses

func (b *Blob) Reader() (io.ReadCloser, error)

Reader returns a reader allow the access to the content of the blob

func (*Blob) Type Uses

func (b *Blob) Type() plumbing.ObjectType

Type returns the type of object. It always returns plumbing.BlobObject.

Type is present to fulfill the Object interface.

type BlobIter Uses

type BlobIter struct {
    storer.EncodedObjectIter
    // contains filtered or unexported fields
}

BlobIter provides an iterator for a set of blobs.

func NewBlobIter Uses

func NewBlobIter(s storer.EncodedObjectStorer, iter storer.EncodedObjectIter) *BlobIter

NewBlobIter takes a storer.EncodedObjectStorer and a storer.EncodedObjectIter and returns a *BlobIter that iterates over all blobs contained in the storer.EncodedObjectIter.

Any non-blob object returned by the storer.EncodedObjectIter is skipped.

func (*BlobIter) ForEach Uses

func (iter *BlobIter) ForEach(cb func(*Blob) error) error

ForEach call the cb function for each blob contained on this iter until an error happens or the end of the iter is reached. If ErrStop is sent the iteration is stop but no error is returned. The iterator is closed.

func (*BlobIter) Next Uses

func (iter *BlobIter) Next() (*Blob, error)

Next moves the iterator to the next blob and returns a pointer to it. If there are no more blobs, it returns io.EOF.

type Change Uses

type Change struct {
    From ChangeEntry
    To   ChangeEntry
}

Change values represent a detected change between two git trees. For modifications, From is the original status of the node and To is its final status. For insertions, From is the zero value and for deletions To is the zero value.

func (*Change) Action Uses

func (c *Change) Action() (merkletrie.Action, error)

Action returns the kind of action represented by the change, an insertion, a deletion or a modification.

func (*Change) Files Uses

func (c *Change) Files() (from, to *File, err error)

Files return the files before and after a change. For insertions from will be nil. For deletions to will be nil.

func (*Change) Patch Uses

func (c *Change) Patch() (*Patch, error)

Patch returns a Patch with all the file changes in chunks. This representation can be used to create several diff outputs.

func (*Change) PatchContext Uses

func (c *Change) PatchContext(ctx context.Context) (*Patch, error)

Patch returns a Patch with all the file changes in chunks. This representation can be used to create several diff outputs. If context expires, an non-nil error will be returned Provided context must be non-nil

func (*Change) String Uses

func (c *Change) String() string

type ChangeEntry Uses

type ChangeEntry struct {
    // Full path of the node using "/" as separator.
    Name string
    // Parent tree of the node that has changed.
    Tree *Tree
    // The entry of the node.
    TreeEntry TreeEntry
}

ChangeEntry values represent a node that has suffered a change.

type Changes Uses

type Changes []*Change

Changes represents a collection of changes between two git trees. Implements sort.Interface lexicographically over the path of the changed files.

func DiffTree Uses

func DiffTree(a, b *Tree) (Changes, error)

DiffTree compares the content and mode of the blobs found via two tree objects.

func DiffTreeContext Uses

func DiffTreeContext(ctx context.Context, a, b *Tree) (Changes, error)

DiffTree compares the content and mode of the blobs found via two tree objects. Provided context must be non-nil. An error will be return if context expires

func (Changes) Len Uses

func (c Changes) Len() int

func (Changes) Less Uses

func (c Changes) Less(i, j int) bool

func (Changes) Patch Uses

func (c Changes) Patch() (*Patch, error)

Patch returns a Patch with all the changes in chunks. This representation can be used to create several diff outputs.

func (Changes) PatchContext Uses

func (c Changes) PatchContext(ctx context.Context) (*Patch, error)

Patch returns a Patch with all the changes in chunks. This representation can be used to create several diff outputs. If context expires, an non-nil error will be returned Provided context must be non-nil

func (Changes) String Uses

func (c Changes) String() string

func (Changes) Swap Uses

func (c Changes) Swap(i, j int)

type Commit Uses

type Commit struct {
    // Hash of the commit object.
    Hash plumbing.Hash
    // Author is the original author of the commit.
    Author Signature
    // Committer is the one performing the commit, might be different from
    // Author.
    Committer Signature
    // PGPSignature is the PGP signature of the commit.
    PGPSignature string
    // Message is the commit message, contains arbitrary text.
    Message string
    // TreeHash is the hash of the root tree of the commit.
    TreeHash plumbing.Hash
    // ParentHashes are the hashes of the parent commits of the commit.
    ParentHashes []plumbing.Hash
    // contains filtered or unexported fields
}

Commit points to a single tree, marking it as what the project looked like at a certain point in time. It contains meta-information about that point in time, such as a timestamp, the author of the changes since the last commit, a pointer to the previous commit(s), etc. http://shafiulazam.com/gitbook/1_the_git_object_model.html

func DecodeCommit Uses

func DecodeCommit(s storer.EncodedObjectStorer, o plumbing.EncodedObject) (*Commit, error)

DecodeCommit decodes an encoded object into a *Commit and associates it to the given object storer.

func GetCommit Uses

func GetCommit(s storer.EncodedObjectStorer, h plumbing.Hash) (*Commit, error)

GetCommit gets a commit from an object storer and decodes it.

func Independents Uses

func Independents(commits []*Commit) ([]*Commit, error)

Independents returns a subset of the passed commits, that are not reachable the others It mimics the behavior of `git merge-base --independent commit...`.

func (*Commit) Decode Uses

func (c *Commit) Decode(o plumbing.EncodedObject) (err error)

Decode transforms a plumbing.EncodedObject into a Commit struct.

func (*Commit) Encode Uses

func (b *Commit) Encode(o plumbing.EncodedObject) error

Encode transforms a Commit into a plumbing.EncodedObject.

func (*Commit) EncodeWithoutSignature Uses

func (b *Commit) EncodeWithoutSignature(o plumbing.EncodedObject) error

EncodeWithoutSignature export a Commit into a plumbing.EncodedObject without the signature (correspond to the payload of the PGP signature).

func (*Commit) File Uses

func (c *Commit) File(path string) (*File, error)

File returns the file with the specified "path" in the commit and a nil error if the file exists. If the file does not exist, it returns a nil file and the ErrFileNotFound error.

func (*Commit) Files Uses

func (c *Commit) Files() (*FileIter, error)

Files returns a FileIter allowing to iterate over the Tree

func (*Commit) ID Uses

func (c *Commit) ID() plumbing.Hash

ID returns the object ID of the commit. The returned value will always match the current value of Commit.Hash.

ID is present to fulfill the Object interface.

func (*Commit) IsAncestor Uses

func (c *Commit) IsAncestor(other *Commit) (bool, error)

IsAncestor returns true if the actual commit is ancestor of the passed one. It returns an error if the history is not transversable It mimics the behavior of `git merge --is-ancestor actual other`

func (*Commit) MergeBase Uses

func (c *Commit) MergeBase(other *Commit) ([]*Commit, error)

MergeBase mimics the behavior of `git merge-base actual other`, returning the best common ancestor between the actual and the passed one. The best common ancestors can not be reached from other common ancestors.

func (*Commit) NumParents Uses

func (c *Commit) NumParents() int

NumParents returns the number of parents in a commit.

func (*Commit) Parent Uses

func (c *Commit) Parent(i int) (*Commit, error)

Parent returns the ith parent of a commit.

func (*Commit) Parents Uses

func (c *Commit) Parents() CommitIter

Parents return a CommitIter to the parent Commits.

func (*Commit) Patch Uses

func (c *Commit) Patch(to *Commit) (*Patch, error)

Patch returns the Patch between the actual commit and the provided one.

func (*Commit) PatchContext Uses

func (c *Commit) PatchContext(ctx context.Context, to *Commit) (*Patch, error)

PatchContext returns the Patch between the actual commit and the provided one. Error will be return if context expires. Provided context must be non-nil.

func (*Commit) Stats Uses

func (c *Commit) Stats() (FileStats, error)

Stats returns the stats of a commit.

func (*Commit) StatsContext Uses

func (c *Commit) StatsContext(ctx context.Context) (FileStats, error)

StatsContext returns the stats of a commit. Error will be return if context expires. Provided context must be non-nil.

func (*Commit) String Uses

func (c *Commit) String() string

func (*Commit) Tree Uses

func (c *Commit) Tree() (*Tree, error)

Tree returns the Tree from the commit.

func (*Commit) Type Uses

func (c *Commit) Type() plumbing.ObjectType

Type returns the type of object. It always returns plumbing.CommitObject.

Type is present to fulfill the Object interface.

func (*Commit) Verify Uses

func (c *Commit) Verify(armoredKeyRing string) (*openpgp.Entity, error)

Verify performs PGP verification of the commit with a provided armored keyring and returns openpgp.Entity associated with verifying key on success.

type CommitFilter Uses

type CommitFilter func(*Commit) bool

CommitFilter returns a boolean for the passed Commit

type CommitIter Uses

type CommitIter interface {
    Next() (*Commit, error)
    ForEach(func(*Commit) error) error
    Close()
}

CommitIter is a generic closable interface for iterating over commits.

func NewCommitAllIter Uses

func NewCommitAllIter(repoStorer storage.Storer, commitIterFunc func(*Commit) CommitIter) (CommitIter, error)

NewCommitAllIter returns a new commit iterator for all refs. repoStorer is a repo Storer used to get commits and references. commitIterFunc is a commit iterator function, used to iterate through ref commits in chosen order

func NewCommitFileIterFromIter Uses

func NewCommitFileIterFromIter(fileName string, commitIter CommitIter, checkParent bool) CommitIter

NewCommitFileIterFromIter returns a commit iterator which performs diffTree between successive trees returned from the commit iterator from the argument. The purpose of this is to find the commits that explain how the files that match the path came to be. If checkParent is true then the function double checks if potential parent (next commit in a path) is one of the parents in the tree (it's used by `git log --all`).

func NewCommitIter Uses

func NewCommitIter(s storer.EncodedObjectStorer, iter storer.EncodedObjectIter) CommitIter

NewCommitIter takes a storer.EncodedObjectStorer and a storer.EncodedObjectIter and returns a CommitIter that iterates over all commits contained in the storer.EncodedObjectIter.

Any non-commit object returned by the storer.EncodedObjectIter is skipped.

func NewCommitIterBSF Uses

func NewCommitIterBSF(
    c *Commit,
    seenExternal map[plumbing.Hash]bool,
    ignore []plumbing.Hash,
) CommitIter

NewCommitIterBSF returns a CommitIter that walks the commit history, starting at the given commit and visiting its parents in pre-order. The given callback will be called for each visited commit. Each commit will be visited only once. If the callback returns an error, walking will stop and will return the error. Other errors might be returned if the history cannot be traversed (e.g. missing objects). Ignore allows to skip some commits from being iterated.

func NewCommitIterCTime Uses

func NewCommitIterCTime(
    c *Commit,
    seenExternal map[plumbing.Hash]bool,
    ignore []plumbing.Hash,
) CommitIter

NewCommitIterCTime returns a CommitIter that walks the commit history, starting at the given commit and visiting its parents while preserving Committer Time order. this appears to be the closest order to `git log` The given callback will be called for each visited commit. Each commit will be visited only once. If the callback returns an error, walking will stop and will return the error. Other errors might be returned if the history cannot be traversed (e.g. missing objects). Ignore allows to skip some commits from being iterated.

func NewCommitPostorderIter Uses

func NewCommitPostorderIter(c *Commit, ignore []plumbing.Hash) CommitIter

NewCommitPostorderIter returns a CommitIter that walks the commit history like WalkCommitHistory but in post-order. This means that after walking a merge commit, the merged commit will be walked before the base it was merged on. This can be useful if you wish to see the history in chronological order. Ignore allows to skip some commits from being iterated.

func NewCommitPreorderIter Uses

func NewCommitPreorderIter(
    c *Commit,
    seenExternal map[plumbing.Hash]bool,
    ignore []plumbing.Hash,
) CommitIter

NewCommitPreorderIter returns a CommitIter that walks the commit history, starting at the given commit and visiting its parents in pre-order. The given callback will be called for each visited commit. Each commit will be visited only once. If the callback returns an error, walking will stop and will return the error. Other errors might be returned if the history cannot be traversed (e.g. missing objects). Ignore allows to skip some commits from being iterated.

func NewFilterCommitIter Uses

func NewFilterCommitIter(
    from *Commit,
    isValid *CommitFilter,
    isLimit *CommitFilter,
) CommitIter

NewFilterCommitIter returns a CommitIter that walks the commit history, starting at the passed commit and visiting its parents in Breadth-first order. The commits returned by the CommitIter will validate the passed CommitFilter. The history won't be transversed beyond a commit if isLimit is true for it. Each commit will be visited only once. If the commit history can not be traversed, or the Close() method is called, the CommitIter won't return more commits. If no isValid is passed, all ancestors of from commit will be valid. If no isLimit is limmit, all ancestors of all commits will be visited.

type File Uses

type File struct {
    // Name is the path of the file. It might be relative to a tree,
    // depending of the function that generates it.
    Name string
    // Mode is the file mode.
    Mode filemode.FileMode
    // Blob with the contents of the file.
    Blob
}

File represents git file objects.

func NewFile Uses

func NewFile(name string, m filemode.FileMode, b *Blob) *File

NewFile returns a File based on the given blob object

func (*File) Contents Uses

func (f *File) Contents() (content string, err error)

Contents returns the contents of a file as a string.

func (*File) IsBinary Uses

func (f *File) IsBinary() (bin bool, err error)

IsBinary returns if the file is binary or not

func (*File) Lines Uses

func (f *File) Lines() ([]string, error)

Lines returns a slice of lines from the contents of a file, stripping all end of line characters. If the last line is empty (does not end in an end of line), it is also stripped.

type FileIter Uses

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

FileIter provides an iterator for the files in a tree.

func NewFileIter Uses

func NewFileIter(s storer.EncodedObjectStorer, t *Tree) *FileIter

NewFileIter takes a storer.EncodedObjectStorer and a Tree and returns a *FileIter that iterates over all files contained in the tree, recursively.

func (*FileIter) Close Uses

func (iter *FileIter) Close()

func (*FileIter) ForEach Uses

func (iter *FileIter) ForEach(cb func(*File) error) error

ForEach call the cb function for each file contained in this iter until an error happens or the end of the iter is reached. If plumbing.ErrStop is sent the iteration is stop but no error is returned. The iterator is closed.

func (*FileIter) Next Uses

func (iter *FileIter) Next() (*File, error)

Next moves the iterator to the next file and returns a pointer to it. If there are no more files, it returns io.EOF.

type FileStat Uses

type FileStat struct {
    Name     string
    Addition int
    Deletion int
}

FileStat stores the status of changes in content of a file.

func (FileStat) String Uses

func (fs FileStat) String() string

type FileStats Uses

type FileStats []FileStat

FileStats is a collection of FileStat.

func (FileStats) String Uses

func (fileStats FileStats) String() string

type Hash Uses

type Hash plumbing.Hash

Hash represents the hash of an object

type Object Uses

type Object interface {
    ID() plumbing.Hash
    Type() plumbing.ObjectType
    Decode(plumbing.EncodedObject) error
    Encode(plumbing.EncodedObject) error
}

Object is a generic representation of any git object. It is implemented by Commit, Tree, Blob, and Tag, and includes the functions that are common to them.

Object is returned when an object can be of any type. It is frequently used with a type cast to acquire the specific type of object:

func process(obj Object) {
	switch o := obj.(type) {
	case *Commit:
		// o is a Commit
	case *Tree:
		// o is a Tree
	case *Blob:
		// o is a Blob
	case *Tag:
		// o is a Tag
	}
}

This interface is intentionally different from plumbing.EncodedObject, which is a lower level interface used by storage implementations to read and write objects in its encoded form.

func DecodeObject Uses

func DecodeObject(s storer.EncodedObjectStorer, o plumbing.EncodedObject) (Object, error)

DecodeObject decodes an encoded object into an Object and associates it to the given object storer.

func GetObject Uses

func GetObject(s storer.EncodedObjectStorer, h plumbing.Hash) (Object, error)

GetObject gets an object from an object storer and decodes it.

type ObjectIter Uses

type ObjectIter struct {
    storer.EncodedObjectIter
    // contains filtered or unexported fields
}

ObjectIter provides an iterator for a set of objects.

func NewObjectIter Uses

func NewObjectIter(s storer.EncodedObjectStorer, iter storer.EncodedObjectIter) *ObjectIter

NewObjectIter takes a storer.EncodedObjectStorer and a storer.EncodedObjectIter and returns an *ObjectIter that iterates over all objects contained in the storer.EncodedObjectIter.

func (*ObjectIter) ForEach Uses

func (iter *ObjectIter) ForEach(cb func(Object) error) error

ForEach call the cb function for each object contained on this iter until an error happens or the end of the iter is reached. If ErrStop is sent the iteration is stop but no error is returned. The iterator is closed.

func (*ObjectIter) Next Uses

func (iter *ObjectIter) Next() (Object, error)

Next moves the iterator to the next object and returns a pointer to it. If there are no more objects, it returns io.EOF.

type Patch Uses

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

textPatch is an implementation of fdiff.Patch interface

func (*Patch) Encode Uses

func (p *Patch) Encode(w io.Writer) error

func (*Patch) FilePatches Uses

func (t *Patch) FilePatches() []fdiff.FilePatch

func (*Patch) Message Uses

func (t *Patch) Message() string

func (*Patch) Stats Uses

func (p *Patch) Stats() FileStats

func (*Patch) String Uses

func (p *Patch) String() string

type Signature Uses

type Signature struct {
    // Name represents a person name. It is an arbitrary string.
    Name string
    // Email is an email, but it cannot be assumed to be well-formed.
    Email string
    // When is the timestamp of the signature.
    When time.Time
}

Signature is used to identify who and when created a commit or tag.

func (*Signature) Decode Uses

func (s *Signature) Decode(b []byte)

Decode decodes a byte slice into a signature

func (*Signature) Encode Uses

func (s *Signature) Encode(w io.Writer) error

Encode encodes a Signature into a writer.

func (*Signature) String Uses

func (s *Signature) String() string

type Tag Uses

type Tag struct {
    // Hash of the tag.
    Hash plumbing.Hash
    // Name of the tag.
    Name string
    // Tagger is the one who created the tag.
    Tagger Signature
    // Message is an arbitrary text message.
    Message string
    // PGPSignature is the PGP signature of the tag.
    PGPSignature string
    // TargetType is the object type of the target.
    TargetType plumbing.ObjectType
    // Target is the hash of the target object.
    Target plumbing.Hash
    // contains filtered or unexported fields
}

Tag represents an annotated tag object. It points to a single git object of any type, but tags typically are applied to commit or blob objects. It provides a reference that associates the target with a tag name. It also contains meta-information about the tag, including the tagger, tag date and message.

Note that this is not used for lightweight tags.

https://git-scm.com/book/en/v2/Git-Internals-Git-References#Tags

func DecodeTag Uses

func DecodeTag(s storer.EncodedObjectStorer, o plumbing.EncodedObject) (*Tag, error)

DecodeTag decodes an encoded object into a *Commit and associates it to the given object storer.

func GetTag Uses

func GetTag(s storer.EncodedObjectStorer, h plumbing.Hash) (*Tag, error)

GetTag gets a tag from an object storer and decodes it.

func (*Tag) Blob Uses

func (t *Tag) Blob() (*Blob, error)

Blob returns the blob pointed to by the tag. If the tag points to a different type of object ErrUnsupportedObject will be returned.

func (*Tag) Commit Uses

func (t *Tag) Commit() (*Commit, error)

Commit returns the commit pointed to by the tag. If the tag points to a different type of object ErrUnsupportedObject will be returned.

func (*Tag) Decode Uses

func (t *Tag) Decode(o plumbing.EncodedObject) (err error)

Decode transforms a plumbing.EncodedObject into a Tag struct.

func (*Tag) Encode Uses

func (t *Tag) Encode(o plumbing.EncodedObject) error

Encode transforms a Tag into a plumbing.EncodedObject.

func (*Tag) EncodeWithoutSignature Uses

func (t *Tag) EncodeWithoutSignature(o plumbing.EncodedObject) error

EncodeWithoutSignature export a Tag into a plumbing.EncodedObject without the signature (correspond to the payload of the PGP signature).

func (*Tag) ID Uses

func (t *Tag) ID() plumbing.Hash

ID returns the object ID of the tag, not the object that the tag references. The returned value will always match the current value of Tag.Hash.

ID is present to fulfill the Object interface.

func (*Tag) Object Uses

func (t *Tag) Object() (Object, error)

Object returns the object pointed to by the tag.

func (*Tag) String Uses

func (t *Tag) String() string

String returns the meta information contained in the tag as a formatted string.

func (*Tag) Tree Uses

func (t *Tag) Tree() (*Tree, error)

Tree returns the tree pointed to by the tag. If the tag points to a commit object the tree of that commit will be returned. If the tag does not point to a commit or tree object ErrUnsupportedObject will be returned.

func (*Tag) Type Uses

func (t *Tag) Type() plumbing.ObjectType

Type returns the type of object. It always returns plumbing.TagObject.

Type is present to fulfill the Object interface.

func (*Tag) Verify Uses

func (t *Tag) Verify(armoredKeyRing string) (*openpgp.Entity, error)

Verify performs PGP verification of the tag with a provided armored keyring and returns openpgp.Entity associated with verifying key on success.

type TagIter Uses

type TagIter struct {
    storer.EncodedObjectIter
    // contains filtered or unexported fields
}

TagIter provides an iterator for a set of tags.

func NewTagIter Uses

func NewTagIter(s storer.EncodedObjectStorer, iter storer.EncodedObjectIter) *TagIter

NewTagIter takes a storer.EncodedObjectStorer and a storer.EncodedObjectIter and returns a *TagIter that iterates over all tags contained in the storer.EncodedObjectIter.

Any non-tag object returned by the storer.EncodedObjectIter is skipped.

func (*TagIter) ForEach Uses

func (iter *TagIter) ForEach(cb func(*Tag) error) error

ForEach call the cb function for each tag contained on this iter until an error happens or the end of the iter is reached. If ErrStop is sent the iteration is stop but no error is returned. The iterator is closed.

func (*TagIter) Next Uses

func (iter *TagIter) Next() (*Tag, error)

Next moves the iterator to the next tag and returns a pointer to it. If there are no more tags, it returns io.EOF.

type Tree Uses

type Tree struct {
    Entries []TreeEntry
    Hash    plumbing.Hash
    // contains filtered or unexported fields
}

Tree is basically like a directory - it references a bunch of other trees and/or blobs (i.e. files and sub-directories)

func DecodeTree Uses

func DecodeTree(s storer.EncodedObjectStorer, o plumbing.EncodedObject) (*Tree, error)

DecodeTree decodes an encoded object into a *Tree and associates it to the given object storer.

func GetTree Uses

func GetTree(s storer.EncodedObjectStorer, h plumbing.Hash) (*Tree, error)

GetTree gets a tree from an object storer and decodes it.

func (*Tree) Decode Uses

func (t *Tree) Decode(o plumbing.EncodedObject) (err error)

Decode transform an plumbing.EncodedObject into a Tree struct

func (*Tree) Diff Uses

func (from *Tree) Diff(to *Tree) (Changes, error)

Diff returns a list of changes between this tree and the provided one

func (*Tree) DiffContext Uses

func (from *Tree) DiffContext(ctx context.Context, to *Tree) (Changes, error)

Diff returns a list of changes between this tree and the provided one Error will be returned if context expires Provided context must be non nil

func (*Tree) Encode Uses

func (t *Tree) Encode(o plumbing.EncodedObject) (err error)

Encode transforms a Tree into a plumbing.EncodedObject.

func (*Tree) File Uses

func (t *Tree) File(path string) (*File, error)

File returns the hash of the file identified by the `path` argument. The path is interpreted as relative to the tree receiver.

func (*Tree) Files Uses

func (t *Tree) Files() *FileIter

Files returns a FileIter allowing to iterate over the Tree

func (*Tree) FindEntry Uses

func (t *Tree) FindEntry(path string) (*TreeEntry, error)

FindEntry search a TreeEntry in this tree or any subtree.

func (*Tree) ID Uses

func (t *Tree) ID() plumbing.Hash

ID returns the object ID of the tree. The returned value will always match the current value of Tree.Hash.

ID is present to fulfill the Object interface.

func (*Tree) Patch Uses

func (from *Tree) Patch(to *Tree) (*Patch, error)

Patch returns a slice of Patch objects with all the changes between trees in chunks. This representation can be used to create several diff outputs.

func (*Tree) PatchContext Uses

func (from *Tree) PatchContext(ctx context.Context, to *Tree) (*Patch, error)

Patch returns a slice of Patch objects with all the changes between trees in chunks. This representation can be used to create several diff outputs. If context expires, an error will be returned Provided context must be non-nil

func (*Tree) Size Uses

func (t *Tree) Size(path string) (int64, error)

Size returns the plaintext size of an object, without reading it into memory.

func (*Tree) Tree Uses

func (t *Tree) Tree(path string) (*Tree, error)

Tree returns the tree identified by the `path` argument. The path is interpreted as relative to the tree receiver.

func (*Tree) TreeEntryFile Uses

func (t *Tree) TreeEntryFile(e *TreeEntry) (*File, error)

TreeEntryFile returns the *File for a given *TreeEntry.

func (*Tree) Type Uses

func (t *Tree) Type() plumbing.ObjectType

Type returns the type of object. It always returns plumbing.TreeObject.

type TreeEntry Uses

type TreeEntry struct {
    Name string
    Mode filemode.FileMode
    Hash plumbing.Hash
}

TreeEntry represents a file

type TreeIter Uses

type TreeIter struct {
    storer.EncodedObjectIter
    // contains filtered or unexported fields
}

TreeIter provides an iterator for a set of trees.

func NewTreeIter Uses

func NewTreeIter(s storer.EncodedObjectStorer, iter storer.EncodedObjectIter) *TreeIter

NewTreeIter takes a storer.EncodedObjectStorer and a storer.EncodedObjectIter and returns a *TreeIter that iterates over all tree contained in the storer.EncodedObjectIter.

Any non-tree object returned by the storer.EncodedObjectIter is skipped.

func (*TreeIter) ForEach Uses

func (iter *TreeIter) ForEach(cb func(*Tree) error) error

ForEach call the cb function for each tree contained on this iter until an error happens or the end of the iter is reached. If ErrStop is sent the iteration is stop but no error is returned. The iterator is closed.

func (*TreeIter) Next Uses

func (iter *TreeIter) Next() (*Tree, error)

Next moves the iterator to the next tree and returns a pointer to it. If there are no more trees, it returns io.EOF.

type TreeWalker Uses

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

TreeWalker provides a means of walking through all of the entries in a Tree.

func NewTreeWalker Uses

func NewTreeWalker(t *Tree, recursive bool, seen map[plumbing.Hash]bool) *TreeWalker

NewTreeWalker returns a new TreeWalker for the given tree.

It is the caller's responsibility to call Close() when finished with the tree walker.

func (*TreeWalker) Close Uses

func (w *TreeWalker) Close()

Close releases any resources used by the TreeWalker.

func (*TreeWalker) Next Uses

func (w *TreeWalker) Next() (name string, entry TreeEntry, err error)

Next returns the next object from the tree. Objects are returned in order and subtrees are included. After the last object has been returned further calls to Next() will return io.EOF.

In the current implementation any objects which cannot be found in the underlying repository will be skipped automatically. It is possible that this may change in future versions.

func (*TreeWalker) Tree Uses

func (w *TreeWalker) Tree() *Tree

Tree returns the tree that the tree walker most recently operated on.

Directories

PathSynopsis
commitgraphPackage commitgraph provides an interface for efficient traversal over Git commit graph either through the regular object storage, or optionally with the index stored in commit-graph file (Git 2.18+).

Package object imports 29 packages (graph) and is imported by 288 packages. Updated 2019-11-06. Refresh now. Tools for package owners.