gitrepo

package
v0.1.4 Latest Latest
Warning

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

Go to latest
Published: Sep 11, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package gitrepo is a thin wrapper over the system git binary.

Shelling out to real git is deliberate. A reimplementation (go-git and friends) would produce diffs that differ in formatting and rename detection from what the reviewer sees when they run git themselves, and linking a C library would reintroduce the runtime dependency this tool exists without. Requiring git on PATH costs nothing: without a repository there is nothing for jaira to operate on.

Index

Constants

This section is empty.

Variables

View Source
var ErrNoGit = errors.New("gitrepo: git is not available on PATH")

ErrNoGit means the git binary is unavailable.

Functions

func Available

func Available() bool

Available reports whether git can be used at all.

Types

type Commit

type Commit struct {
	SHA     string `json:"sha"`
	Short   string `json:"short"`
	Subject string `json:"subject"`
	Author  string `json:"author"`
	Date    string `json:"date"`
}

Commit describes one commit for display on a ticket.

type Repo

type Repo struct{ Dir string }

Repo is a git working tree.

func (*Repo) Commits

func (r *Repo) Commits(shas []string) ([]Commit, error)

Commits resolves metadata for the SHAs recorded on a ticket. Unknown SHAs are returned with empty metadata rather than dropped, so a ticket referencing a commit from an unfetched branch still shows what it claims.

func (*Repo) CommitsForTicket added in v0.1.1

func (r *Repo) CommitsForTicket(ticketPath, ticketID string) ([]string, error)

CommitsForTicket works out which commits carry a ticket, so a person never has to type a sha by hand for the tool to know it. The result is the union of two independent sources, because neither alone finds every commit that belongs to a ticket: a commit can touch the ticket file without naming the ticket in its message (a rename, a bulk edit), and a commit can name the ticket without touching its file (the source change the ticket describes). The returned shas are oldest-first, since the recorded list is read as the history of the ticket and every caller records it the same way.

func (*Repo) Diff

func (r *Repo) Diff(shas []string) (string, error)

Diff returns the combined patch for a set of commits, scoped to those commits rather than to the working tree — a reviewer is judging what the ticket shipped, not whatever happens to be uncommitted right now.

func (*Repo) HeadSHA

func (r *Repo) HeadSHA() (string, error)

HeadSHA returns the current commit.

func (*Repo) IsRepo

func (r *Repo) IsRepo() bool

IsRepo reports whether Dir is inside a git working tree.

func (*Repo) Root

func (r *Repo) Root() (string, error)

Root returns the working tree root.

func (*Repo) Stat

func (r *Repo) Stat(shas []string) (string, error)

Stat returns the per-file summary for a set of commits.

Jump to

Keyboard shortcuts

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