Documentation
¶
Overview ¶
Package evidence turns what version control and the forge show into evidence facts: a change landing, a change reverted, a merged PR's lead time and its CI result. Facts are observed, never reported and never judged: they carry no weight, and the package holds no store, so what to keep and how to count it is for the caller. Rework is not observed here: reading it from history is a guess, and a fact is never a guess (design 05 section 6.5).
Index ¶
Constants ¶
const ( KindLanded = "landed" KindReverted = "reverted" KindLeadTime = "lead_time" KindCIPassed = "ci_passed" KindCIFailed = "ci_failed" KindCIPassedAfterFails = "ci_passed_after_failing" )
The kinds of Fact.
const ( SourceVCS = "vcs" SourceForge = "forge" )
The sources of a Fact.
Variables ¶
This section is empty.
Functions ¶
func Observe ¶
func Observe(repo Repo, forge Merged, w Watermark, now time.Time) (facts []Fact, next Watermark, forgeErr error, err error)
Observe reads the changes landed since w and, when forge is not nil, the PRs merged since it, and returns their facts oldest first with the watermark to start the next look from. A forge that fails gives forgeErr, with the version-control facts still returned and the forge's watermark unmoved; a failure of version control is err. A repo with no default branch has no changes and is no error.
Types ¶
type Fact ¶
type Fact struct {
Kind string `json:"kind"`
Commit string `json:"commit,omitempty"`
PR int `json:"pr,omitempty"`
Capability string `json:"capability,omitempty"`
Pursuit string `json:"pursuit,omitempty"`
Change string `json:"change,omitempty"` // the plan change's name
Idea string `json:"idea,omitempty"`
At time.Time `json:"at"`
Source string `json:"source"`
Seconds *int64 `json:"seconds,omitempty"` // lead time only
ByCommit string `json:"by_commit,omitempty"`
}
Fact is one observation. The idea is never set here: it needs the store.
type Repo ¶
type Repo interface {
DefaultBranch(ctx context.Context) (string, error)
Changes(ctx context.Context, rng string) ([]vcs.Change, error)
Since(ctx context.Context, ref string, t time.Time) ([]vcs.Change, error)
Reverts(c vcs.Change) (string, bool)
Resolve(ctx context.Context, ref string) (string, bool)
IsAncestor(ctx context.Context, a, b string) bool
Latest(ctx context.Context, ref string, n int) ([]vcs.Change, error)
}
Repo is the smallest part of vcs.Repo that observing reads.
type Watermark ¶
type Watermark struct {
Commit string `json:"commit,omitempty"`
Time time.Time `json:"time,omitzero"`
Forge time.Time `json:"forge,omitzero"`
}
Watermark is how far observing has got: the default branch's head and its time, and the newest merged-at the forge showed. The zero Watermark is a first look.