git

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Jul 30, 2026 License: MPL-2.0 Imports: 10 Imported by: 0

Documentation

Overview

Package git wraps go-git with the helpers uda needs (commit ranges, repo IDs, changed files).

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CommitDetail

type CommitDetail struct {
	SHA       string
	Message   string
	Timestamp time.Time
	Files     []FileChange
}

CommitDetail holds full commit info with file-level stats.

type CommitFiles

type CommitFiles struct {
	SHA   string
	Files []string // Paths relative to repo root
}

CommitFiles holds files changed in a single commit.

type CommitRange

type CommitRange struct {
	From *plumbing.Hash // nil means "from beginning"
	To   plumbing.Hash
}

CommitRange represents a range of commits to analyze.

func ParseCommitRange

func ParseCommitRange(repo *Repository, rangeStr string) (*CommitRange, error)

ParseCommitRange parses a commit range string. Supported formats:

  • "abc123" - single commit
  • "abc123..def456" - range from abc123 (exclusive) to def456 (inclusive)

type FileChange

type FileChange struct {
	Path      string
	Additions int
	Deletions int
}

FileChange holds change stats for a single file.

type Repository

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

Repository wraps a go-git repository with additional utilities.

func OpenRepository

func OpenRepository(path string) (*Repository, error)

OpenRepository opens a git repository at the given path. Returns an error if the path is not a git repository.

func (*Repository) CommitChangedFiles

func (r *Repository) CommitChangedFiles(hashes []plumbing.Hash) ([]CommitFiles, error)

CommitChangedFiles returns the files changed in each commit.

func (*Repository) CommitDetails

func (r *Repository) CommitDetails(hashes []plumbing.Hash) ([]CommitDetail, error)

CommitDetails returns detailed commit info with file stats.

func (*Repository) Commits

func (r *Repository) Commits(commitRange *CommitRange) ([]plumbing.Hash, error)

Commits returns the list of commits in the range, ordered from oldest to newest. For a single commit (From == nil and no ".." in original), returns just that commit. For a range, returns commits from From (exclusive) to To (inclusive). If the range is backwards (From is not an ancestor of To), it automatically flips.

func (*Repository) CommitsSince

func (r *Repository) CommitsSince(d time.Duration) ([]plumbing.Hash, error)

CommitsSince returns commits from the last d duration, oldest first.

func (*Repository) CommitsWithin

func (r *Repository) CommitsWithin(d time.Duration, end time.Time) ([]plumbing.Hash, error)

CommitsWithin returns commits in the window [end-d, end], oldest first. An explicit end keeps history-derived analyses anchored to the data (e.g. a review head's commit time) instead of the wall clock.

func (*Repository) Repo

func (r *Repository) Repo() *git.Repository

Repo returns the underlying go-git repository.

func (*Repository) RepoID

func (r *Repository) RepoID() string

RepoID returns a unique identifier for the repository. This is a hash of the origin URL if available, otherwise a hash of the path.

func (*Repository) ResolveCommit

func (r *Repository) ResolveCommit(commitish string) (plumbing.Hash, error)

ResolveCommit resolves a commit-ish string (e.g., "HEAD", "main", "abc123") to a concrete commit hash.

func (*Repository) RootPath

func (r *Repository) RootPath() string

RootPath returns the root path of the repository.

func (*Repository) WorkingTreeChangedFiles

func (r *Repository) WorkingTreeChangedFiles() ([]string, error)

WorkingTreeChangedFiles returns the paths (relative to the repo root) that differ between the working tree and HEAD, including staged and untracked files.

Jump to

Keyboard shortcuts

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