git

package
v0.4.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: 11 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.

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

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