git

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Jul 17, 2026 License: MIT Imports: 13 Imported by: 0

Documentation

Overview

Package git defines the GitRunner interface and a system-git implementation that shells out to the installed git binary.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsFullSHA added in v0.3.0

func IsFullSHA(s string) bool

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

func WithMemo(ctx context.Context) context.Context

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 BranchRef added in v0.3.0

type BranchRef struct {
	Name   string
	Commit string
}

BranchRef pairs a branch name with its head commit.

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

func (m Memoized) FetchCommit(ctx context.Context, url, commit, dest string) error

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

func (m Memoized) LsRemoteHeads(ctx context.Context, url string) ([]BranchRef, error)

LsRemoteHeads returns the run's memoized branch listing for url.

func (Memoized) LsRemoteTags added in v0.5.0

func (m Memoized) LsRemoteTags(ctx context.Context, url string) ([]TagRef, error)

LsRemoteTags returns the run's memoized tag listing for url, fetching it once on first use.

func (Memoized) ResolveRef added in v0.5.0

func (m Memoized) ResolveRef(ctx context.Context, url, ref string) (string, error)

ResolveRef returns the run's memoized commit for (url, ref). A full-SHA ref stays uncached: the runner answers it locally.

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

func Fresh(r Runner) Runner

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.

func Memoize added in v0.5.0

func Memoize(r Runner) Runner

Memoize wraps r in a Memoized runner. Idempotent.

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

func (SystemRunner) LsRemoteHeads(ctx context.Context, url string) ([]BranchRef, error)

LsRemoteHeads lists branch heads via "git ls-remote --heads".

func (SystemRunner) LsRemoteTags

func (SystemRunner) LsRemoteTags(ctx context.Context, url string) ([]TagRef, error)

LsRemoteTags lists tags via "git ls-remote --tags", preferring the peeled (^{}) commit for annotated tags.

func (SystemRunner) ResolveRef

func (SystemRunner) ResolveRef(ctx context.Context, url, ref string) (string, error)

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".

type TagRef

type TagRef struct {
	Name   string
	Commit string
}

TagRef pairs a tag name with the commit it resolves to.

Jump to

Keyboard shortcuts

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