ref

package
v0.14.0 Latest Latest
Warning

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

Go to latest
Published: Aug 27, 2023 License: Apache-2.0 Imports: 14 Imported by: 3

Documentation

Index

Constants

View Source
const (
	HeadPrefix           = "heads/"
	TagPrefix            = "tags/"
	RemoteRefPrefix      = "remotes/"
	TransactionRefPrefix = "txs/"
)

Variables

View Source
var (
	HeadPattern = regexp.MustCompile(`^[-_0-9a-zA-Z/]+$`)
	HashPattern = regexp.MustCompile(`^[a-f0-9]{32}$`)
)
View Source
var ErrKeyNotFound = fmt.Errorf("key not found")

Functions

func CommitHead

func CommitHead(s Store, name string, sum []byte, commit *objects.Commit, txid *uuid.UUID) error

func CommitMerge

func CommitMerge(s Store, branch string, sum []byte, commit *objects.Commit) error

func CopyRef

func CopyRef(s Store, srcName, dstName string) (sum []byte, err error)

func DeleteAllRemoteRefs

func DeleteAllRemoteRefs(s Store, remote string) error

func DeleteHead

func DeleteHead(s Store, name string) error

func DeleteRef

func DeleteRef(s Store, name string) error

func DeleteRemoteRef

func DeleteRemoteRef(s Store, remote, name string) error

func DeleteTag

func DeleteTag(s Store, name string) error

func DeleteTransactionRefs added in v0.10.1

func DeleteTransactionRefs(s Store, id uuid.UUID) error

func FirstLine added in v0.10.1

func FirstLine(s string) string

func GetHead

func GetHead(s Store, name string) ([]byte, error)

func GetRef

func GetRef(s Store, name string) ([]byte, error)

func GetRemoteRef

func GetRemoteRef(s Store, remote, name string) ([]byte, error)

func GetTag

func GetTag(s Store, name string) ([]byte, error)

func HeadRef added in v0.10.1

func HeadRef(name string) string

func InterpretCommitName

func InterpretCommitName(db objects.Store, rs Store, commitStr string, excludeTag bool) (name string, hash []byte, commit *objects.Commit, err error)

func IsAncestorOf

func IsAncestorOf(db objects.Store, commit1, commit2 []byte) (ok bool, err error)

IsAncestorOf returns true if "commit1" is ancestor of "commit2"

func ListAllRefs

func ListAllRefs(s Store) (map[string][]byte, error)

func ListHeads

func ListHeads(s Store) (map[string][]byte, error)

func ListLocalRefs

func ListLocalRefs(s Store, prefixes, notPrefixes []string) (map[string][]byte, error)

func ListRemoteRefs

func ListRemoteRefs(s Store, remote string) (map[string][]byte, error)

func ListTags

func ListTags(s Store) (map[string][]byte, error)

func ListTransactionRefs added in v0.10.1

func ListTransactionRefs(s Store, id uuid.UUID) (map[string][]byte, error)

func ParseNavigationChars

func ParseNavigationChars(commitStr string) (commitName string, numPeel int, err error)

func PeelCommit

func PeelCommit(db objects.Store, hash []byte, commit *objects.Commit, numPeel int) ([]byte, *objects.Commit, error)

func RemoteRef

func RemoteRef(remote, name string) string

func RenameAllRemoteRefs

func RenameAllRemoteRefs(s Store, oldRemote, newRemote string) error

func RenameRef

func RenameRef(s Store, oldName, newName string) (sum []byte, err error)

func SaveFetchRef added in v0.8.4

func SaveFetchRef(s Store, name string, commit []byte, authorName, authorEmail, remote, message string) error

func SaveRef

func SaveRef(s Store, name string, commit []byte, authorName, authorEmail, action, message string, txid *uuid.UUID) error

func SaveRemoteRef

func SaveRemoteRef(s Store, remote, name string, commit []byte, authorName, authorEmail, action, message string) error

func SaveTag

func SaveTag(s Store, name string, sum []byte) error

func SaveTransactionRef added in v0.10.1

func SaveTransactionRef(s Store, tid uuid.UUID, branch string, sum []byte) error

func SeekCommonAncestor

func SeekCommonAncestor(db objects.Store, commits ...[]byte) (baseCommit []byte, err error)

func TransactionRef added in v0.10.1

