gitmeta

package
v1.5.1 Latest Latest
Warning

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

Go to latest
Published: Jul 25, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

Package gitmeta collects pull-request cost-attribution metadata from local git, for Goei's cost-per-PR view. It is opt-in (budgetclaw prs on) and content-free: it reads only branch names, merge/squash commit subjects (for the PR number), commit counts, and numstat diff sizes. It never reads commit message bodies, code, or diffs content. Every git invocation is read-only, time-bounded, and non-fatal: a directory that is not a git repo, or a machine without git, simply yields nothing.

The join back to spend is by (project, branch): budgetclaw already sends spend keyed by project (basename of the working directory) and git branch, so a PR record tagged with the same (project, branch) lets Goei sum that branch's local spend as the PR's cost.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type PRRecord

type PRRecord struct {
	Project   string `json:"project"`
	Branch    string `json:"branch,omitempty"`
	PR        int    `json:"pr,omitempty"`
	Base      string `json:"base,omitempty"`
	State     string `json:"state"`
	MergedAt  string `json:"mergedAt,omitempty"`
	Commits   int    `json:"commits"`
	Additions int    `json:"additions"`
	Deletions int    `json:"deletions"`
}

PRRecord is one pull request (or in-flight branch) with the metadata needed to attribute cost to it. State is "merged" (a merge commit named the branch and PR), "squashed" (a squash-merge commit on the base branch carried the PR number, but the head branch is gone so cost cannot be joined by branch), or "open" (a local branch with spend that is not yet merged).

func Collect

func Collect(ctx context.Context, keys []SpendKey, since time.Time) []PRRecord

Collect returns PR records for the repositories the spend keys point at. since bounds how far back merged/squashed PRs are considered, keeping git work proportional to the sync window.

type SpendKey

type SpendKey struct {
	Project string
	Branch  string
	CWD     string
}

SpendKey is one (project, branch) that had spend, with a working directory to locate its repository. Mirrors db.RepoSpendKey without the storage dependency.

Jump to

Keyboard shortcuts

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