Documentation
¶
Index ¶
- func ValidateBranchName(name string) error
- type Commit
- type Git
- func (g *Git) BranchExists(branch string) bool
- func (g *Git) CheckoutBranch(branchName string) error
- func (g *Git) CreateBranchOnly(branchName, baseBranch string) error
- func (g *Git) CreateWorktree(branchName, worktreePath, baseBranch string) error
- func (g *Git) CurrentBranch() (string, error)
- func (g *Git) DeleteBranch(branchName string, force bool) error
- func (g *Git) Fetch() error
- func (g *Git) FindEzstackStash(branchName string) (int, bool)
- func (g *Git) GetBranchCommit(branch string) (string, error)
- func (g *Git) GetCommitCount(base, head string) (int, error)
- func (g *Git) GetCommitsAhead(branch, target string) (int, error)
- func (g *Git) GetCommitsBehind(branch, target string) (int, error)
- func (g *Git) GetCommitsBetween(base, head string) ([]Commit, error)
- func (g *Git) GetLastCommitMessage() (string, error)
- func (g *Git) GetMainWorktree() (string, error)
- func (g *Git) GetMergeBase(branch1, branch2 string) (string, error)
- func (g *Git) GetPRTemplate() string
- func (g *Git) GetRemote(name string) (string, error)
- func (g *Git) GetRepoRoot() (string, error)
- func (g *Git) HasChanges() (bool, error)
- func (g *Git) HasDivergedFromOrigin(branch string) (bool, int, int, error)
- func (g *Git) IsBranchMerged(branch, target string) (bool, error)
- func (g *Git) IsLocalAheadOfOrigin(branch string) (bool, error)
- func (g *Git) IsRebaseInProgress() (bool, error)
- func (g *Git) ListLocalBranches() ([]string, error)
- func (g *Git) ListWorktrees() ([]Worktree, error)
- func (g *Git) Merge(target string) error
- func (g *Git) MergeNonInteractive(target string) RebaseResult
- func (g *Git) PruneWorktrees() error
- func (g *Git) Push(force bool) error
- func (g *Git) PushForce() error
- func (g *Git) PushSetUpstream() error
- func (g *Git) Rebase(target string) error
- func (g *Git) RebaseNonInteractive(target string) RebaseResult
- func (g *Git) RebaseOntoNonInteractive(newBase, oldBase string) RebaseResult
- func (g *Git) RemoteBranchExists(branch string) bool
- func (g *Git) RemoveWorktree(worktreePath string, deleteBranch bool, branchName string) error
- func (g *Git) ResetHard(ref string) error
- func (g *Git) RunInteractive(args ...string) error
- func (g *Git) StashPop() error
- func (g *Git) StashPopIndex(index int) error
- func (g *Git) StashPush() error
- type RebaseResult
- type Worktree
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ValidateBranchName ¶ added in v1.5.0
ValidateBranchName checks if a name is valid for a git branch.
Types ¶
type Git ¶
type Git struct {
RepoDir string
}
Git wraps git operations
func (*Git) BranchExists ¶
BranchExists checks if a local branch exists
func (*Git) CheckoutBranch ¶ added in v1.1.1
CheckoutBranch switches to an existing branch
func (*Git) CreateBranchOnly ¶ added in v1.1.1
CreateBranchOnly creates a new branch without a worktree
func (*Git) CreateWorktree ¶
CreateWorktree creates a new worktree
func (*Git) CurrentBranch ¶
CurrentBranch returns the current branch name
func (*Git) DeleteBranch ¶
DeleteBranch deletes a local git branch
func (*Git) FindEzstackStash ¶ added in v1.7.0
FindEzstackStash finds the stash index of an ezstack autostash entry for a specific branch. Git stash entries look like: "stash@{N}: On <branch>: ezstack-autostash" Returns (index, true) if found, (-1, false) if not found. Matches both branch name and message to avoid touching stashes from other worktrees.
func (*Git) GetBranchCommit ¶
GetBranchCommit gets the commit hash of a branch
func (*Git) GetCommitCount ¶
GetCommitCount returns the number of commits between base and head This is useful to check if a branch has any commits of its own
func (*Git) GetCommitsAhead ¶
GetCommitsAhead returns the number of commits branch is ahead of target
func (*Git) GetCommitsBehind ¶
GetCommitsBehind returns the number of commits branch is behind target
func (*Git) GetCommitsBetween ¶
GetCommitsBetween returns commits between base and head (exclusive of base)
func (*Git) GetLastCommitMessage ¶
GetLastCommitMessage returns the message of the last commit on the current branch
func (*Git) GetMainWorktree ¶
GetMainWorktree returns the path to the main worktree
func (*Git) GetMergeBase ¶
GetMergeBase finds the common ancestor between two branches
func (*Git) GetPRTemplate ¶
GetPRTemplate finds and reads the GitHub PR template from common locations. Returns the template content or empty string if no template is found. GitHub looks for templates in these locations (in order of priority): - .github/pull_request_template.md - .github/PULL_REQUEST_TEMPLATE.md - docs/pull_request_template.md - pull_request_template.md - PULL_REQUEST_TEMPLATE.md
func (*Git) GetRepoRoot ¶
GetRepoRoot returns the root directory of the git repository
func (*Git) HasChanges ¶ added in v1.1.1
HasChanges returns true if the working directory has uncommitted changes
func (*Git) HasDivergedFromOrigin ¶
HasDivergedFromOrigin checks if local and remote branches have diverged Returns (hasDiverged, localAhead, remoteBehind, error) hasDiverged is true if both local has commits not in remote AND remote has commits not in local
func (*Git) IsBranchMerged ¶
IsBranchMerged checks if a branch has been merged into target
func (*Git) IsLocalAheadOfOrigin ¶
IsLocalAheadOfOrigin checks if the local branch has commits not in origin Returns true if local is ahead (needs push), false if in sync or behind
func (*Git) IsRebaseInProgress ¶
IsRebaseInProgress checks if a rebase is in progress
func (*Git) ListLocalBranches ¶ added in v1.0.0
ListLocalBranches returns all local branch names
func (*Git) ListWorktrees ¶
ListWorktrees lists all worktrees
func (*Git) MergeNonInteractive ¶ added in v1.7.0
func (g *Git) MergeNonInteractive(target string) RebaseResult
MergeNonInteractive merges target into the current branch without interactive mode Returns structured result for conflict handling, matching RebaseResult for compatibility
func (*Git) PruneWorktrees ¶
PruneWorktrees prunes stale worktree metadata from git
func (*Git) PushForce ¶
PushForce force pushes the current branch with lease (safer than --force) Explicitly specifies origin and branch name to handle branches without upstream
func (*Git) PushSetUpstream ¶
PushSetUpstream pushes and sets upstream
func (*Git) RebaseNonInteractive ¶
func (g *Git) RebaseNonInteractive(target string) RebaseResult
RebaseNonInteractive rebases current branch onto target without interactive mode Returns structured result instead of just error for better conflict handling
func (*Git) RebaseOntoNonInteractive ¶
func (g *Git) RebaseOntoNonInteractive(newBase, oldBase string) RebaseResult
RebaseOntoNonInteractive rebases commits from oldBase to current onto newBase Returns structured result for better conflict handling
func (*Git) RemoteBranchExists ¶
RemoteBranchExists checks if a remote branch exists
func (*Git) RemoveWorktree ¶
RemoveWorktree removes a worktree and optionally deletes the branch
func (*Git) ResetHard ¶
ResetHard performs a hard reset to the given ref This is used to fast-forward a branch that has no commits of its own
func (*Git) RunInteractive ¶
RunInteractive runs a git command interactively (for rebase with conflicts)
func (*Git) StashPop ¶ added in v1.1.1
StashPop pops the ezstack autostash entry for the current branch. Uses targeted lookup to avoid popping user stashes or stashes from other branches. Returns nil if no ezstack stash is found (nothing to pop).
func (*Git) StashPopIndex ¶ added in v1.7.0
StashPopIndex pops a specific stash entry by index.
type RebaseResult ¶
RebaseResult contains the result of a rebase operation