Documentation
¶
Overview ¶
Package git wraps local git CLI operations (branch listing, comparison, deletion) used to enrich data fetched from the GitHub API.
Index ¶
- Variables
- type BranchInfo
- type LocalRepo
- func (r *LocalRepo) CompareBranches(base, head string) (int, int, error)
- func (r *LocalRepo) DeleteBranch(branch string, force bool) error
- func (r *LocalRepo) GetCurrentBranch() (string, error)
- func (r *LocalRepo) GetDefaultBranch() (string, error)
- func (r *LocalRepo) GetMergeBase(branch1, branch2 string) (string, error)
- func (r *LocalRepo) IsInsideWorkTree() bool
- func (r *LocalRepo) ListBranches() ([]BranchInfo, error)
Constants ¶
This section is empty.
Variables ¶
var ErrNoBranches = errors.New("no branches found")
ErrNoBranches means the repository has no local branches to fall back to.
var ErrUnexpectedGitOutput = errors.New("unexpected git output")
ErrUnexpectedGitOutput means a git subcommand's output didn't match the format its caller expected to parse.
Functions ¶
This section is empty.
Types ¶
type BranchInfo ¶
type BranchInfo struct {
Name string
SHA string
Ahead int
Behind int
LastCommitDate time.Time
LastCommitMsg string
}
BranchInfo represents information about a branch.
type LocalRepo ¶
type LocalRepo struct {
Path string
}
LocalRepo represents a local Git repository.
func NewLocalRepo ¶
NewLocalRepo creates a new local repository handle.
func (*LocalRepo) CompareBranches ¶
CompareBranches compares two branches and returns ahead/behind counts.
func (*LocalRepo) DeleteBranch ¶
DeleteBranch deletes a branch locally.
func (*LocalRepo) GetCurrentBranch ¶
GetCurrentBranch returns the current branch name.
func (*LocalRepo) GetDefaultBranch ¶
GetDefaultBranch attempts to get the default branch (main or master).
func (*LocalRepo) GetMergeBase ¶
GetMergeBase returns the merge base of two branches.
func (*LocalRepo) IsInsideWorkTree ¶
IsInsideWorkTree checks if the path is inside a Git repository.
func (*LocalRepo) ListBranches ¶
func (r *LocalRepo) ListBranches() ([]BranchInfo, error)
ListBranches lists all local branches.