func TransactionRef(tid, branch string) string

Types

type CommitsQueue

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

CommitsQueue is a queue sorted by commit time (newer commit first, older commit last).

func NewCommitsQueue

func NewCommitsQueue(db objects.Store, initialSums [][]byte) (*CommitsQueue, error)

func (*CommitsQueue) Insert

func (q *CommitsQueue) Insert(sum []byte) (err error)

func (*CommitsQueue) InsertParents

func (q *CommitsQueue) InsertParents(c *objects.Commit) (err error)

func (*CommitsQueue) Len

func (q *CommitsQueue) Len() int

func (*CommitsQueue) Less

func (q *CommitsQueue) Less(i, j int) bool

func (*CommitsQueue) Pop

func (q *CommitsQueue) Pop() (sum []byte, commit *objects.Commit, err error)

func (*CommitsQueue) PopInsertParents

func (q *CommitsQueue) PopInsertParents() (sum []byte, commit *objects.Commit, err error)

func (*CommitsQueue) PopUntil

func (q *CommitsQueue) PopUntil(b []byte) (sum []byte, commit *objects.Commit, err error)

func (*CommitsQueue) RemoveAncestors

func (q *CommitsQueue) RemoveAncestors(sums [][]byte) error

func (*CommitsQueue) Reset added in v0.12.1

func (q *CommitsQueue) Reset(initialSums [][]byte) error

func (*CommitsQueue) Seen

func (q *CommitsQueue) Seen(b []byte) bool

func (*CommitsQueue) Swap

func (q *CommitsQueue) Swap(i, j int)

type Reflog

type Reflog struct {
	OldOID      []byte
	NewOID      []byte
	AuthorName  string
	AuthorEmail string
	Time        time.Time
	Action      string
	Message     string
	Txid        *uuid.UUID
}

func (*Reflog) FetchRemote added in v0.8.4

func (rec *Reflog) FetchRemote() string

func (*Reflog) Read

func (rec *Reflog) Read(b []byte) (n int, err error)

func (*Reflog) WriteTo

func (rec *Reflog) WriteTo(w io.Writer) (total int64, err error)

type ReflogReader

type ReflogReader interface {
	Read() (*Reflog, error)
	Close() error
}

type Store

type Store interface {
	SetWithLog(key string, val []byte, log *Reflog) error
	Set(key string, val []byte) error
	Get(key string) (val []byte, err error)
	Delete(key string) error
	Filter(prefixes, notPrefixes []string) (m map[string][]byte, err error)
	FilterKey(prefixes, notPrefixes []string) (keys []string, err error)
	Rename(oldKey, newKey string) (err error)
	Copy(srcKey, dstKey string) (err error)
	LogReader(key string) (ReflogReader, error)

	NewTransaction(tx *Transaction) (*uuid.UUID, error)
	GetTransaction(id uuid.UUID) (*Transaction, error)
	UpdateTransaction(tx *Transaction) error
	DeleteTransaction(id uuid.UUID) error
	GCTransactions(txTTL time.Duration) (ids []uuid.UUID, err error)
	GetTransactionLogs(txid uuid.UUID) (logs map[string]*Reflog, err error)
	ListTransactions(offset, limit int) (txs []*Transaction, err error)
}

type Transaction added in v0.10.1

type Transaction struct {
	ID     uuid.UUID
	Status TransactionStatus
	Begin  time.Time
	End    time.Time
}

type TransactionStatus added in v0.10.1

type TransactionStatus string
const (
	TSInProgress TransactionStatus = "in-progress"
	TSCommitted  TransactionStatus = "committed"
)

type Traveller added in v0.8.4

type Traveller struct {

	// Reflog is the closest reflog to the current commit, provided that all traversal is done via Parent()
	Reflog *Reflog
	// contains filtered or unexported fields
}

Traveller travels a ref from the latest commit to the very first commit of that ref

func NewTraveller added in v0.8.4

func NewTraveller(db objects.Store, rs Store, refName string) (*Traveller, error)

NewTraveller creates a new BranchTraveller

func (*Traveller) Close added in v0.8.4

func (rt *Traveller) Close() error

func (*Traveller) Next added in v0.8.4

func (rt *Traveller) Next() (*objects.Commit, error)

Next traverses the ref and returns the next commit. If it returns nil then that means there's no more commit in this ref.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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