history

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Sep 1, 2026 License: MIT Imports: 10 Imported by: 0

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

View Source
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

View Source
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.

View Source
var ErrNotARepository = errors.New("not a git repository")

ErrNotARepository reports a path that is not a git repository.

View Source
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 Read

func Read(path string) (Range, error)

Read opens the repository at path and reduces it to a Range.

func (Range) HasReleased

func (r Range) HasReleased() bool

HasReleased reports whether the project has ever cut a release.

Jump to

Keyboard shortcuts

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