git

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Feb 21, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DefaultBranch

func DefaultBranch(dir string) string

DefaultBranch returns the current branch name or HEAD.

func IsGitRepo

func IsGitRepo(dir string) bool

IsGitRepo checks whether the given directory is inside a git repository.

func ListBranches

func ListBranches(dir string) ([]string, error)

ListBranches returns all local branch names.

func TotalCommits

func TotalCommits(dir, branch string) int

TotalCommits returns the total number of commits on a branch without loading them all.

Types

type Author

type Author struct {
	Name   string
	Email  string
	Color  lipgloss.Color
	Symbol string
}

Author represents a unique contributor with display attributes.

func (*Author) Badge

func (a *Author) Badge() string

Badge returns the colored symbol badge for this author.

func (*Author) Tag

func (a *Author) Tag() string

Tag returns the full colored "● Name" tag.

type ChangeStatus

type ChangeStatus int

ChangeStatus describes how a file changed in a commit.

const (
	StatusAdded ChangeStatus = iota
	StatusModified
	StatusDeleted
	StatusRenamed
)

func (ChangeStatus) Prefix

func (s ChangeStatus) Prefix() string

Prefix returns the display prefix character for a file change.

func (ChangeStatus) String

func (s ChangeStatus) String() string

type Commit

type Commit struct {
	Hash      string
	ShortHash string
	Author    string
	Email     string
	Timestamp time.Time
	Subject   string
	Body      string
	Index     int // position in the full history (0-based)
}

Commit represents a single git commit.

func LoadHistory

func LoadHistory(dir, branch string, maxCount int) ([]Commit, error)

LoadHistory parses the full git commit log for the given directory and branch. maxCount = 0 means no limit.

func (*Commit) FormattedDate

func (c *Commit) FormattedDate() string

FormattedDate returns a nicely formatted date string.

func (*Commit) RelativeTime

func (c *Commit) RelativeTime() string

RelativeTime returns a human-friendly relative time string.

type CommitStats

type CommitStats struct {
	Files     int
	Additions int
	Deletions int
	Changes   []FileChange
}

CommitStats holds aggregate stats for a commit.

func LoadDiff

func LoadDiff(dir, hash string) (*CommitStats, error)

LoadDiff returns the file changes for a given commit hash. Results are cached in memory.

type FileChange

type FileChange struct {
	Path      string
	OldPath   string // non-empty for renames
	Status    ChangeStatus
	Additions int
	Deletions int
}

FileChange holds change details for one file in a commit.

type Registry

type Registry struct {
	// contains filtered or unexported fields
}

Registry tracks all unique authors encountered in the history.

func BuildRegistry

func BuildRegistry(commits []Commit) *Registry

BuildRegistry walks the full commit history and registers all authors.

func NewRegistry

func NewRegistry() *Registry

NewRegistry creates a fresh author registry.

func (*Registry) All

func (r *Registry) All() []*Author

All returns all authors in registration order.

func (*Registry) Get

func (r *Registry) Get(email string) *Author

Get returns an author by email, or nil.

func (*Registry) Len

func (r *Registry) Len() int

Len returns the number of unique authors.

func (*Registry) Register

func (r *Registry) Register(name, email string) *Author

Register ensures an author is tracked, assigning color+symbol on first encounter.

Jump to

Keyboard shortcuts

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