git

package
v0.7.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 20, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

Package git wraps local git CLI operations (branch listing, comparison, deletion) used to enrich data fetched from the GitHub API.

Index

Constants

This section is empty.

Variables

View Source
var ErrNoBranches = errors.New("no branches found")

ErrNoBranches means the repository has no local branches to fall back to.

View Source
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

func NewLocalRepo(path string) *LocalRepo

NewLocalRepo creates a new local repository handle.

func (*LocalRepo) CompareBranches

func (r *LocalRepo) CompareBranches(base, head string) (int, int, error)

CompareBranches compares two branches and returns ahead/behind counts.

func (*LocalRepo) DeleteBranch

func (r *LocalRepo) DeleteBranch(branch string, force bool) error

DeleteBranch deletes a branch locally.

func (*LocalRepo) GetCurrentBranch

func (r *LocalRepo) GetCurrentBranch() (string, error)

GetCurrentBranch returns the current branch name.

func (*LocalRepo) GetDefaultBranch

func (r *LocalRepo) GetDefaultBranch() (string, error)

GetDefaultBranch attempts to get the default branch (main or master).

func (*LocalRepo) GetMergeBase

func (r *LocalRepo) GetMergeBase(branch1, branch2 string) (string, error)

GetMergeBase returns the merge base of two branches.

func (*LocalRepo) IsInsideWorkTree

func (r *LocalRepo) IsInsideWorkTree() bool

IsInsideWorkTree checks if the path is inside a Git repository.

func (*LocalRepo) ListBranches

func (r *LocalRepo) ListBranches() ([]BranchInfo, error)

ListBranches lists all local branches.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL