Documentation
¶
Index ¶
- type Commit
- type Git
- func (g *Git) BranchExists(branch string) bool
- 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) 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) 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) ListWorktrees() ([]Worktree, error)
- 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
- type RebaseResult
- type Worktree
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Git ¶
type Git struct {
RepoDir string
}
Git wraps git operations
func (*Git) BranchExists ¶
BranchExists checks if a local branch exists
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) 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) 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) ListWorktrees ¶
ListWorktrees lists all worktrees
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)
type RebaseResult ¶
RebaseResult contains the result of a rebase operation