Documentation
¶
Overview ¶
Package git provides Git repository utilities and worktree management.
Index ¶
- Variables
- func AddWorktree(repoRoot, path, branch string, createBranch bool, baseBranch string) error
- func BranchExists(repoRoot, branchName string) (bool, error)
- func GetCurrentBranch(path string) (string, error)
- func GetRepoName() (string, error)
- func GetRepoRoot() (string, error)
- func GetRepoRootFromPath(path string) (string, error)
- func GetStatusSummary(repoRoot string) (string, error)
- func GetWorktreePath(repoRoot, path string) (string, error)
- func IsWorktreeClean(worktreePath string) (bool, string)
- func RemoveWorktree(repoRoot, path string, force bool) error
- func RunGit(repoPath string, args ...string) (string, error)
- func RunGitLines(repoPath string, args ...string) ([]string, error)
- type Worktree
Constants ¶
This section is empty.
Variables ¶
var ErrNotInGitRepo = fmt.Errorf("not in a git repository")
ErrNotInGitRepo is returned when a git repository cannot be found.
Functions ¶
func AddWorktree ¶
AddWorktree creates a new worktree. If createBranch is true, creates a new branch from baseBranch (or HEAD if baseBranch is empty). If createBranch is false, checks out the existing branch.
func BranchExists ¶
BranchExists checks if a branch exists locally or remotely.
func GetCurrentBranch ¶
GetCurrentBranch returns the name of the current branch. Returns empty string if in detached HEAD state. Correctly handles worktrees by using git rev-parse --abbrev-ref HEAD.
func GetRepoName ¶
GetRepoName returns the name of the current git repository.
func GetRepoRoot ¶
GetRepoRoot returns the root directory of the current git repository. Correctly handles worktrees by finding the actual repository root instead of the worktree directory.
func GetRepoRootFromPath ¶
GetRepoRootFromPath returns the root directory of the git repository containing the given path. Uses git rev-parse --show-toplevel.
func GetStatusSummary ¶
GetStatusSummary returns a brief git status summary.
func GetWorktreePath ¶
GetWorktreePath returns the absolute path of a worktree.
func IsWorktreeClean ¶
IsWorktreeClean checks if a worktree has uncommitted changes. Returns (isClean, statusMessage).
func RemoveWorktree ¶
RemoveWorktree removes a worktree.