plumbing

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, Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	HASH_DIGEST_SIZE = 32
	HASH_HEX_SIZE    = 64
)
View Source
const (
	BLANK_BLOB = "af1349b9f5f9a1a6a0404dea36dcc9499bcb25c9adc112b7cc9a93cae41f3262"
	ZERO_OID   = "0000000000000000000000000000000000000000000000000000000000000000"
)
View Source
const (
	Origin = "origin"
)
View Source
const (
	RefRevParseRulesCount = 6
)
View Source
const (
	ReferencePrefix = "refs/"
)

Variables

View Source
var (
	ErrReferenceNotFound = errors.New("reference does not exist")
)
View Source
var (
	//ErrStop is used to stop a ForEach function in an Iter
	ErrStop = errors.New("stop iter")
)
View Source
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 HashesSort

func HashesSort(a []Hash)

HashesSort sorts a slice of Hashes in increasing order.

func IsErrBadReferenceName

func IsErrBadReferenceName(err error) bool

func IsErrResourceLocked

func IsErrResourceLocked(err error) bool

func IsErrRevNotFound

func IsErrRevNotFound(e error) bool

func IsLooseDir

func IsLooseDir(s string) bool

func IsNoSuchObject

func IsNoSuchObject(e error) bool

IsNoSuchObject indicates whether an error is a noSuchObject and is non-nil.

func NewErrResourceLocked

func NewErrResourceLocked(t string, name ReferenceName) error

func NewErrRevNotFound

func NewErrRevNotFound(format string, a ...any) error

func NoSuchObject

func NoSuchObject(oid Hash) error

NoSuchObject creates a new error representing a missing object with a given object ID.

func ValidateBranchName

func ValidateBranchName(branch []byte) bool

ValidateBranchName: creating branches starting with - is not supported

func ValidateHashHex

func ValidateHashHex(s string) bool

ValidateHashHex returns true if the given string is a valid hash.

func ValidateReferenceName

func ValidateReferenceName(refname []byte) bool

* 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

func ValidateTagName(tag []byte) bool

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 ExtractNoSuchObject(e error) (Hash, bool)

func NewHash

func NewHash(s string) Hash

NewHash return a new Hash from a hexadecimal hash representation

func (Hash) IsZero

func (h Hash) IsZero() bool

func (Hash) MarshalJSON

func (h Hash) MarshalJSON() ([]byte, error)

func (Hash) MarshalText

func (h Hash) MarshalText() ([]byte, error)

TOML

func (Hash) Prefix

func (h Hash) Prefix() string

func (Hash) Shorten

func (h Hash) Shorten() int

func (Hash) String

func (h Hash) String() string

func (*Hash) UnmarshalJSON

func (h *Hash) UnmarshalJSON(b []byte) error

func (*Hash) UnmarshalText

func (h *Hash) UnmarshalText(text []byte) error

type HashSlice

type HashSlice []Hash

HashSlice attaches the methods of sort.Interface to []Hash, sorting in increasing order.

func (HashSlice) Len

func (p HashSlice) Len() int

func (HashSlice) Less

func (p HashSlice) Less(i, j int) bool

func (HashSlice) Swap

func (p HashSlice) Swap(i, j int)

type Hasher

type Hasher struct {
	hash.Hash
}

func NewHasher

func NewHasher() Hasher

func (Hasher) Sum

func (h Hasher) Sum() (hash Hash)

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

func NewReferenceFromStrings(name, target string) *Reference

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) Hash

func (r *Reference) Hash() Hash

Hash returns the hash of a hash reference

func (*Reference) Name

func (r *Reference) Name() ReferenceName

Name returns the name of a reference

func (*Reference) String

func (r *Reference) String() string

func (*Reference) Strings

func (r *Reference) Strings() [2]string

Strings dump a reference as a [2]string

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.

Jump to

Keyboard shortcuts

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