Documentation
¶
Overview ¶
Package git defines the GitRunner interface and a system-git implementation that shells out to the installed git binary.
Index ¶
- func IsFullSHA(s string) bool
- func WithMemo(ctx context.Context) context.Context
- type BranchRef
- type Memoized
- func (m Memoized) FetchCommit(ctx context.Context, url, commit, dest string) error
- func (m Memoized) LsRemoteHeads(ctx context.Context, url string) ([]BranchRef, error)
- func (m Memoized) LsRemoteTags(ctx context.Context, url string) ([]TagRef, error)
- func (m Memoized) ResolveRef(ctx context.Context, url, ref string) (string, error)
- type Runner
- type SystemRunner
- func (SystemRunner) FetchCommit(ctx context.Context, url, commit, dest string) error
- func (SystemRunner) LsRemoteHeads(ctx context.Context, url string) ([]BranchRef, error)
- func (SystemRunner) LsRemoteTags(ctx context.Context, url string) ([]TagRef, error)
- func (SystemRunner) ResolveRef(ctx context.Context, url, ref string) (string, error)
- type TagRef
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func IsFullSHA ¶ added in v0.3.0
IsFullSHA reports whether s is a full 40-hex commit SHA — the single definition shared by ref resolution and the wizard's typed-ref input.
func WithMemo ¶ added in v0.5.0
WithMemo arms run-scoped memoization for every Memoized runner call made under the returned context. One armed context = one command's consistent view of each remote; repeated resolutions return the first answer. Idempotent: a context already carrying a memo is returned unchanged.
Types ¶
type Memoized ¶ added in v0.5.0
type Memoized struct {
// contains filtered or unexported fields
}
Memoized decorates a Runner with context-scoped memoization (see WithMemo). Without an armed context every call passes straight through.
func (Memoized) FetchCommit ¶ added in v0.5.0
FetchCommit always delegates: it materializes into a caller-owned dest, so sharing one result across callers would be wrong.
func (Memoized) LsRemoteHeads ¶ added in v0.5.0
LsRemoteHeads returns the run's memoized branch listing for url.
func (Memoized) LsRemoteTags ¶ added in v0.5.0
LsRemoteTags returns the run's memoized tag listing for url, fetching it once on first use.
type Runner ¶
type Runner interface {
// LsRemoteTags lists the repo's tags and the commits they point to.
LsRemoteTags(ctx context.Context, url string) ([]TagRef, error)
// LsRemoteHeads lists the repo's branches and their head commits.
LsRemoteHeads(ctx context.Context, url string) ([]BranchRef, error)
// ResolveRef resolves a branch, tag, or commit ref to an immutable commit SHA.
ResolveRef(ctx context.Context, url, ref string) (string, error)
// FetchCommit materializes the tree at commit into dest, without a .git dir.
FetchCommit(ctx context.Context, url, commit, dest string) error
}
Runner is the git capability gskill needs. The system implementation shells out to the git binary; the interface lets it be swapped (e.g. go-git) later.
func Fresh ¶ added in v0.5.0
Fresh returns a runner for callers that must see upstream state newer than the run's memoized view (the computedHash-mismatch retry). Its first ask for a key re-asks the remote and refreshes the run memo; later asks — from this runner or the memoized one — reuse the refreshed answer, so N sibling skills retrying one moved source cost one extra round trip, not N.
type SystemRunner ¶
type SystemRunner struct{}
SystemRunner implements Runner by shelling out to the system git binary.
func NewSystemRunner ¶
func NewSystemRunner() SystemRunner
NewSystemRunner returns a Runner backed by the system git binary.
func (SystemRunner) FetchCommit ¶
func (SystemRunner) FetchCommit(ctx context.Context, url, commit, dest string) error
FetchCommit materializes the tree at commit into dest with no .git directory.
func (SystemRunner) LsRemoteHeads ¶ added in v0.3.0
LsRemoteHeads lists branch heads via "git ls-remote --heads".
func (SystemRunner) LsRemoteTags ¶
LsRemoteTags lists tags via "git ls-remote --tags", preferring the peeled (^{}) commit for annotated tags.
func (SystemRunner) ResolveRef ¶
ResolveRef resolves a ref to an immutable commit SHA. A full SHA is returned as-is; otherwise the ref is looked up via "git ls-remote".