Movatterモバイル変換


[0]ホーム

URL:


object

package
v5.16.4Latest Latest
Warning

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

Go to latest
Published: Nov 23, 2025 License:Apache-2.0Imports:26Imported by:1,782

Details

Repository

github.com/go-git/go-git

Links

Documentation

Overview

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

Index

Constants

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

DateFormat is the format being used in the original git implementation

Variables

View Source
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")ErrEntriesNotSorted  =errors.New("entries in tree are not sorted"))

New errors defined by this package.

View Source
var DefaultDiffTreeOptions = &DiffTreeOptions{DetectRenames:true,RenameScore:      60,RenameLimit:      0,OnlyExactRenames:false,}

DefaultDiffTreeOptions are the default and recommended options for thediff tree.

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

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

Functions

funcNewTreeRootNode

func NewTreeRootNode(t *Tree)noder.Noder

NewTreeRootNode returns the root node of a Tree

Types

typeBlob

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

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

funcDecodeBlob

func DecodeBlob(oplumbing.EncodedObject) (*Blob,error)

DecodeObject decodes an encoded object into a *Blob.

funcGetBlob

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

func (*Blob)Decode

func (b *Blob) Decode(oplumbing.EncodedObject)error

Decode transforms a plumbing.EncodedObject into a Blob struct.

func (*Blob)Encode

func (b *Blob) Encode(oplumbing.EncodedObject) (errerror)

Encode transforms a Blob into a plumbing.EncodedObject.

func (*Blob)ID

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

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

ID is present to fulfill the Object interface.

func (*Blob)Reader

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

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

func (*Blob)Type

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.

typeBlobIter

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

BlobIter provides an iterator for a set of blobs.

funcNewBlobIter

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

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

func (*BlobIter)ForEach

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

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

func (*BlobIter)Next

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

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

typeChange

type Change struct {FromChangeEntryToChangeEntry}

Change values represent a detected change between two git trees. Formodifications, From is the original status of the node and To is itsfinal status. For insertions, From is the zero value and fordeletions To is the zero value.

func (*Change)Action

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

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

func (*Change)Files

func (c *Change) Files() (from, to *File, errerror)

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

func (*Change)Patch

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

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

func (*Change)PatchContext

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

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

func (*Change)String

func (c *Change) String()string

typeChangeEntry

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

ChangeEntry values represent a node that has suffered a change.

typeChanges

type Changes []*Change

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

funcDetectRenamesadded inv5.1.0

func DetectRenames(changesChanges,opts *DiffTreeOptions,) (Changes,error)

DetectRenames detects the renames in the given changes on two trees withthe given options. It will return the given changes grouping additions anddeletions into modifications when possible.If options is nil, the default diff tree options will be used.

funcDiffTree

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

DiffTree compares the content and mode of the blobs found via twotree objects.DiffTree does not perform rename detection, use DiffTreeWithOptionsinstead to detect renames.

funcDiffTreeContext

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

DiffTreeContext compares the content and mode of the blobs found via twotree objects. Provided context must be non-nil.An error will be returned if context expires.

funcDiffTreeWithOptionsadded inv5.1.0

func DiffTreeWithOptions(ctxcontext.Context,a, b *Tree,opts *DiffTreeOptions,) (Changes,error)

DiffTreeWithOptions compares the content and mode of the blobs foundvia two tree objects with the given options. The provided contextmust be non-nil.If no options are passed, no rename detection will be performed. Therecommended options are DefaultDiffTreeOptions.An error will be returned if the context expires.This function will be deprecated and removed in v6 so the defaultbehaviour of DiffTree is to detect renames.

func (Changes)Len

func (cChanges) Len()int

func (Changes)Less

func (cChanges) Less(i, jint)bool

func (Changes)Patch

func (cChanges) Patch() (*Patch,error)

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

func (Changes)PatchContext

func (cChanges) PatchContext(ctxcontext.Context) (*Patch,error)

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

func (Changes)String

func (cChanges) String()string

func (Changes)Swap

func (cChanges) Swap(i, jint)

typeCommit

