git

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Feb 24, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package git wraps git CLI operations behind a testable interface.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type RealRunner

type RealRunner struct {
	Log *slog.Logger
}

RealRunner shells out to the git binary.

func (*RealRunner) AddWorktree

func (r *RealRunner) AddWorktree(ctx context.Context, bareRepo, worktreePath, branch string) error

AddWorktree creates a worktree from a bare repo at the given path and branch.

func (*RealRunner) AddWorktreeNewBranch

func (r *RealRunner) AddWorktreeNewBranch(ctx context.Context, bareRepo, worktreePath, newBranch, startPoint string) error

AddWorktreeNewBranch creates a worktree with a new branch starting from startPoint.

func (*RealRunner) BareClone

func (r *RealRunner) BareClone(ctx context.Context, url, dest string) error

BareClone creates a bare clone of a repository.

func (*RealRunner) BranchExists

func (r *RealRunner) BranchExists(ctx context.Context, bareRepo, branch string) (bool, error)

BranchExists checks if a branch exists in the bare repo (local or remote ref).

func (*RealRunner) DefaultBranch

func (r *RealRunner) DefaultBranch(ctx context.Context, bareRepo string) (string, error)

DefaultBranch returns the default branch name (e.g. "main" or "master") for a bare repo.

func (*RealRunner) Fetch

func (r *RealRunner) Fetch(ctx context.Context, repoPath string) error

Fetch fetches all refs in a bare repository.

func (*RealRunner) RemoveWorktree

func (r *RealRunner) RemoveWorktree(ctx context.Context, bareRepo, worktreePath string) error

RemoveWorktree removes a worktree from a bare repo.

type Runner

type Runner interface {
	BareClone(ctx context.Context, url, dest string) error
	Fetch(ctx context.Context, repoPath string) error
	AddWorktree(ctx context.Context, bareRepo, worktreePath, branch string) error
	AddWorktreeNewBranch(ctx context.Context, bareRepo, worktreePath, newBranch, startPoint string) error
	RemoveWorktree(ctx context.Context, bareRepo, worktreePath string) error
	BranchExists(ctx context.Context, bareRepo, branch string) (bool, error)
	DefaultBranch(ctx context.Context, bareRepo string) (string, error)
}

Runner abstracts git operations for testability.

Jump to

Keyboard shortcuts

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