engine

package
v0.2.3 Latest Latest
Warning

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

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

Documentation

Overview

Package engine computes a release Plan from a repository's commit history.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RenderPlan

func RenderPlan(tmplText string, plan *Plan, footer bool) (string, error)

RenderPlan executes tmplText (a config's Template) against plan, producing changelog body text, then appends footerText when footer is true. Compute uses this for the full repo-wide/multi Plan; multi-mode draft/publish commands reuse it to render an isolated body for a single Package's own draft release, by wrapping that one PackagePlan in a synthetic *Plan — footer is threaded through separately each time so every rendered body gets (or skips) it consistently, not just the top-level one.

Types

type Entry

type Entry struct {
	SHA string
	// ShortSHA is SHA truncated to git's conventional 7-character
	// abbreviation, for compact display — text/template has no string
	// slicing of its own to derive this from SHA in a custom template.
	ShortSHA string
	// Author is the commit's plain git author name — always populated,
	// independent of AuthorRef.
	Author      string
	Type        string
	Scope       string
	Description string
	// Breaking is the commit's Conventional Commit breaking-change marker
	// (a "!" after type/scope, or a "BREAKING CHANGE:" footer) — orthogonal
	// to Type/Section, since a breaking commit still categorizes by its
	// literal type (e.g. a "feat!:" is both a Feature and breaking).
	Breaking bool
	// PR is the commit's resolved PR Reference, or nil when none was
	// found — enrichment only, never required (ADR-0001, ADR-0003).
	PR *commit.PRReference
	// AuthorRef is the commit author's linked backend account, or nil when
	// unresolved (no Backend, unsupported backend, or no linked account) —
	// enrichment only, template authors should fall back to Author.
	AuthorRef *backend.AuthorReference
	// CommitURL links to the commit on the backend's web UI. Empty when be
	// is nil (ADR-0001: enrichment only, never required for an Entry to
	// exist) — Backend.CommitURL is pure string formatting, so it's always
	// populated when a Backend is available, unlike PR which depends on a
	// live lookup succeeding.
	CommitURL string
}

Entry is one changelog line, derived from a single parsed commit.

type PackagePlan

type PackagePlan struct {
	Name             string
	Sections         []Section
	PreviousVersion  string
	SuggestedVersion string
	// PreviousTag/SuggestedTag are PreviousVersion/SuggestedVersion with
	// tag-format applied — the actual git tag names, not bare SemVer.
	// Empty wherever the corresponding Version field is (no previous
	// release, or no release-worthy Entries yet).
	PreviousTag  string
	SuggestedTag string
	// CompareURL links to a from/to diff between PreviousTag and
	// SuggestedTag on the backend's web UI. Empty when either tag is
	// empty, or no Backend was supplied — enrichment only, same as
	// Entry.CommitURL.
	CompareURL string
}

PackagePlan is one Package's sectioned Entries. Name is empty when packages aren't configured — an implicit single package standing in for the whole repo.

PreviousVersion/SuggestedVersion are only populated in multi mode (ADR-0004), where each Package is versioned and tagged independently; in single mode they stay empty and the repo-wide Plan fields apply instead.

type Plan

type Plan struct {
	Packages         []PackagePlan
	PreviousVersion  string
	SuggestedVersion string
	PreviousTag      string
	SuggestedTag     string
	CompareURL       string
	Rendered         string
}

Plan is the computed result of a release: every affected Package's sectioned Entries, plus the changelog body rendered through the configured template. PreviousVersion/SuggestedVersion (and their Tag/ CompareURL counterparts) are the repo-wide version (single mode only — see PackagePlan for multi mode).

func Compute

func Compute(ctx context.Context, repoPath string, cfg *config.Config, be backend.Backend) (*Plan, error)

Compute parses repoPath's commits as Conventional Commits, drops any carrying cfg's skip-changelog trailer, buckets the rest into cfg's sections, and computes a suggested next version from the highest-severity type seen (breaking > feat > fix). In single mode (default) this happens once, repo-wide, bounded by the last tag matching cfg.TagFormat, with Packages used only to section Entries (ADR-0004). In multi mode it happens independently per configured Package, each bounded by its own last tag (cfg.TagFormat with {{package}} resolved).

be is optional (nil is fine) — when a commit's PR Reference can't be extracted from its text (ADR-0001), be.ResolvePR is tried as a best-effort fallback. Whether that fallback does anything is entirely up to the adapter: only GitHub's actually looks anything up, so passing a Gitea/Forgejo Backend (or none) transparently yields the same text-extraction-only behavior.

type Section

type Section struct {
	Name    string
	Entries []Entry
}

Section is a named group of Entries (e.g. "Features", "Bug Fixes").

Jump to

Keyboard shortcuts

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