Documentation ¶
Index ¶
- Constants
- Variables
- func HashesSort(a []Hash)
- func IsErrBadReferenceName(err error) bool
- func IsErrResourceLocked(err error) bool
- func IsErrRevNotFound(e error) bool
- func IsLooseDir(s string) bool
- func IsNoSuchObject(e error) bool
- func NewErrResourceLocked(t string, name ReferenceName) error
- func NewErrRevNotFound(format string, a ...any) error
- func NoSuchObject(oid Hash) error
- func ValidateBranchName(branch []byte) bool
- func ValidateHashHex(s string) bool
- func ValidateReferenceName(refname []byte) bool
- func ValidateTagName(tag []byte) bool
- type ErrBadReferenceName
- type ErrResourceLocked
- type ErrRevNotFound
- type Hash
- type HashSlice
- type Hasher
- type Reference
- type ReferenceName
- func (r ReferenceName) BranchName() string
- func (r ReferenceName) IsBranch() bool
- func (r ReferenceName) IsRemote() bool
- func (r ReferenceName) IsTag() bool
- func (r ReferenceName) Prefix() string
- func (r ReferenceName) Short() string
- func (r ReferenceName) String() string
- func (r ReferenceName) TagName() string
- type ReferenceSlice
- type ReferenceType
Constants ¶
const ( HASH_DIGEST_SIZE = 32 HASH_HEX_SIZE = 64 )
const ( BLANK_BLOB = "af1349b9f5f9a1a6a0404dea36dcc9499bcb25c9adc112b7cc9a93cae41f3262" ZERO_OID = "0000000000000000000000000000000000000000000000000000000000000000" )
const (
Origin = "origin"
)
const (
RefRevParseRulesCount = 6
)
const (
ReferencePrefix = "refs/"
)
Variables ¶
var (
ErrReferenceNotFound = errors.New("reference does not exist")
)
var ( //ErrStop is used to stop a ForEach function in an Iter ErrStop = errors.New("stop iter") )
var RefRevParseRules = []string{
"%s",
"refs/%s",
"refs/tags/%s",
"refs/heads/%s",
"refs/remotes/%s",
"refs/remotes/%s/HEAD",
}
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
Functions ¶
func IsErrBadReferenceName ¶
func IsErrResourceLocked ¶
func IsErrRevNotFound ¶
func IsLooseDir ¶
func IsNoSuchObject ¶
IsNoSuchObject indicates whether an error is a noSuchObject and is non-nil.
func NewErrResourceLocked ¶
func NewErrResourceLocked(t string, name ReferenceName) error
func NewErrRevNotFound ¶
func NoSuchObject ¶
NoSuchObject creates a new error representing a missing object with a given object ID.
func ValidateBranchName ¶
ValidateBranchName: creating branches starting with - is not supported
func ValidateHashHex ¶
ValidateHashHex returns true if the given string is a valid hash.
func ValidateReferenceName ¶
* Try to read one refname component from the front of refname. * Return the length of the component found, or -1 if the component is * not legal. It is legal if it is something reasonable to have under * ".zeta/refs/"; We do not like it if: * * - it begins with ".", or * - it has double dots "..", or * - it has ASCII control characters, or * - it has ":", "?", "[", "\", "^", "~", SP, or TAB anywhere, or * - it has "*" anywhere unless REFNAME_REFSPEC_PATTERN is set, or * - it ends with a "/", or * - it ends with ".lock", or * - it contains a "@{" portion * * When sanitized is not NULL, instead of rejecting the input refname * as an error, try to come up with a usable replacement for the input * refname in it.
func ValidateTagName ¶
ValidateTagName: creating tags starting with - is not supported
Types ¶
type ErrBadReferenceName ¶
type ErrBadReferenceName struct {
Name string
}
func (ErrBadReferenceName) Error ¶
func (err ErrBadReferenceName) Error() string
type ErrResourceLocked ¶
type ErrResourceLocked struct {
// contains filtered or unexported fields
}
func (*ErrResourceLocked) Error ¶
func (err *ErrResourceLocked) Error() string
type ErrRevNotFound ¶
type ErrRevNotFound struct {
Reason string
}
func (*ErrRevNotFound) Error ¶
func (e *ErrRevNotFound) Error() string
type Hash ¶
type Hash [HASH_DIGEST_SIZE]byte
Hash BLAKE3 hashed content
var ZeroHash Hash
ZeroHash is Hash with value zero
func ExtractNoSuchObject ¶
func (Hash) MarshalJSON ¶
func (*Hash) UnmarshalJSON ¶
func (*Hash) UnmarshalText ¶
type HashSlice ¶
type HashSlice []Hash
HashSlice attaches the methods of sort.Interface to []Hash, sorting in increasing order.
type Reference ¶
type Reference struct {
// contains filtered or unexported fields
}
Reference is a representation of git reference
func NewHashReference ¶
func NewHashReference(n ReferenceName, h Hash) *Reference
NewHashReference creates a new HashReference reference
func NewReferenceFromStrings ¶
NewReferenceFromStrings creates a reference from name and target as string, the resulting reference can be a SymbolicReference or a HashReference base on the target provided
func NewSymbolicReference ¶
func NewSymbolicReference(n, target ReferenceName) *Reference
NewSymbolicReference creates a new SymbolicReference reference
func (*Reference) Name ¶
func (r *Reference) Name() ReferenceName
Name returns the name of a reference
func (*Reference) Target ¶
func (r *Reference) Target() ReferenceName
Target returns the target of a symbolic reference
func (*Reference) Type ¶
func (r *Reference) Type() ReferenceType
Type returns the type of a reference
type ReferenceName ¶
type ReferenceName string
ReferenceName reference name's
const ( HEAD ReferenceName = "HEAD" Mainline ReferenceName = "refs/heads/mainline" )
func NewBranchReferenceName ¶
func NewBranchReferenceName(name string) ReferenceName
NewBranchReferenceName returns a reference name describing a branch based on his short name.
func NewRemoteHEADReferenceName ¶
func NewRemoteHEADReferenceName(remote string) ReferenceName
NewRemoteHEADReferenceName returns a reference name describing a the HEAD branch of a remote.
func NewRemoteReferenceName ¶
func NewRemoteReferenceName(remote, name string) ReferenceName
NewRemoteReferenceName returns a reference name describing a remote branch based on his short name and the remote name.
func NewTagReferenceName ¶
func NewTagReferenceName(name string) ReferenceName
NewTagReferenceName returns a reference name describing a tag based on short his name.
func (ReferenceName) BranchName ¶
func (r ReferenceName) BranchName() string
func (ReferenceName) IsBranch ¶
func (r ReferenceName) IsBranch() bool
IsBranch check if a reference is a branch
func (ReferenceName) IsRemote ¶
func (r ReferenceName) IsRemote() bool
IsRemote check if a reference is a remote
func (ReferenceName) IsTag ¶
func (r ReferenceName) IsTag() bool
IsTag check if a reference is a tag
func (ReferenceName) Prefix ¶
func (r ReferenceName) Prefix() string
func (ReferenceName) Short ¶
func (r ReferenceName) Short() string
Short returns the short name of a ReferenceName
un strict, does not check whether the name is ambiguous
func (ReferenceName) String ¶
func (r ReferenceName) String() string
func (ReferenceName) TagName ¶
func (r ReferenceName) TagName() string
type ReferenceSlice ¶
type ReferenceSlice []*Reference
func (ReferenceSlice) Len ¶
func (p ReferenceSlice) Len() int
func (ReferenceSlice) Less ¶
func (p ReferenceSlice) Less(i, j int) bool
func (ReferenceSlice) Swap ¶
func (p ReferenceSlice) Swap(i, j int)
type ReferenceType ¶
type ReferenceType int8
ReferenceType reference type's
const ( InvalidReference ReferenceType = 0 HashReference ReferenceType = 1 SymbolicReference ReferenceType = 2 )
func (ReferenceType) String ¶
func (r ReferenceType) String() string
Directories ¶
Path | Synopsis |
---|---|
format
|
|
ignore
Package gitignore implements matching file system paths to gitignore patterns that can be automatically read from a git repository tree in the order of definition priorities.
|
Package gitignore implements matching file system paths to gitignore patterns that can be automatically read from a git repository tree in the order of definition priorities. |
index
Package index implements encoding and decoding of index format files.
|
Package index implements encoding and decoding of index format files. |
pktline
Package pktline implements reading payloads form pkt-lines and encoding pkt-lines from payloads.
|
Package pktline implements reading payloads form pkt-lines and encoding pkt-lines from payloads. |