Documentation
¶
Index ¶
- Constants
- type DB
- func (db *DB) AppendReflog(ctx context.Context, ref string, old, new store.Hash, who string, ...) error
- func (db *DB) CreateBranch(ctx context.Context, name string, commit store.Hash) error
- func (db *DB) CreateTag(ctx context.Context, name string, target store.Hash) error
- func (db *DB) DeleteBranch(ctx context.Context, name string, expected store.Hash) error
- func (db *DB) DeleteTag(ctx context.Context, name string, expected store.Hash) error
- func (db *DB) GetBranch(ctx context.Context, name string) (store.Hash, error)
- func (db *DB) GetTag(ctx context.Context, name string) (store.Hash, error)
- func (db *DB) ListBranches(ctx context.Context) ([]string, error)
- func (db *DB) ListTags(ctx context.Context) ([]string, error)
- func (db *DB) ReadHEAD(ctx context.Context) (branch string, commit store.Hash, err error)
- func (db *DB) ReadReflog(ctx context.Context, ref string) ([]store.ReflogEntry, error)
- func (db *DB) Resolve(ctx context.Context, refish string) (store.Hash, error)
- func (db *DB) SetHEAD(ctx context.Context, branch string) error
- func (db *DB) UpdateBranch(ctx context.Context, name string, expected, next store.Hash) error
Constants ¶
const ( HeadRef = "HEAD" BranchPrefix = "refs/heads/" TagPrefix = "refs/tags/" )
Well-known ref prefixes.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type DB ¶
type DB struct {
// contains filtered or unexported fields
}
DB wraps a store.Storage and provides higher-level ref operations: branches, HEAD, tags, reflog, and ref-ish resolution.
func (*DB) AppendReflog ¶
func (db *DB) AppendReflog(ctx context.Context, ref string, old, new store.Hash, who string, op, msg string) error
AppendReflog records a ref movement.
func (*DB) CreateBranch ¶
CreateBranch creates a new branch pointing at commit.
func (*DB) DeleteBranch ¶
DeleteBranch deletes a branch if it points at expected.
func (*DB) ListBranches ¶
ListBranches returns all branch names (without the prefix), sorted.
func (*DB) ReadHEAD ¶
ReadHEAD returns the current HEAD. HEAD is stored as a symbolic ref whose value is a branch name (e.g. "refs/heads/main"). We store it as a special ref whose "hash" is actually the branch ref name encoded. For v0, we store the branch name in a ref called "HEAD".
Returns the branch name (e.g. "refs/heads/main") and the commit hash that branch points to.
func (*DB) ReadReflog ¶
ReadReflog returns the reflog for a given ref.
func (*DB) Resolve ¶
Resolve parses a ref-ish string and returns the commit hash it points to.
Supported forms:
- Full hex hash (64 chars)
- Branch name: "main" -> looks up refs/heads/main
- Tag name: "v1.0" -> looks up refs/tags/v1.0
- "HEAD" -> dereferences HEAD
- Ancestor: "main~3" or "HEAD~1" -> walks N parents
- Raw ref path: "refs/heads/main" or "refs/tags/v1.0"