type Commit struct {// Hash of the commit object.Hashplumbing.Hash// Author is the original author of the commit.AuthorSignature// Committer is the one performing the commit, might be different from// Author.CommitterSignature// MergeTag is the embedded tag object when a merge commit is created by// merging a signed tag.MergeTagstring// PGPSignature is the PGP signature of the commit.PGPSignaturestring// Message is the commit message, contains arbitrary text.Messagestring// TreeHash is the hash of the root tree of the commit.TreeHashplumbing.Hash// ParentHashes are the hashes of the parent commits of the commit.ParentHashes []plumbing.Hash// Encoding is the encoding of the commit.EncodingMessageEncoding// List of extra headers of the commitExtraHeaders []ExtraHeader// contains filtered or unexported fields}

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

funcDecodeCommit

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

funcGetCommit

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

funcIndependents

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

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

func (*Commit)Decode

func (c *Commit) Decode(oplumbing.EncodedObject) (errerror)

Decode transforms a plumbing.EncodedObject into a Commit struct.

func (*Commit)Encode

Encode transforms a Commit into a plumbing.EncodedObject.

func (*Commit)EncodeWithoutSignature

func (c *Commit) EncodeWithoutSignature(oplumbing.EncodedObject)error

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

func (*Commit)File

func (c *Commit) File(pathstring) (*File,error)

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

func (*Commit)Files

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

Files returns a FileIter allowing to iterate over the Tree

func (*Commit)ID

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

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

ID is present to fulfill the Object interface.

func (*Commit)IsAncestor

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 transversableIt mimics the behavior of `git merge --is-ancestor actual other`

func (*Commit)Lessadded inv5.8.0

func (c *Commit) Less(rhs *Commit)bool

Less defines a compare function to determine which commit is 'earlier' by:- First use Committer.When- If Committer.When are equal then use Author.When- If Author.When also equal then compare the string value of the hash

func (*Commit)MergeBase

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

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

func (*Commit)NumParents

func (c *Commit) NumParents()int

NumParents returns the number of parents in a commit.

func (*Commit)Parent

func (c *Commit) Parent(iint) (*Commit,error)

Parent returns the ith parent of a commit.

func (*Commit)Parents

func (c *Commit) Parents()CommitIter

Parents return a CommitIter to the parent Commits.

func (*Commit)Patch

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

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

NOTE: Since version 5.1.0 the renames are correctly handled, the settingsused are the recommended options DefaultDiffTreeOptions.

func (*Commit)PatchContext

func (c *Commit) PatchContext(ctxcontext.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.

NOTE: Since version 5.1.0 the renames are correctly handled, the settingsused are the recommended options DefaultDiffTreeOptions.

func (*Commit)Stats

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

Stats returns the stats of a commit.

func (*Commit)StatsContext

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

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

func (*Commit)String

func (c *Commit) String()string

func (*Commit)Tree

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

Tree returns the Tree from the commit.

func (*Commit)Type

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

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

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

typeCommitFilter

type CommitFilter func(*Commit)bool

CommitFilter returns a boolean for the passed Commit

typeCommitIter

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

CommitIter is a generic closable interface for iterating over commits.

funcNewCommitAllIter

func NewCommitAllIter(repoStorerstorage.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

funcNewCommitFileIterFromIter

func NewCommitFileIterFromIter(fileNamestring, commitIterCommitIter, checkParentbool)CommitIter

NewCommitFileIterFromIter is kept for compatibility, can be replaced with NewCommitPathIterFromIter

funcNewCommitIter

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

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

funcNewCommitIterBSF

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 willbe visited only once. If the callback returns an error, walking will stopand will return the error. Other errors might be returned if the historycannot be traversed (e.g. missing objects). Ignore allows to skip somecommits from being iterated.

funcNewCommitIterCTime

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 willbe visited only once. If the callback returns an error, walking will stopand will return the error. Other errors might be returned if the historycannot be traversed (e.g. missing objects). Ignore allows to skip somecommits from being iterated.

funcNewCommitLimitIterFromIter

func NewCommitLimitIterFromIter(commitIterCommitIter, limitOptionsLogLimitOptions)CommitIter

funcNewCommitPathIterFromIter

func NewCommitPathIterFromIter(pathFilter func(string)bool, commitIterCommitIter, checkParentbool)CommitIter

NewCommitPathIterFromIter returns a commit iterator which performs diffTree betweensuccessive trees returned from the commit iterator from the argument. The purpose of this isto 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`).pathFilter is a function that takes path of file as argument and returns true if we want it

funcNewCommitPostorderIter

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

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

funcNewCommitPreorderIter

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 willbe visited only once. If the callback returns an error, walking will stopand will return the error. Other errors might be returned if the historycannot be traversed (e.g. missing objects). Ignore allows to skip somecommits from being iterated.

funcNewFilterCommitIter

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 limit, all ancestors of all commits will be visited.

typeDiffTreeOptionsadded inv5.1.0

type DiffTreeOptions struct {// DetectRenames is whether the diff tree will use rename detection.DetectRenamesbool// RenameScore is the threshold to of similarity between files to consider// that a pair of delete and insert are a rename. The number must be// exactly between 0 and 100.RenameScoreuint// RenameLimit is the maximum amount of files that can be compared when// detecting renames. The number of comparisons that have to be performed// is equal to the number of deleted files * the number of added files.// That means, that if 100 files were deleted and 50 files were added, 5000// file comparisons may be needed. So, if the rename limit is 50, the number// of both deleted and added needs to be equal or less than 50.// A value of 0 means no limit.RenameLimituint// OnlyExactRenames performs only detection of exact renames and will not perform// any detection of renames based on file similarity.OnlyExactRenamesbool}

DiffTreeOptions are the configurable options when performing a diff tree.

typeExtraHeaderadded inv5.16.3

type ExtraHeader struct {// Header nameKeystring// Value of the headerValuestring}

ExtraHeader holds any non-standard header

func (ExtraHeader)Formatadded inv5.16.3

func (hExtraHeader) Format(ffmt.State, verbrune)

Implement fmt.Formatter for ExtraHeader

typeFile

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

File represents git file objects.

funcNewFile

func NewFile(namestring, mfilemode.FileMode, b *Blob) *File

NewFile returns a File based on the given blob object

func (*File)Contents

func (f *File) Contents() (contentstring, errerror)

Contents returns the contents of a file as a string.

func (*File)IsBinary

func (f *File) IsBinary() (binbool, errerror)

IsBinary returns if the file is binary or not

func (*File)Lines

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

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

typeFileIter

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

FileIter provides an iterator for the files in a tree.

funcNewFileIter

func NewFileIter(sstorer.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

func (iter *FileIter) Close()

func (*FileIter)ForEach

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

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

func (*FileIter)Next

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

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

typeFileStat

type FileStat struct {NamestringAdditionintDeletionint}

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

func (FileStat)String

func (fsFileStat) String()string

typeFileStats

type FileStats []FileStat

FileStats is a collection of FileStat.

func (FileStats)String

func (fileStatsFileStats) String()string

typeHash

type Hashplumbing.Hash

Hash represents the hash of an object

typeLogLimitOptions

type LogLimitOptions struct {Since *time.TimeUntil *time.Time}

typeMessageEncodingadded inv5.10.0

type MessageEncodingstring

MessageEncoding represents the encoding of a commit

typeObject

Object is a generic representation of any git object. It is implemented byCommit, Tree, Blob, and Tag, and includes the functions that are common tothem.

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

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

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

funcDecodeObject

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

funcGetObject

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

typeObjectIter

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

ObjectIter provides an iterator for a set of objects.

funcNewObjectIter

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

func (*ObjectIter)ForEach

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

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

func (*ObjectIter)Next

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

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

typePatch

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

Patch is an implementation of fdiff.Patch interface

func (*Patch)Encode

func (p *Patch) Encode(wio.Writer)error

func (*Patch)FilePatches

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

func (*Patch)Message

func (p *Patch) Message()string

func (*Patch)Stats

func (p *Patch) Stats()FileStats

func (*Patch)String

func (p *Patch) String()string

typeSignature

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

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

func (*Signature)Decode

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

Decode decodes a byte slice into a signature

func (*Signature)Encode

func (s *Signature) Encode(wio.Writer)error

Encode encodes a Signature into a writer.

func (*Signature)String

func (s *Signature) String()string

typeTag

type Tag struct {// Hash of the tag.Hashplumbing.Hash// Name of the tag.Namestring// Tagger is the one who created the tag.TaggerSignature// Message is an arbitrary text message.Messagestring// PGPSignature is the PGP signature of the tag.PGPSignaturestring// TargetType is the object type of the target.TargetTypeplumbing.ObjectType// Target is the hash of the target object.Targetplumbing.Hash// contains filtered or unexported fields}

Tag represents an annotated tag object. It points to a single git object ofany type, but tags typically are applied to commit or blob objects. Itprovides a reference that associates the target with a tag name. It alsocontains meta-information about the tag, including the tagger, tag date andmessage.

Note that this is not used for lightweight tags.

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

funcDecodeTag

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

funcGetTag

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

func (*Tag)Blob

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

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

func (*Tag)Commit

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

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

func (*Tag)Decode

func (t *Tag) Decode(oplumbing.EncodedObject) (errerror)

Decode transforms a plumbing.EncodedObject into a Tag struct.

func (*Tag)Encode

func (t *Tag) Encode(oplumbing.EncodedObject)error

Encode transforms a Tag into a plumbing.EncodedObject.

func (*Tag)EncodeWithoutSignature

func (t *Tag) EncodeWithoutSignature(oplumbing.EncodedObject)error

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

func (*Tag)ID

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

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

Object returns the object pointed to by the tag.

func (*Tag)String

func (t *Tag) String()string

String returns the meta information contained in the tag as a formattedstring.

func (*Tag)Tree

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

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

func (*Tag)Type

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

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

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

typeTagIter

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

TagIter provides an iterator for a set of tags.

funcNewTagIter

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

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

func (*TagIter)ForEach

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

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

func (*TagIter)Next

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

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

typeTree

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

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

funcDecodeTree

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

funcGetTree

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

func (*Tree)Decode

func (t *Tree) Decode(oplumbing.EncodedObject) (errerror)

Decode transform an plumbing.EncodedObject into a Tree struct

func (*Tree)Diff

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

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

func (*Tree)DiffContext

func (t *Tree) DiffContext(ctxcontext.Context, to *Tree) (Changes,error)

DiffContext returns a list of changes between this tree and the provided oneError will be returned if context expires. Provided context must be non nil.

NOTE: Since version 5.1.0 the renames are correctly handled, the settingsused are the recommended options DefaultDiffTreeOptions.

func (*Tree)Encode

func (t *Tree) Encode(oplumbing.EncodedObject) (errerror)

Encode transforms a Tree into a plumbing.EncodedObject.The tree entries must be sorted by name.

func (*Tree)File

func (t *Tree) File(pathstring) (*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

func (t *Tree) Files() *FileIter

Files returns a FileIter allowing to iterate over the Tree

func (*Tree)FindEntry

func (t *Tree) FindEntry(pathstring) (*TreeEntry,error)

FindEntry search a TreeEntry in this tree or any subtree.

func (*Tree)ID

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

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

ID is present to fulfill the Object interface.

func (*Tree)Patch

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

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

func (*Tree)PatchContext

func (t *Tree) PatchContext(ctxcontext.Context, to *Tree) (*Patch,error)

PatchContext returns a slice of Patch objects with all the changes betweentrees in chunks. This representation can be used to create several diffoutputs. If context expires, an error will be returned. Provided context mustbe non-nil.

NOTE: Since version 5.1.0 the renames are correctly handled, the settingsused are the recommended options DefaultDiffTreeOptions.

func (*Tree)Size

func (t *Tree) Size(pathstring) (int64,error)

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

func (*Tree)Tree

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

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

func (*Tree)TreeEntryFile

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

TreeEntryFile returns the *File for a given *TreeEntry.

func (*Tree)Type

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

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

typeTreeEntry

type TreeEntry struct {NamestringModefilemode.FileModeHashplumbing.Hash}

TreeEntry represents a file

typeTreeEntrySorteradded inv5.12.0

type TreeEntrySorter []TreeEntry

func (TreeEntrySorter)Lenadded inv5.12.0

func (sTreeEntrySorter) Len()int

func (TreeEntrySorter)Lessadded inv5.12.0

func (sTreeEntrySorter) Less(i, jint)bool

func (TreeEntrySorter)Swapadded inv5.12.0

func (sTreeEntrySorter) Swap(i, jint)

typeTreeIter

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

TreeIter provides an iterator for a set of trees.

funcNewTreeIter

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

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

func (*TreeIter)ForEach

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

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

func (*TreeIter)Next

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

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

typeTreeWalker

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

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

funcNewTreeWalker

func NewTreeWalker(t *Tree, recursivebool, 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 thetree walker.

func (*TreeWalker)Close

func (w *TreeWalker) Close()

Close releases any resources used by the TreeWalker.

func (*TreeWalker)Next

func (w *TreeWalker) Next() (namestring, entryTreeEntry, errerror)

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

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

func (*TreeWalker)Tree

func (w *TreeWalker) Tree() *Tree

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

Source Files

View all Source files

Directories

PathSynopsis
Package 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 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+).

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f orF : Jump to
y orY : Canonical URL
go.dev uses cookies from Google to deliver and enhance the quality of its services and to analyze traffic.Learn more.

[8]ページ先頭

©2009-2025 Movatter.jp