Documentation
¶
Overview ¶
Package git wraps all git CLI interactions. No other package shells out to git.
Index ¶
- Constants
- func BranchExists(ctx context.Context, dir, branch string) bool
- func CheckoutBranch(ctx context.Context, dir, branch string) error
- func Clone(ctx context.Context, url, dir string) error
- func Commit(ctx context.Context, dir, message string) error
- func ConfigGet(ctx context.Context, dir, key string) (string, error)
- func CreateBranch(ctx context.Context, dir, branch string) error
- func CurrentBranch(ctx context.Context, dir string) (string, error)
- func DetectSpecFromBranch(ctx context.Context, dir string) string
- func Diff(ctx context.Context, dir, baseRef string) (string, error)
- func DiffStaged(ctx context.Context, dir string) (string, error)
- func EnsureSpecsRepo(ctx context.Context, cfg *config.SpecsRepoConfig) (string, error)
- func Fetch(ctx context.Context, dir string) error
- func HasChanges(ctx context.Context, dir string) (bool, error)
- func IsGitRepo(dir string) bool
- func ListArchiveFiles(cfg *config.SpecsRepoConfig, archiveDir string) ([]string, error)
- func ListSpecFiles(cfg *config.SpecsRepoConfig) ([]string, error)
- func ListTriageFiles(cfg *config.SpecsRepoConfig) ([]string, error)
- func Log(ctx context.Context, dir string, n int, format string) (string, error)
- func Push(ctx context.Context, dir, branch string) error
- func PushLocalEdits(ctx context.Context, cfg *config.SpecsRepoConfig, commitMsg string) (bool, error)
- func ReadSpecFile(cfg *config.SpecsRepoConfig, filename string) ([]byte, error)
- func Rebase(ctx context.Context, dir, ref string) error
- func ResetHard(ctx context.Context, dir, ref string) error
- func Run(ctx context.Context, dir string, args ...string) (string, error)
- func SpecBranchName(specID string, stepNumber int, slug string) string
- func SpecFilePath(cfg *config.SpecsRepoConfig, filename string) string
- func SpecsRepoDir(cfg *config.SpecsRepoConfig) string
- func SpecsRepoURL(cfg *config.SpecsRepoConfig) string
- func Status(ctx context.Context, dir string) (string, error)
- func TriageFilePath(cfg *config.SpecsRepoConfig, filename string) string
- func UserEmail(ctx context.Context) string
- func UserName(ctx context.Context) string
- func WithSpecsRepo(ctx context.Context, cfg *config.SpecsRepoConfig, ...) error
- type BranchInfo
Constants ¶
const ( // SpecsSubDir is the sub-directory within the specs repo where spec // files are stored. All spec, triage, and archive content lives under // this path. SpecsSubDir = "specs" )
Variables ¶
This section is empty.
Functions ¶
func BranchExists ¶
BranchExists checks if a branch exists locally.
func CheckoutBranch ¶
CheckoutBranch checks out an existing branch.
func CreateBranch ¶
CreateBranch creates and checks out a new branch.
func CurrentBranch ¶
CurrentBranch returns the current branch name.
func DetectSpecFromBranch ¶
DetectSpecFromBranch attempts to detect the spec ID from the current branch.
func DiffStaged ¶
DiffStaged returns the diff of staged changes.
func EnsureSpecsRepo ¶
EnsureSpecsRepo clones the specs repo if not present, otherwise fetches latest.
func HasChanges ¶
HasChanges returns true if there are uncommitted changes.
func ListArchiveFiles ¶
func ListArchiveFiles(cfg *config.SpecsRepoConfig, archiveDir string) ([]string, error)
ListArchiveFiles returns all archived spec files.
func ListSpecFiles ¶
func ListSpecFiles(cfg *config.SpecsRepoConfig) ([]string, error)
ListSpecFiles returns all spec files in the specs/ directory of the specs repo.
func ListTriageFiles ¶
func ListTriageFiles(cfg *config.SpecsRepoConfig) ([]string, error)
ListTriageFiles returns all triage files in the specs/triage/ directory.
func PushLocalEdits ¶
func PushLocalEdits(ctx context.Context, cfg *config.SpecsRepoConfig, commitMsg string) (bool, error)
PushLocalEdits commits any uncommitted changes in the specs repo and pushes them. Unlike WithSpecsRepo, which resets to remote state before applying a mutation, PushLocalEdits preserves existing local edits — it is the backing implementation for `spec push`. Returns true if changes were found and pushed. On a push conflict it fetches and rebases rather than hard-resetting, preserving the committed local work.
func ReadSpecFile ¶
func ReadSpecFile(cfg *config.SpecsRepoConfig, filename string) ([]byte, error)
ReadSpecFile reads a spec file from the specs repo.
func SpecBranchName ¶
SpecBranchName generates a branch name for a build step.
func SpecFilePath ¶
func SpecFilePath(cfg *config.SpecsRepoConfig, filename string) string
SpecFilePath returns the absolute path to a spec file in the specs repo.
func SpecsRepoDir ¶
func SpecsRepoDir(cfg *config.SpecsRepoConfig) string
SpecsRepoDir returns the local path for the specs repo clone.
func SpecsRepoURL ¶
func SpecsRepoURL(cfg *config.SpecsRepoConfig) string
SpecsRepoURL returns the clone URL for the specs repo. If a token is configured, it is embedded in the URL for passwordless auth.
func TriageFilePath ¶
func TriageFilePath(cfg *config.SpecsRepoConfig, filename string) string
TriageFilePath returns the absolute path to a triage file.
func WithSpecsRepo ¶
func WithSpecsRepo(ctx context.Context, cfg *config.SpecsRepoConfig, mutate func(repoPath string) (commitMsg string, err error)) error
WithSpecsRepo fetches the latest, calls the mutator function, then commits and pushes. If the push fails due to a conflict, it retries up to maxPushRetries times.
Types ¶
type BranchInfo ¶
type BranchInfo struct {
SpecNumber string // e.g., "042"
StepNumber string // e.g., "1"
Slug string // e.g., "token-bucket"
}
BranchInfo represents parsed branch name information.
func ParseSpecBranch ¶
func ParseSpecBranch(branch string) *BranchInfo
ParseSpecBranch extracts spec and step info from a branch name. Returns nil if the branch doesn't match the spec branch pattern.