Documentation ¶
Index ¶
- Constants
- Variables
- func CheckClose(c io.Closer, err *error)
- func ReferenceResolve(b Backend, name plumbing.ReferenceName) (ref *plumbing.Reference, err error)
- type Backend
- type DB
- func (d *DB) Exists(refname plumbing.ReferenceName) bool
- func (d *DB) HEAD() *plumbing.Reference
- func (d *DB) IsCurrent(refname plumbing.ReferenceName) bool
- func (d *DB) Lookup(name string) *plumbing.Reference
- func (d *DB) References() []*plumbing.Reference
- func (d *DB) Resolve(name plumbing.ReferenceName) (*plumbing.Reference, error)
- func (d *DB) ShortName(refname plumbing.ReferenceName, strict bool) string
- func (d *DB) Sort()
- type ReferenceIter
- type ReferenceSliceIter
- type Rule
Constants ¶
const MaxResolveRecursion = 1024
Variables ¶
var ( // ErrNotFound is returned by New when the path is not found. ErrNotFound = errors.New("path not found") // ErrIdxNotFound is returned by Idxfile when the idx file is not found ErrIdxNotFound = errors.New("idx file not found") // ErrPackfileNotFound is returned by Packfile when the packfile is not found ErrPackfileNotFound = errors.New("packfile not found") // ErrConfigNotFound is returned by Config when the config is not found ErrConfigNotFound = errors.New("config file not found") // ErrPackedRefsDuplicatedRef is returned when a duplicated reference is // found in the packed-ref file. This is usually the case for corrupted git // repositories. ErrPackedRefsDuplicatedRef = errors.New("duplicated ref found in packed-ref file") // ErrPackedRefsBadFormat is returned when the packed-ref file corrupt. ErrPackedRefsBadFormat = errors.New("malformed packed-ref") // ErrSymRefTargetNotFound is returned when a symbolic reference is // targeting a non-existing object. This usually means the repository // is corrupt. ErrSymRefTargetNotFound = errors.New("symbolic reference target not found") // ErrIsDir is returned when a reference file is attempting to be read, // but the path specified is a directory. ErrIsDir = errors.New("reference path is a directory") )
var ErrMaxResolveRecursion = errors.New("max. recursion level reached")
ErrMaxResolveRecursion is returned by ResolveReference is MaxResolveRecursion is exceeded
var (
ErrReferenceHasChanged = errors.New("reference has changed concurrently")
)
Functions ¶
func CheckClose ¶
func ReferenceResolve ¶
Types ¶
type Backend ¶
type Backend interface { // Find the current reference HEAD() (*plumbing.Reference, error) // view all references References() (*DB, error) // Look up a reference using the full reference name. Reference(name plumbing.ReferenceName) (*plumbing.Reference, error) // ReferencePrefixMatch match reference prefix // prefix: refs/logs // refs/logs ✅ // refs/logs/211 ✅ // refs/logs.l ❌ ReferencePrefixMatch(prefix plumbing.ReferenceName) (*plumbing.Reference, error) // Update reference ReferenceUpdate(r, old *plumbing.Reference) error // remove reference ReferenceRemove(r *plumbing.Reference) error // packed references Packed() error }
func NewBackend ¶
type DB ¶
type DB struct {
// contains filtered or unexported fields
}
DB: References DB
func ReferencesDB ¶
func (*DB) References ¶
type ReferenceIter ¶
type ReferenceIter interface { Next() (*plumbing.Reference, error) ForEach(func(*plumbing.Reference) error) error Close() }
ReferenceIter is a generic closable interface for iterating over references.
func NewReferenceIter ¶
func NewReferenceIter(b Backend) (ReferenceIter, error)
func NewReferenceSliceIter ¶
func NewReferenceSliceIter(series []*plumbing.Reference) ReferenceIter
NewReferenceSliceIter returns a reference iterator for the given slice of objects.
type ReferenceSliceIter ¶
type ReferenceSliceIter struct {
// contains filtered or unexported fields
}
func (*ReferenceSliceIter) Close ¶
func (iter *ReferenceSliceIter) Close()
Close releases any resources used by the iterator.
func (*ReferenceSliceIter) ForEach ¶
func (iter *ReferenceSliceIter) ForEach(cb func(*plumbing.Reference) error) error
ForEach call the cb function for each reference 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.
type Rule ¶
type Rule struct {
// contains filtered or unexported fields
}
func RefRevParseRules ¶
func RefRevParseRules() []*Rule
RefRevParseRules are a set of rules to parse references into short names. These are the same rules as used by git in shorten_unambiguous_ref. See: https://github.com/git/git/blob/9857273be005833c71e2d16ba48e193113e12276/refs.c#L610
func (Rule) ReferenceName ¶
func (r Rule) ReferenceName(name string) plumbing.ReferenceName