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
- Variables
- func AddFragment(u *Unreleased, fragment []byte)
- func Ahead(ctx context.Context, dir, tag, rev string) (int, error)
- func Changelog(ctx context.Context, dir, rev string) ([]byte, bool)
- func DefaultRef(ctx context.Context, dir string) (ref, sha string, err error)
- func Fragments(ctx context.Context, dir, rev string) ([][]byte, bool)
- func MedianGap(tags []Tag) (int64, int)
- func OriginURL(ctx context.Context, dir string) (string, error)
- type Tag
- type Unreleased
Constants ¶
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 )
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 ¶
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).
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 DefaultRef ¶
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
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.
Types ¶
type Tag ¶
Tag is one tag and when it was made (unix ms): an annotated tag's own date, else its commit's.
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.