Documentation
¶
Overview ¶
Package git provides git worktree operations for agent-deck
Index ¶
- func BranchExists(repoDir, branchName string) bool
- func CreateWorktree(repoDir, worktreePath, branchName string) error
- func GenerateWorktreePath(repoDir, branchName, location string) string
- func GetCurrentBranch(dir string) (string, error)
- func GetMainWorktreePath(dir string) (string, error)
- func GetRepoRoot(dir string) (string, error)
- func GetWorktreeForBranch(repoDir, branchName string) (string, error)
- func IsGitRepo(dir string) bool
- func IsWorktree(dir string) bool
- func RemoveWorktree(repoDir, worktreePath string, force bool) error
- func SanitizeBranchName(name string) string
- func ValidateBranchName(name string) error
- type Worktree
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func BranchExists ¶
BranchExists checks if a branch exists in the repository
func CreateWorktree ¶
CreateWorktree creates a new git worktree at worktreePath for the given branch If the branch doesn't exist, it will be created
func GenerateWorktreePath ¶
GenerateWorktreePath generates a worktree directory path based on the repository directory, branch name, and location strategy. Location "subdirectory" places worktrees under <repo>/.worktrees/<branch>. Location "sibling" (or empty) places worktrees as <repo>-<branch> alongside the repo.
func GetCurrentBranch ¶
GetCurrentBranch returns the current branch name for the repository at dir
func GetMainWorktreePath ¶
GetMainWorktreePath returns the path to the main worktree (original clone)
func GetRepoRoot ¶
GetRepoRoot returns the root directory of the git repository containing dir
func GetWorktreeForBranch ¶
GetWorktreeForBranch returns the worktree path for a given branch, if any
func IsWorktree ¶
IsWorktree checks if the given directory is a git worktree (not the main repo)
func RemoveWorktree ¶
RemoveWorktree removes a worktree from the repository If force is true, it will remove even if there are uncommitted changes
func SanitizeBranchName ¶
SanitizeBranchName converts a string to a valid branch name
func ValidateBranchName ¶
ValidateBranchName validates that a branch name follows git's naming rules
Types ¶
type Worktree ¶
type Worktree struct {
Path string // Filesystem path to the worktree
Branch string // Branch name checked out in this worktree
Commit string // HEAD commit SHA
Bare bool // Whether this is the bare repository
}
Worktree represents a git worktree
func ListWorktrees ¶
ListWorktrees returns all worktrees for the repository at repoDir