Documentation
¶
Overview ¶
Package source defines what baton reads about components.
Index ¶
Constants ¶
View Source
const ( KindReleases = "releases" KindTags = "tags" )
Where a component's releases come from.
View Source
const ( OrderVersion = "version" OrderPublished = "published" OrderForge = "forge" )
Release orders.
View Source
const ( LevelMajor = "major" LevelMinor = "minor" LevelPatch = "patch" )
Trigger levels: the smallest SemVer change that owes work.
View Source
const MaxHistory = 100
MaxHistory caps how many commits PathHistory returns.
Variables ¶
View Source
var ( ErrNotFound = errors.New("not found") ErrNotFile = errors.New("path is not a file") ErrHTTP = errors.New("unexpected HTTP status") // ErrUnknowable means a question can't be answered for a past date // by design, such as the forge's current latest flag in a replay. ErrUnknowable = errors.New("can't be evaluated for a past date") )
Errors a Source returns for answers that aren't API failures.
Functions ¶
This section is empty.
Types ¶
type Filter ¶
type Filter struct {
Kind string // "releases" (default) or "tags"
Tags []*regexp.Regexp // every pattern must match
Prerelease bool // count prereleases
Order string // OrderVersion (default), OrderPublished, or OrderForge
Level string // triggers only; "" or LevelPatch counts every release
}
Filter says which of a component's releases count, and in what order.
type Release ¶
type Release struct {
Tag string
Published time.Time
Commit string
Prerelease bool // the forge's prerelease flag; tags have none
}
Release is a version of a component and when it was published. Commit is the commit the tag points to, when the listing provides it; otherwise TagCommit resolves it.
type Source ¶
type Source interface {
// Releases returns stable releases. kind is "releases" (GitHub
// releases) or "tags" (version tags, dated by their commit).
Releases(repo, kind string) ([]Release, error)
// TagCommit returns the commit a tag points to, peeling annotated
// tags.
TagCommit(repo, tag string) (string, error)
// CommitAt returns the default-branch commit as of a time.
CommitAt(repo string, asOf time.Time) (string, error)
// PathHistory returns up to MaxHistory default-branch commits that
// touched path, committed at or before until, newest first.
PathHistory(repo, path string, until time.Time) ([]Commit, error)
// FlaggedLatest returns the release the forge marks as latest.
FlaggedLatest(repo string) (Release, error)
// File returns a file's content at ref; found is false on 404.
File(repo, path, ref string) (content string, found bool, err error)
// GetJSON fetches a JSON object from a URL.
GetJSON(url string) (map[string]any, error)
}
Source is everything the probes read. The GitHub implementation is in internal/github; tests use the generated fake.
Click to show internal directories.
Click to hide internal directories.