gitrepo

package
v0.4.3 Latest Latest
Warning

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

Go to latest
Published: Oct 13, 2026 License: MIT Imports: 9 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, []string)

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.

The second return names the shas git could not show: rebased away, cherry-picked elsewhere, or on a branch this clone never fetched. They stay in the patch as a placeholder line, but a caller counting commits would otherwise report them as diffs it had shown — the same fraction-reported-whole failure this package was fixed for. There is no error return because there is no failure: an unshowable sha is an outcome, not a broken repository.

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.

func (*Repo) Tracks added in v0.4.0

func (r *Repo) Tracks(path string) bool

Tracks reports whether git tracks at least one file under path, relative to Dir. Outside a repository, or without git, nothing is tracked.

func (*Repo) WorktreeDiff added in v0.3.1

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

WorktreeDiff returns the patch for work that is not committed yet: every tracked change against HEAD, staged or not, followed by every untracked file in full.

A lane judges what is in front of it, and on a conversational ticket — where the worker hands back a commit line instead of committing — that is the worktree and not the commits. The rule "a lane that changed no code commits nothing" leaves work lying there on an autonomous board too, so this is not a conversational-mode special case. Telling the reviewer to go and look for it by hand is the same hand instruction this file's Diff comment exists to have removed.

.jaira/tickets is excluded on purpose: the worker rewrites the ticket file with every 'jaira dod' and every 'jaira note', so including it would bury the few lines of code under the ticket's own prose — prose the payload already carries as goal, definition-of-done and notes. ",top" anchors the exclusion at the repository root so it holds whatever directory Dir is.

Jump to

Keyboard shortcuts

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