Documentation
¶
Overview ¶
Package history reads a repository and produces exactly what a version decision needs: where the project is now, and what has landed since.
This is the seam where I/O enters. Everything above it — package policy — is pure, which is what makes the decision testable as a table and reviewable without running anything. Keeping the git in one narrow place is what buys that.
Index ¶
Constants ¶
const FirstVersion = "0.0.0"
FirstVersion is where a project with no releases starts.
A repository with no semver tag has no current version, so one has to be chosen rather than discovered. 0.0.0 is the choice, which means the first release is decided by its commits exactly as every later one is: a feat makes it 0.1.0, a fix makes it 0.0.1.
The alternative — defaulting the first release to 0.1.0 whatever landed — was rejected because it makes the first release the one release whose number nobody can explain from the log.
Variables ¶
var ( // ErrTagNotFound reports a release tag the repository does not carry. ErrTagNotFound = errors.New("release tag not found") // ErrNotAVersion reports a tag that does not name a semantic version. ErrNotAVersion = errors.New("tag is not a version") // ErrNotAtTag reports a checkout whose HEAD is not the tagged commit. The // commits are walked from HEAD, so anywhere else would describe a // different release from the one named. ErrNotAtTag = errors.New("HEAD is not at the release tag") )
var ErrAmbiguousLatest = errors.New("ambiguous latest release")
ErrAmbiguousLatest reports two reachable tags that compare equal under semver precedence but exclude different commits — "v1.0.0+a" and "v1.0.0+b". There is no highest, and choosing one silently changes what the release contains.
var ErrNotARepository = errors.New("not a git repository")
ErrNotARepository reports a path that is not a git repository.
var ErrUnresolvableHEAD = errors.New("HEAD cannot be resolved")
ErrUnresolvableHEAD reports a repository that has history its HEAD cannot reach. Reporting it as empty would compute a release from thin air.
Functions ¶
This section is empty.
Types ¶
type Range ¶
type Range struct {
// Root is the repository's working-tree root, resolved by walking up from
// the supplied path.
//
// Anything else read per-repository — the manifest above all — must use
// this rather than the path the caller happened to pass, or `plan -C
// ./subdir` reads the same history with the manifest silently missing.
Root string
// Current is the latest released version, or FirstVersion when there are
// none.
Current semver.Version
// FromTag is the tag Current came from. Empty when the project has never
// released, which is what distinguishes "no releases" from "released 0.0.0".
FromTag string
// Commits are those not yet in any release, newest first.
Commits []policy.Commit
}
Range is a repository reduced to what a decision needs.
func (Range) HasReleased ¶
HasReleased reports whether the project has ever cut a release.
type Released ¶ added in v0.3.0
Released is one named release and the range of history it covers.
Current and FromTag describe the release BEFORE this one, and Commits are what this release added on top of it: the same shape Read gives for a release that has not happened yet, for a release that has.
func ReadRelease ¶ added in v0.3.0
ReadRelease reduces the repository at path to the range a named release covers: from the highest reachable semver tag strictly below it, to the tagged commit. HEAD must be that commit.
Spec 0005 D4. Strictly below, because on a checkout of the tag the highest reachable tag is the tag itself and the range would be empty. The ambiguity refusal is inherited from Read for the reason it exists there.