Documentation
¶
Overview ¶
internal/git/git.go
Index ¶
- Variables
- type Commit
- type Git
- func (g *Git) BranchExists(branch string) bool
- func (g *Git) Checkout(branch string) error
- func (g *Git) Commit(message string) error
- func (g *Git) CommitExists(sha string) bool
- func (g *Git) CreateAndCheckout(name string) error
- func (g *Git) CreateBranch(name string) error
- func (g *Git) CurrentBranch() (string, error)
- func (g *Git) DeleteBranch(branch string) error
- func (g *Git) FastForward(branch string) error
- func (g *Git) Fetch() error
- func (g *Git) GetCommits(base, head string) ([]Commit, error)
- func (g *Git) GetGitDir() string
- func (g *Git) GetMergeBase(a, b string) (string, error)
- func (g *Git) GetTip(branch string) (string, error)
- func (g *Git) HasStagedChanges() (bool, error)
- func (g *Git) HasUnmergedCommits(branch, upstream string) (bool, error)
- func (g *Git) IsContentMerged(branch, upstream string) (bool, error)
- func (g *Git) IsDirty() (bool, error)
- func (g *Git) IsRebaseInProgress() bool
- func (g *Git) NeedsRebase(branch, parent string) (bool, error)
- func (g *Git) Push(branch string, force bool) error
- func (g *Git) Rebase(onto string) error
- func (g *Git) RebaseAbort() error
- func (g *Git) RebaseContinue() error
- func (g *Git) RebaseOnto(newBase, oldBase, branch string) error
- func (g *Git) RemoteBranchExists(branch string) bool
Constants ¶
This section is empty.
Variables ¶
var ErrDirtyWorkTree = errors.New("working tree has uncommitted changes")
ErrDirtyWorkTree is returned when the working tree has uncommitted changes.
Functions ¶
This section is empty.
Types ¶
type Commit ¶
type Commit struct {
Subject string // First line of the commit message
Body string // Everything after the first line (may be empty)
}
Commit represents a git commit with its subject and body.
type Git ¶
type Git struct {
// contains filtered or unexported fields
}
Git provides git operations for a repository.
func (*Git) BranchExists ¶
BranchExists checks if a branch exists.
func (*Git) CommitExists ¶
CommitExists checks if a commit SHA exists in the repository.
func (*Git) CreateAndCheckout ¶
CreateAndCheckout creates a new branch and switches to it.
func (*Git) CreateBranch ¶
CreateBranch creates a new branch at the current HEAD.
func (*Git) CurrentBranch ¶
CurrentBranch returns the name of the current branch.
func (*Git) DeleteBranch ¶
DeleteBranch deletes a local branch.
func (*Git) FastForward ¶
FastForward fast-forwards a branch to its remote tracking branch.
func (*Git) GetCommits ¶
GetCommits returns the commits from base..head (commits in head not in base). Returns commits in reverse chronological order (newest first).
func (*Git) GetMergeBase ¶
GetMergeBase returns the merge base of two branches.
func (*Git) HasStagedChanges ¶
HasStagedChanges returns true if there are staged changes.
func (*Git) HasUnmergedCommits ¶
HasUnmergedCommits returns true if the branch has commits not yet in upstream. Uses git cherry to detect by diff content, which works for cherry-picks where the commit SHAs differ but the content is the same. Note: This does NOT detect squash merges where multiple commits are combined. Use IsContentMerged for squash merge detection.
func (*Git) IsContentMerged ¶
IsContentMerged returns true if the branch has no content differences from upstream. This detects squash merges where the tree content is identical even though the commit history differs. Returns true if `git diff upstream branch` is empty.
func (*Git) IsRebaseInProgress ¶
IsRebaseInProgress checks if a rebase is in progress.
func (*Git) NeedsRebase ¶
NeedsRebase returns true if branch needs to be rebased onto parent.
func (*Git) RebaseAbort ¶
RebaseAbort aborts an in-progress rebase.
func (*Git) RebaseContinue ¶
RebaseContinue continues an in-progress rebase.
func (*Git) RebaseOnto ¶
RebaseOnto rebases a branch onto a new base, replaying only commits after oldBase. Checks out the branch first, then runs: git rebase --onto <newBase> <oldBase> Useful when a parent branch was squash-merged and we need to replay only the commits unique to the child branch.
func (*Git) RemoteBranchExists ¶
RemoteBranchExists checks if a branch exists on the remote (origin).