relplan

package
v0.150.0 Latest Latest
Warning

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

Go to latest
Published: Oct 22, 2026 License: Apache-2.0 Imports: 9 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package relplan reads what a repository has merged and not yet released, and how its releases have been spaced, from the machine alone (ADR-064).

The Work board's release column asks two questions: what is waiting to ship, and how often does this repository ship. Both are answered from git as it stands on this machine: the CHANGELOG's Unreleased section on the remote's default branch (`git show origin/HEAD:CHANGELOG.md`), plus the changelog fragments in changes/unreleased/ on that branch for a repository that keeps one file per change, and the newest tags. Nothing here fetches: the answer is only as fresh as the user's last `git fetch`, and the board says so. No release time is predicted; the median gap is a measured spacing, shown as one.

Index

Constants

View Source
const (
	// MaxItems is how many [Unreleased] entries are returned; the count
	// says how many there are.
	MaxItems = 30
	// TagsRead is how many of the newest tags are read: ten gaps.
	TagsRead = 11
	// MinGaps is how many gaps between releases a median needs (rule 6):
	// with fewer, the spacing is anecdote, not a measure.
	MinGaps = 3
)
View Source
const FragmentsDir = "changes/unreleased"

FragmentsDir is where a repository that keeps one file per change holds the entries waiting for the next release (changes/README.md): each file is a `---`/`kind: …`/`---` front matter and then its bullets.

Variables

View Source
var ErrNoRef = errors.New("no remote default branch known locally")

ErrNoRef is returned when the clone has no remote default branch known locally (no refs/remotes/origin/HEAD).

View Source
var Kinds = []string{"Added", "Changed", "Deprecated", "Removed", "Fixed", "Security"}

Kinds are Keep a Changelog's six kinds, the ones Unreleased.Kinds counts.

Functions

func AddFragment added in v0.120.0

func AddFragment(u *Unreleased, fragment []byte)

AddFragment counts one fragment's top-level bullets into u, as ParseUnreleased counts the section's: the front matter is read for its `kind:` and skipped, and a file without a closing `---` is read as bullets alone, of no kind.

func Ahead

func Ahead(ctx context.Context, dir, tag, rev string) (int, error)

Ahead is how many commits rev has that the tag does not.

func Changelog

func Changelog(ctx context.Context, dir, rev string) ([]byte, bool)

Changelog is CHANGELOG.md at rev; ok is false when the file is not there.

func DefaultRef

func DefaultRef(ctx context.Context, dir string) (ref, sha string, err error)

DefaultRef is the remote default branch as this clone knows it, "origin/main", and its commit. It reads refs only; it never fetches.

func Fragments added in v0.120.0

func Fragments(ctx context.Context, dir, rev string) ([][]byte, bool)

Fragments is the text of every `.md` file in FragmentsDir at rev, in file name order, read with two git processes however many there are. ok is false when rev has no such directory.

func MedianGap

func MedianGap(tags []Tag) (int64, int)

MedianGap is the median time between consecutive tags (ms) and how many gaps it is taken over; 0 with fewer than MinGaps gaps. Order does not matter; tags made in the same second are one release.

func OriginURL

func OriginURL(ctx context.Context, dir string) (string, error)

OriginURL is the address of the remote named origin, as configured.

Types

type Tag

type Tag struct {
	Name string
	At   int64
}

Tag is one tag and when it was made (unix ms): an annotated tag's own date, else its commit's.

func ParseTags

func ParseTags(out string) []Tag

ParseTags reads for-each-ref output in the format Tags asks for ("name<TAB>unix seconds" per line), newest first as git sorted it. Lines it cannot read are skipped.

func Tags

func Tags(ctx context.Context, dir string) ([]Tag, error)

Tags is the repository's newest TagsRead tags, newest first.

type Unreleased

type Unreleased struct {
	// Items are the first lines of its top-level bullets, in order, at most
	// MaxItems; nested bullets and sub-headings are not items.
	Items []string
	// Count is how many top-level bullets the section has.
	Count int
	// Kinds counts the bullets by their Keep a Changelog kind — the `### `
	// heading they sit under in the section, a fragment's `kind:` — for the
	// six kinds only (Kinds); a bullet under no such heading counts in Count
	// alone. Nil when no bullet has a kind. The release plan predicts the
	// next version from it: an Added entry is a minor release.
	Kinds map[string]int
}

Unreleased is the CHANGELOG's Unreleased section, summed up.

func ParseUnreleased

func ParseUnreleased(changelog []byte) (Unreleased, bool)

ParseUnreleased reads the Unreleased section of a Keep a Changelog file. ok is false when there is no such section; an empty section is ok with no items. The heading may carry more after the bracket ("## Unreleased - …"), and CRLF line ends read as LF.

Jump to

Keyboard shortcuts

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