refs

package
v0.16.2 Latest Latest
Warning

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

Go to latest
Published: Dec 23, 2024 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const MaxResolveRecursion = 1024

Variables

View Source
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")
)
View Source
var ErrMaxResolveRecursion = errors.New("max. recursion level reached")

ErrMaxResolveRecursion is returned by ResolveReference is MaxResolveRecursion is exceeded

View Source
var (
	ErrReferenceHasChanged = errors.New("reference has changed concurrently")
)

Functions

func CheckClose

func CheckClose(c io.Closer, err *error)

func ReferenceResolve

func ReferenceResolve(b Backend, name plumbing.ReferenceName) (ref *plumbing.Reference, err error)

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

func NewBackend(repoPath string) Backend

type DB

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

DB: References DB

func ReferencesDB

func ReferencesDB(repoPath string) (*DB, error)

func (*DB) Exists

func (d *DB) Exists(refname plumbing.ReferenceName) bool

func (*DB) HEAD

func (d *DB) HEAD() *plumbing.Reference

func (*DB) IsCurrent

func (d *DB) IsCurrent(refname plumbing.ReferenceName) bool

func (*DB) Lookup

func (d *DB) Lookup(name string) *plumbing.Reference

func (*DB) References

func (d *DB) References() []*plumbing.Reference

func (*DB) Resolve

func (d *DB) Resolve(name plumbing.ReferenceName) (*plumbing.Reference, error)

func (*DB) ShortName

func (d *DB) ShortName(refname plumbing.ReferenceName, strict bool) string

Return shorten unambiguous refname

func (*DB) Sort

func (d *DB) Sort()

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.

func (*ReferenceSliceIter) Next

func (iter *ReferenceSliceIter) Next() (*plumbing.Reference, error)

Next returns the next reference from the iterator. If the iterator has reached the end it will return io.EOF as an error.

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

func (Rule) ShortName

func (r Rule) ShortName(name string) string

Jump to

Keyboard shortcuts

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