Documentation
¶
Overview ¶
Package git provides a changeprovider.ChangeProvider that reads change metadata out of a git repository, for a remote that offers no API to ask.
Where the GitHub and Phabricator providers query a service that already knows what a change contains, this one derives it: it keeps its own copy of the remote and computes each change's files, line counts and author from the commits themselves. That makes a plain git remote — an internal host, a mirror, a bare repository on disk — a first-class source of change metadata with no service in front of it.
What a change is measured against ¶
A git:// change URI names a commit and the ref it lives on, and nothing else. Unlike a pull request it carries no base, so the baseline has to be derived, and for a stack it cannot be the target branch: a stack's changes are cut one from the next, so measuring each against the target would report the second change as containing the first as well. Each change is therefore measured from where it diverged from the change before it, and only the first from the target. Callers get per-change numbers that sum, which is what any consumer aggregating over a batch depends on.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func New ¶
func New(params Params) changeprovider.ChangeProvider
New returns a changeprovider.ChangeProvider reading from repo.
Types ¶
type Params ¶
type Params struct {
Config changeprovider.Config
Repo Repository
Logger *zap.SugaredLogger
MetricsScope tally.Scope
}
Params carries what a provider needs. The Repository is built once per repository and shared by every queue reading it.
type Repository ¶
type Repository interface {
sync.Locker
FetchTarget(ctx context.Context) error
EnsureCommit(ctx context.Context, sha, ref string) error
MergeBase(ctx context.Context, a, b string) (string, error)
// RunRaw returns git's stdout untrimmed, since the diff and author formats
// this provider reads are NUL-delimited with a meaningful trailing byte.
RunRaw(ctx context.Context, args ...string) (string, error)
Remote() string
Target() string
}
Repository is the local copy this provider reads through. It is the git plumbing the provider needs and nothing more: fetching, commit resolution, merge bases, and a lock the provider holds across a read so a shared copy's object set stays consistent. platform/git/repo.Repo satisfies it.