Documentation
¶
Index ¶
- type RealExecutor
- func (e *RealExecutor) BranchExists(name string) bool
- func (e *RealExecutor) CreateWorktreeWithContext(ctx context.Context, path, newBranch, baseBranch string) error
- func (e *RealExecutor) DetermineWorktreePath(sessionID string) (string, error)
- func (e *RealExecutor) GetCommitDiff(hash string) (string, error)
- func (e *RealExecutor) GetCommitLog(limit int) ([]domain.CommitInfo, error)
- func (e *RealExecutor) GetCommitLogForRef(ref string, limit int) ([]domain.CommitInfo, error)
- func (e *RealExecutor) GetCurrentBranch() (string, error)
- func (e *RealExecutor) GetDiff(ref string) (string, error)
- func (e *RealExecutor) GetDiffStat(ref string) (string, error)
- func (e *RealExecutor) GetFileContent(path string) (string, error)
- func (e *RealExecutor) GetFileDiff(ref, path string) (string, error)
- func (e *RealExecutor) GetMainBranch() (string, error)
- func (e *RealExecutor) GetRemoteURL(name string) (string, error)
- func (e *RealExecutor) GetRepoRoot() (string, error)
- func (e *RealExecutor) GetUntrackedFiles() ([]string, error)
- func (e *RealExecutor) GetWorkingDirDiff() (string, error)
- func (e *RealExecutor) HasUncommittedChanges() (bool, error)
- func (e *RealExecutor) IsBareRepo() (bool, error)
- func (e *RealExecutor) IsDetachedHead() (bool, error)
- func (e *RealExecutor) IsGitRepo() bool
- func (e *RealExecutor) IsOnMainBranch() (bool, error)
- func (e *RealExecutor) IsWorktree() (bool, error)
- func (e *RealExecutor) ListBranches() ([]domain.BranchInfo, error)
- func (e *RealExecutor) ListWorktrees() ([]domain.WorktreeInfo, error)
- func (e *RealExecutor) PruneWorktrees() error
- func (e *RealExecutor) RemoveWorktree(path string) error
- func (e *RealExecutor) ValidateBranchName(name string) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type RealExecutor ¶
type RealExecutor struct {
// contains filtered or unexported fields
}
RealExecutor implements GitExecutor by executing actual git commands.
func NewRealExecutor ¶
func NewRealExecutor(workDir string) *RealExecutor
NewRealExecutor creates a new RealExecutor.
func (*RealExecutor) BranchExists ¶
func (e *RealExecutor) BranchExists(name string) bool
BranchExists checks if a branch with the given name exists.
func (*RealExecutor) CreateWorktreeWithContext ¶
func (e *RealExecutor) CreateWorktreeWithContext(ctx context.Context, path, newBranch, baseBranch string) error
CreateWorktreeWithContext creates a new worktree at the specified path with context support. If branch is empty, creates a new branch based on HEAD. The context can be used to cancel/timeout the operation. Returns domain.ErrWorktreeTimeout if the context deadline is exceeded.
func (*RealExecutor) DetermineWorktreePath ¶
func (e *RealExecutor) DetermineWorktreePath(sessionID string) (string, error)
DetermineWorktreePath determines the best path for a new worktree. Strategy: prefer sibling directory, fallback to .perles/worktrees/
func (*RealExecutor) GetCommitDiff ¶
func (e *RealExecutor) GetCommitDiff(hash string) (string, error)
GetCommitDiff returns the diff for a specific commit (what changed in that commit). Uses git show to get the commit's patch. Uses a 5-second timeout to prevent hanging on large repos.
func (*RealExecutor) GetCommitLog ¶
func (e *RealExecutor) GetCommitLog(limit int) ([]domain.CommitInfo, error)
GetCommitLog returns the most recent commits, up to the specified limit. Uses a 5-second timeout to prevent hanging on large repos. Returns an empty slice for empty repositories. Also detects which commits have been pushed to the remote tracking branch.
func (*RealExecutor) GetCommitLogForRef ¶
func (e *RealExecutor) GetCommitLogForRef(ref string, limit int) ([]domain.CommitInfo, error)
GetCommitLogForRef returns commit history for a specific ref (branch, tag, etc.). If ref is empty, returns commits for HEAD. Uses a 5-second timeout to prevent hanging on large repos. Returns an empty slice for empty repositories. Also detects which commits have been pushed to the remote tracking branch.
func (*RealExecutor) GetCurrentBranch ¶
func (e *RealExecutor) GetCurrentBranch() (string, error)
GetCurrentBranch returns the name of the current branch. Returns domain.ErrDetachedHead if HEAD is not pointing to a branch (common in CI).
func (*RealExecutor) GetDiff ¶
func (e *RealExecutor) GetDiff(ref string) (string, error)
GetDiff returns the unified diff output for the given ref. Uses a 5-second timeout to prevent hanging on large repos.
func (*RealExecutor) GetDiffStat ¶
func (e *RealExecutor) GetDiffStat(ref string) (string, error)
GetDiffStat returns the --numstat output for the given ref. Format: "additions\tdeletions\tpath" per line. Uses a 5-second timeout to prevent hanging on large repos.
func (*RealExecutor) GetFileContent ¶
func (e *RealExecutor) GetFileContent(path string) (string, error)
GetFileContent returns the content of a file in the working directory. Used for displaying untracked files that have no diff.
func (*RealExecutor) GetFileDiff ¶
func (e *RealExecutor) GetFileDiff(ref, path string) (string, error)
GetFileDiff returns the diff for a single file against the given ref. Uses a 5-second timeout to prevent hanging on large repos.
func (*RealExecutor) GetMainBranch ¶
func (e *RealExecutor) GetMainBranch() (string, error)
GetMainBranch detects the main branch name using multiple strategies. Order: config → remote HEAD → main/master existence → fallback to "main"
func (*RealExecutor) GetRemoteURL ¶
func (e *RealExecutor) GetRemoteURL(name string) (string, error)
GetRemoteURL returns the URL for the named remote (e.g., "origin"). Returns empty string and nil error if remote doesn't exist.
func (*RealExecutor) GetRepoRoot ¶
func (e *RealExecutor) GetRepoRoot() (string, error)
GetRepoRoot returns the root directory of the git repository.
func (*RealExecutor) GetUntrackedFiles ¶
func (e *RealExecutor) GetUntrackedFiles() ([]string, error)
GetUntrackedFiles returns the list of untracked files (new files not yet staged). Uses a 5-second timeout to prevent hanging on large repos.
func (*RealExecutor) GetWorkingDirDiff ¶
func (e *RealExecutor) GetWorkingDirDiff() (string, error)
GetWorkingDirDiff returns the diff of uncommitted changes (staged + unstaged vs HEAD). Uses a 5-second timeout to prevent hanging on large repos.
func (*RealExecutor) HasUncommittedChanges ¶
func (e *RealExecutor) HasUncommittedChanges() (bool, error)
HasUncommittedChanges checks if there are uncommitted changes in the working directory.
func (*RealExecutor) IsBareRepo ¶
func (e *RealExecutor) IsBareRepo() (bool, error)
IsBareRepo checks if the repository is a bare repository.
func (*RealExecutor) IsDetachedHead ¶
func (e *RealExecutor) IsDetachedHead() (bool, error)
IsDetachedHead checks if HEAD is detached (not on a branch).
func (*RealExecutor) IsGitRepo ¶
func (e *RealExecutor) IsGitRepo() bool
IsGitRepo checks if the current directory is a git repository.
func (*RealExecutor) IsOnMainBranch ¶
func (e *RealExecutor) IsOnMainBranch() (bool, error)
IsOnMainBranch returns true if the current branch is the main branch. Returns false (not error) if in detached HEAD state.
func (*RealExecutor) IsWorktree ¶
func (e *RealExecutor) IsWorktree() (bool, error)
IsWorktree checks if the current directory is inside a git worktree (not the main repo).
func (*RealExecutor) ListBranches ¶
func (e *RealExecutor) ListBranches() ([]domain.BranchInfo, error)
ListBranches returns all local branches, sorted with current branch first then alphabetically.
func (*RealExecutor) ListWorktrees ¶
func (e *RealExecutor) ListWorktrees() ([]domain.WorktreeInfo, error)
ListWorktrees returns information about all worktrees.
func (*RealExecutor) PruneWorktrees ¶
func (e *RealExecutor) PruneWorktrees() error
PruneWorktrees removes stale worktree references.
func (*RealExecutor) RemoveWorktree ¶
func (e *RealExecutor) RemoveWorktree(path string) error
RemoveWorktree removes a worktree at the specified path.
func (*RealExecutor) ValidateBranchName ¶
func (e *RealExecutor) ValidateBranchName(name string) error
ValidateBranchName validates a branch name using git check-ref-format --branch. Returns nil if valid, domain.ErrInvalidBranchName if invalid.