Documentation
¶
Overview ¶
Package git provides functions for interacting with Git repositories. In Go, package names should be short, lowercase, and descriptive.
Index ¶
- type Repository
- func (r *Repository) CreateWorktree(branch, base, dest string) error
- func (r *Repository) CurrentBranch() (string, error)
- func (r *Repository) DeleteBranch(branch string) error
- func (r *Repository) Fetch() error
- func (r *Repository) FindWorktree(target string) (*WorktreeInfo, error)
- func (r *Repository) GetDefaultWorktreeDir() string
- func (r *Repository) ListBranches() ([]string, error)
- func (r *Repository) ListWorktrees() ([]string, error)
- func (r *Repository) RemoveWorktree(path string, force bool) error
- type WorktreeInfo
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Repository ¶
type Repository struct {
// Root is the absolute path to the repository root
Root string
// RepoName is the name of the repository (e.g., "agentree")
RepoName string
}
Repository represents a Git repository with methods for worktree operations. In Go, we often create types (structs) to group related functionality.
func NewRepository ¶
func NewRepository() (*Repository, error)
NewRepository creates a new Repository instance by finding the Git root. Functions that create new instances often start with "New" in Go.
func (*Repository) CreateWorktree ¶
func (r *Repository) CreateWorktree(branch, base, dest string) error
CreateWorktree creates a new worktree for the given branch. Methods in Go are functions with a receiver (r *Repository)
func (*Repository) CurrentBranch ¶
func (r *Repository) CurrentBranch() (string, error)
CurrentBranch returns the current branch name or HEAD commit
func (*Repository) DeleteBranch ¶
func (r *Repository) DeleteBranch(branch string) error
DeleteBranch deletes a local branch
func (*Repository) Fetch ¶
func (r *Repository) Fetch() error
Fetch runs git fetch to update remote refs
func (*Repository) FindWorktree ¶
func (r *Repository) FindWorktree(target string) (*WorktreeInfo, error)
FindWorktree finds a worktree by branch name or path
func (*Repository) GetDefaultWorktreeDir ¶
func (r *Repository) GetDefaultWorktreeDir() string
GetDefaultWorktreeDir returns the default directory for worktrees
func (*Repository) ListBranches ¶
func (r *Repository) ListBranches() ([]string, error)
ListBranches returns a list of all local branches
func (*Repository) ListWorktrees ¶ added in v1.3.0
func (r *Repository) ListWorktrees() ([]string, error)
ListWorktrees returns a list of all worktree paths
func (*Repository) RemoveWorktree ¶
func (r *Repository) RemoveWorktree(path string, force bool) error
RemoveWorktree removes a worktree
type WorktreeInfo ¶
WorktreeInfo represents information about a worktree