config

package
v0.71.2 Latest Latest
Warning

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

Go to latest
Published: Sep 27, 2026 License: MIT Imports: 15 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

Index

Constants

This section is empty.

Variables

View Source
var ErrRemovedConfigKey = errors.New("removed config key")

ErrRemovedConfigKey reports a config key removed by the forge migration (ADR-0043).

Functions

func DefaultBaseURL added in v0.32.0

func DefaultBaseURL(platformType string) string

DefaultBaseURL returns the default web base URL for a platform type, or "" when the type has no known default (e.g. an invalid platform — the type error is raised separately by the validator).

func ExtractRotationTokens added in v0.59.0

func ExtractRotationTokens(output string) []string

ExtractRotationTokens returns the {TOKEN} placeholder names present in output, in the order they appear. Returns nil when output has none — the common case, and the signal that a changelog.output value is a plain literal path with no rotation behavior at all.

func IncrementSprint added in v0.4.0

func IncrementSprint(path string) (int, error)

IncrementSprint reads the config file at path, increments versioning.sprint by one, writes the file back preserving all other content, and returns the new value. If sprint is absent from the file (default 0), it is inserted and set to 1.

func InitDest

func InitDest() string

InitDest returns the path heraut init should write to: .config/heraut.yml if .config/ exists, else .heraut.yml.

func ResolvePath

func ResolvePath(explicit string) string

ResolvePath returns the config file to use. See ResolvePathWithSource for the order.

func ScopeNames added in v0.46.0

func ScopeNames(scopes []ScopeRule) []string

ScopeNames returns the names of the given scopes, in order.

func ValidateChangelogRotationForWizard added in v0.62.1

func ValidateChangelogRotationForWizard(strategy, calverFormat, output string) error

ValidateChangelogRotationForWizard runs the same {TOKEN}-vs-strategy checks validateChangelogRotation applies at config-load time, exposed for `heraut init`'s live, per-keystroke field validation (T258) — the wizard has no full *Config yet, only the strategy/CalVer-format the user has picked so far in the form. Returns nil when output has no {TOKEN} placeholders or they're all valid for strategy/calverFormat; the first validation error otherwise (a huh field validator wants one error, not a list).

func ValidateTagFormatForWizard added in v0.62.1

func ValidateTagFormatForWizard(s string) error

ValidateTagFormatForWizard is a minimal wizard-facing wrapper around tagFormatMissingVersion, for heraut init's live, per-keystroke validation of both the common (versioning.tag_format) and per-environment tag_format fields (T259) — same rule, same message, either field.

Types

type BumpConfig added in v0.63.0

type BumpConfig struct {
	Mode      string     `yaml:"mode,omitempty"`
	Overrides []BumpRule `yaml:"overrides,omitempty"`
	// StayAtV0 holds a major bump back to minor while the current major version is 0 (ADR-0063).
	StayAtV0 bool `yaml:"stay_at_v0,omitempty"`
}

BumpConfig configures SemVer auto-bump resolution (T261): the resolution mode, and — for auto mode — per-commit bump-level overrides layered on top of the built-in defaults (breaking commits → major, feat → minor, any other conventional commit → patch).

type BumpRule added in v0.63.0

type BumpRule struct {
	Type     string `yaml:"type,omitempty"`
	Regex    string `yaml:"regex,omitempty"`
	Breaking *bool  `yaml:"breaking,omitempty"`
	Bump     string `yaml:"bump"` // "major" | "minor" | "patch" | "none"
}

BumpRule assigns an explicit bump level to commits matching Type, Regex, and/or Breaking — all specified conditions must hold (unset conditions are wildcards); Type and Regex are mutually exclusive, like Exclude. Rules are evaluated in order; the first match wins over the built-in defaults, so a rule can also override "breaking commits are always major" (e.g. {breaking: true, bump: minor}).

type CommitRule added in v0.66.0

type CommitRule struct {
	Name string `yaml:"name"`
	// Deny is a regex that must NOT match Target.
	Deny string `yaml:"deny,omitempty"`
	// Require is a regex that MUST match Target.
	Require string `yaml:"require,omitempty"`
	// RequireTicket, when true, is shorthand for "Target must match one of the
	// already-configured commits.tickets[].pattern entries" — reusing that list instead of
	// asking rule authors to duplicate a ticket regex in Require.
	RequireTicket bool `yaml:"require_ticket,omitempty"`
	// Target selects the part of the message matched against: "header", "body", "footer",
	// or "message" (the full raw text — the default when empty).
	Target string `yaml:"target,omitempty"`
	// Message is shown when the rule is violated. Required for Deny/Require; optional
	// (defaulted) for RequireTicket.
	Message string `yaml:"message,omitempty"`
	// Types and Scopes optionally scope the rule to commits of the listed conventional-commit
	// types/scopes (AND'd together). Omitting both applies the rule to every commit.
	Types  []string `yaml:"types,omitempty"`
	Scopes []string `yaml:"scopes,omitempty"`
}

CommitRule enforces one pattern constraint on a commit message, checked by `heraut commit verify`/`check` alongside the type/scope checks (ADR-0056). Exactly one of Deny, Require, or RequireTicket must be set.

type Commits added in v0.46.0

type Commits struct {
	// TypesHeadingLevel is the heading depth (number of '#') for type sections in rendered
	// output. Zero means the renderer's default.
	TypesHeadingLevel int `yaml:"types_heading_level,omitempty"`
	// Types are the conventional-commit type rules, merged over the built-in defaults by name
	// (see EffectiveTypes). The effective set is the verify allow-list and the section taxonomy.
	Types []TypeRule `yaml:"types,omitempty"`
	// Scopes is the allowed scope list (offered by `heraut commit create`; enforced by
	// `heraut commit verify` only when ScopesRestricted is true). Each entry's description is
	// shown beside the scope in the wizard picker.
	Scopes []ScopeRule `yaml:"scopes,omitempty"`
	// ScopesRestricted, when true, makes `heraut commit verify` reject scopes outside Scopes.
	ScopesRestricted bool `yaml:"scopes_restricted,omitempty"`
	// Tickets configures issue-tracker links matched in commit messages and rendered as links.
	Tickets []Ticket `yaml:"tickets,omitempty"`
	// Rules are project-specific commit-message constraints (deny/require/require_ticket
	// patterns), enforced by `heraut commit verify`/`check` alongside Types/Scopes (ADR-0056).
	Rules []CommitRule `yaml:"rules,omitempty"`
	// EnrichmentForge references a forges[].name used as the PR/MR metadata source for
	// changelog and release-notes generation (ADR-0043).
	EnrichmentForge string `yaml:"enrichment_forge,omitempty"`
	// EnrichmentPolicy is the PR/MR enrichment policy sourced from EnrichmentForge:
	// "required", "optional" (default), or "disabled". Governs changelog and release-notes
	// generation (ADR-0043; renamed from the removed remote_metadata).
	EnrichmentPolicy string `yaml:"enrichment_policy,omitempty"`
}

Commits is heraut's single source of truth for commit semantics and enrichment (ADR-0033): the conventional-commit type set, scope rules, ticket links, and the remote-metadata policy.

type Config

type Config struct {
	Version      string                 `yaml:"version"`
	Versioning   Versioning             `yaml:"versioning"`
	Changelog    *ContentDriver         `yaml:"changelog,omitempty"`
	Release      *Release               `yaml:"release,omitempty"`
	Environments map[string]Environment `yaml:"environments,omitempty"`
	// Commits is the single source of truth for commit semantics and enrichment (ADR-0033):
	// the conventional-commit type set (consumed by both `heraut commit verify`/`create` and
	// the native renderer's section taxonomy), scope rules, ticket links, and the
	// remote-metadata policy. Replaces the former commit_lint block and the top-level
	// tickets/remote_metadata keys.
	Commits *Commits `yaml:"commits,omitempty"`
	// Rendering configures content output (ADR-0033): the exclude rules that drop matched
	// commits from the rendered changelog/release-notes.
	Rendering *Rendering `yaml:"rendering,omitempty"`
	// Forges lists the code-hosting platforms heraut talks to (ADR-0043). Consumed by
	// release.targets (publish destinations) and commits.enrichment_forge (PR/MR metadata
	// source).
	Forges []Forge `yaml:"forges,omitempty"`
	// Hooks configures shell commands run at points in the release lifecycle (ADR-0053).
	Hooks *Hooks `yaml:"hooks,omitempty"`
}

Config is the parsed .heraut.yml.

func Load

func Load(path string) (*Config, error)

Load reads and strictly parses the config file at path, then applies heraut's post-parse defaults. Unknown YAML fields are rejected.

func LoadFromReader

func LoadFromReader(r io.Reader) (*Config, error)

LoadFromReader strictly parses config from r, then applies heraut's defaults.

func (*Config) EffectiveTagFormat added in v0.19.0

func (c *Config) EffectiveTagFormat(env string) string

EffectiveTagFormat returns the tag format for env: the environment-level override when set, otherwise the top-level versioning.tag_format. This lets a single top-level format (e.g. "{env}/{version}") cover every environment while allowing per-environment overrides. env may be empty for non-per-env strategies.

func (*Config) EnrichmentPolicy added in v0.55.0

func (c *Config) EnrichmentPolicy() string

EnrichmentPolicy returns the configured PR/MR enrichment policy (commits.enrichment_policy), or "" (which the generators treat as "optional"). Nil-safe.

func (*Config) PostBumpHooks added in v0.64.0

func (c *Config) PostBumpHooks() []HookStep

PostBumpHooks returns the configured post_bump hook steps, or nil. Nil-safe.

func (*Config) PostReleaseHooks added in v0.64.0

func (c *Config) PostReleaseHooks() []HookStep

PostReleaseHooks returns the configured post_release hook steps, or nil. Nil-safe.

func (*Config) PostTagHooks added in v0.64.0

func (c *Config) PostTagHooks() []HookStep

PostTagHooks returns the configured post_tag hook steps, or nil. Nil-safe.

func (*Config) PreChangelogHooks added in v0.64.0

func (c *Config) PreChangelogHooks() []HookStep

PreChangelogHooks returns the configured pre_changelog hook steps, or nil. Nil-safe.

func (*Config) PreReleaseHooks added in v0.64.0

func (c *Config) PreReleaseHooks() []HookStep

PreReleaseHooks returns the configured pre_release hook steps, or nil. Nil-safe.

func (*Config) PreTagHooks added in v0.64.0

func (c *Config) PreTagHooks() []HookStep

PreTagHooks returns the configured pre_tag hook steps, or nil. Nil-safe.

func (*Config) Tickets added in v0.30.0

func (c *Config) Tickets() []Ticket

Tickets returns the configured ticket-link patterns (commits.tickets), or nil. Nil-safe.

type ContentDriver

type ContentDriver struct {
	Output     string `yaml:"output,omitempty"`
	TagPattern string `yaml:"tag_pattern,omitempty"`
	Template   string `yaml:"template,omitempty"`
	// Rendering holds per-driver rendering overrides (template snippets + excludes),
	// deep-merged over the global rendering block. native only (ADR-0037).
	Rendering *Rendering `yaml:"rendering,omitempty"`
	// HeadingVersionPattern is set by the app layer when the effective tag_format contains
	// {env} or {build}. native regex-replaces the heading's version bracket with it after
	// rendering, stripping the env prefix/suffix and build ID from version headings (leaving
	// just the version). Not user-configurable.
	HeadingVersionPattern string `yaml:"-"`
	// RemoteMetadata is the effective top-level Config.EnrichmentPolicy, propagated onto
	// the driver by the app layer so the generator can honour it. Empty means "optional".
	// Not user-configurable at the driver level (the user sets it once at the top level).
	RemoteMetadata string `yaml:"-"`
	// Tickets is the effective top-level Config.Tickets, propagated onto the driver by the
	// app layer so the generator can inject link_parsers. Not user-configurable per-driver.
	Tickets []Ticket `yaml:"-"`
	// Types is the effective commits.types, propagated by the app layer so the native generator
	// drives its section taxonomy from config. Not user-configurable per-driver. (native only.)
	Types []TypeRule `yaml:"-"`
	// Excludes is the effective rendering.excludes, propagated by the app layer so the native
	// generator filters commits from the output. Not user-configurable per-driver. (native only.)
	Excludes []Exclude `yaml:"-"`
	// EffectiveTemplates is the app-computed template-block override map (global rendering.templates
	// overlaid by this driver's rendering.templates), propagated for the native generator. Not
	// user-configurable directly — the knobs are rendering.templates. (native only.)
	EffectiveTemplates map[string]string `yaml:"-"`
	// EffectiveTrailerRules is the app-computed per-token footer-rendering rule map (global
	// rendering.trailers overlaid by this driver's rendering.trailers, keyed by lowercased
	// token), propagated for the native generator (ADR-0057). Not user-configurable directly —
	// the knob is rendering.trailers. (native only.)
	EffectiveTrailerRules map[string]FooterRule `yaml:"-"`
	// RegenerateChangelog forces the native generator to rebuild the entire changelog and
	// re-enrich every section, instead of incrementally splicing only the new release's section.
	// Set by the app layer from the --regenerate / --regenerate-changelog flag. (native only.)
	RegenerateChangelog bool `yaml:"-"`
	// Force downgrades remote_metadata: required to optional for this run: an unavailable or
	// unconfigured remote degrades (warn + render bare) instead of erroring. Set by the app layer
	// from the --force flag. (native only.)
	Force bool `yaml:"-"`
	// HerautVersion is the running heraut binary's version, propagated by the app layer so the
	// native generator can expose it to templates as .Heraut.Version. Not user-configurable.
	// (native only.)
	HerautVersion string `yaml:"-"`
	// TypesHeadingLevel is the effective commits.types_heading_level, propagated by the app
	// layer for the native generator's section heading depth. (native only.)
	TypesHeadingLevel int `yaml:"-"`
	// TagGlob is the app-computed git tag glob scoping the native generator to the active
	// environment's tags under a per-env strategy (tagfmt.GlobPattern). Empty means "all tags"
	// (non-per-env). Not user-configurable — the user-facing knob is TagPattern. (native only.)
	TagGlob string `yaml:"-"`
	// PreviousTagOverride, when set, bounds a freshly-bootstrapped or spliced release section's
	// commit range explicitly, instead of native deriving it from the tag_pattern/tag_glob-scoped
	// tag list. Set by the app layer's rotation decorator (T247) for a rotating changelog.output:
	// tag-scoping a bucket like "^2026\." correctly excludes prior-bucket tags from the historical
	// walk, but also leaves the *new* bucket's first release with no in-scope previous tag to bound
	// it by — which would otherwise default to "since the beginning of history" and duplicate every
	// prior bucket's entries into the new file. Not user-configurable. (native only.)
	PreviousTagOverride string `yaml:"-"`
}

ContentDriver configures native, heraut's sole content generator (ADR-0045).

func EffectiveReleaseNotes added in v0.58.0

func EffectiveReleaseNotes(cfg *Config, env string) *ContentDriver

EffectiveReleaseNotes resolves the release-notes ContentDriver for env: a non-empty per-environment override merges onto the top-level config (ADR-0019, MergeContentDriver). release: presence — top-level or per-environment — always default-populates Notes to a non-nil, empty ContentDriver when neither level sets one explicitly (ADR-0046 release-block atomicity applies per-environment exactly like it does at the root; the loader's normalize() only reaches the top-level block, so the per-environment default has to happen here). A nil result means release: was not configured at all for this environment, at either level.

func MergeContentDriver added in v0.20.0

func MergeContentDriver(base, override *ContentDriver) *ContentDriver

MergeContentDriver returns the effective ContentDriver for a per-environment override applied over a top-level base, per ADR-0019: nil base -> override (nothing to inherit); nil override -> base; otherwise field-by-field merge — a non-empty override field wins, an empty field inherits from base. (Prior to T177/T182, a generator switch between base and override triggered a full replacement instead of a field merge; that branch is gone now that Generator can never be non-empty — native is the only generator.)

Neither argument is mutated; the result is always a fresh value (or the sole non-nil argument when one side is nil).

type EnvRelease added in v0.10.0

type EnvRelease struct {
	Notes *ContentDriver `yaml:"notes,omitempty"`
	// Targets lists per-environment release publish destinations, mirroring Release.Targets
	// (ADR-0043).
	Targets []Target `yaml:"targets,omitempty"`
}

EnvRelease holds per-environment release overrides. Nil fields mean "inherit from root release", which differs from root Release where nil means "disabled".

type Environment added in v0.10.0

type Environment struct {
	// Versioning fields
	Bump      string `yaml:"bump"`
	TagFormat string `yaml:"tag_format,omitempty"`
	Branch    string `yaml:"branch,omitempty"`
	Source    string `yaml:"source,omitempty"`

	// Content fields
	DisableChangelog bool `yaml:"disable_changelog,omitempty"`
	// DisableRelease turns off the entire release: behavior (notes generation and publishing,
	// together) for this environment (T217, release-atomicity design) — renamed from
	// disable_notes, which only silenced the notes text while still publishing.
	DisableRelease bool           `yaml:"disable_release,omitempty"`
	Changelog      *ContentDriver `yaml:"changelog,omitempty"`
	Release        *EnvRelease    `yaml:"release,omitempty"`
}

Environment holds all per-environment configuration under the root environments map. Versioning fields drive version resolution; content fields override changelog/release.

type Exclude added in v0.46.0

type Exclude struct {
	Type  string `yaml:"type,omitempty"`
	Regex string `yaml:"regex,omitempty"`
}

Exclude drops matched commits from rendered output. Exactly one of Type or Regex must be set: Type matches the conventional-commit type; Regex matches the commit subject.

func EffectiveExcludes added in v0.46.0

func EffectiveExcludes(user []Exclude) []Exclude

EffectiveExcludes returns the built-in default excludes followed by the user's excludes: user entries augment the defaults (they do not replace them).

type FooterRule added in v0.67.0

type FooterRule struct {
	Token string `yaml:"token"`
	// Renderer is a Go text/template snippet executed with {Token, Value} as its data context —
	// the same idiom as Rendering.Templates' block snippets.
	Renderer string `yaml:"renderer,omitempty"`
	// Hide drops matching footers from rendered output entirely.
	Hide bool `yaml:"hide,omitempty"`
}

FooterRule customizes the rendering of one commit-message footer trailer (a "trailer" in git terms — conventionalcommit.Footer). Token is matched case-insensitively, exact-match, against the trailer's literal token as parsed (conventionalcommit never normalizes casing). Exactly one of Renderer or Hide must be set (ADR-0057).

func DefaultTrailers added in v0.67.0

func DefaultTrailers() []FooterRule

DefaultTrailers is the built-in trailer-rule set merged under user rendering.trailers, mirroring defaultTypes/defaultScopes (ADR-0058): Co-Authored-By is common enough (GitHub co-authored commits, git commit --trailer, AI pairing tools) to warrant a de-emphasized credit line instead of the raw "Token: Value" fallback. Exported, unlike defaultTypes/ defaultScopes, because its merge call site lives in internal/app (effectiveTrailers), not internal/config.

func MergeFooterRules added in v0.67.0

func MergeFooterRules(base, override []FooterRule) []FooterRule

MergeFooterRules overlays override's entries onto base, matched case-insensitively by Token: an overridden token's entry is replaced (keeping base's position), and override-only tokens are appended after. Mirrors Templates' per-key override-wins merge (ADR-0057), adapted for a token-keyed slice instead of a map. Neither slice is mutated.

type Forge added in v0.55.0

type Forge struct {
	Name       string `yaml:"name"`
	Type       string `yaml:"platform"`             // discriminator; "platform" key avoids Forge.Forge self-reference (ADR-0006)
	Project    string `yaml:"project,omitempty"`    // gitlab: group[/subgroup]/repo; azure: organization/project
	Repository string `yaml:"repository,omitempty"` // github: owner/repo; azure: repo name
	BaseURL    string `yaml:"base_url,omitempty"`
	APIURL     string `yaml:"api_url,omitempty"`
	APIMode    string `yaml:"api_mode,omitempty"` // "rest" (default) | "graphql"
	TokenEnv   string `yaml:"token_env,omitempty"`
}

Forge is one code-hosting platform heraut talks to — connection/identity only. What to publish (draft/assets) lives in release.targets; the enrichment source is commits.enrichment_forge. See ADR-0043.

type HookStep added in v0.68.0

type HookStep struct {
	Run   string   `yaml:"run"`
	Stage []string `yaml:"stage,omitempty"`
}

HookStep is one command in a hook point's list (ADR-0053, extended by ADR-0061: object-only, stage added). Run is required; Stage is optional and only meaningful under post_bump/ pre_changelog (internal/config/validator.go enforces the scope — see T296).

func (*HookStep) UnmarshalYAML added in v0.68.0

func (h *HookStep) UnmarshalYAML(node *yaml.Node) error

UnmarshalYAML rejects the plain-string shorthand ADR-0053 originally allowed (ADR-0061): every hook entry must be a mapping with at least run. Re-marshals node and decodes it through a fresh KnownFields(true) decoder rather than calling node.Decode directly — verified empirically that node.Decode alone does NOT honor the outer forge/config.Decode call's KnownFields(true), so an unknown field inside a hook entry (e.g. a typo'd `stag:`) would otherwise silently pass instead of erroring.

type Hooks added in v0.64.0

type Hooks struct {
	// PostBump runs immediately after the next version is resolved.
	PostBump []HookStep `yaml:"post_bump,omitempty"`
	// PreChangelog runs before changelog generation.
	PreChangelog []HookStep `yaml:"pre_changelog,omitempty"`
	// PreTag runs before the local git tag is created.
	PreTag []HookStep `yaml:"pre_tag,omitempty"`
	// PostTag runs after the tag is pushed to origin.
	PostTag []HookStep `yaml:"post_tag,omitempty"`
	// PreRelease runs before publishing to a platform, once per platform.
	PreRelease []HookStep `yaml:"pre_release,omitempty"`
	// PostRelease runs after publishing to a platform, once per platform.
	PostRelease []HookStep `yaml:"post_release,omitempty"`
}

Hooks configures shell commands run at points in the release lifecycle (ADR-0053, ADR-0061). post_bump/pre_changelog/pre_tag/post_tag fire in both `heraut release` and `heraut changelog --tag`; pre_release/post_release fire only in `heraut release`, once per publish target.

type PathSource added in v0.16.0

type PathSource string

PathSource identifies how a config file path was resolved. The values mirror forge's Resolver.Label output for app "heraut".

const (
	SourceFlag      PathSource = "--config"
	SourceEnvVar    PathSource = "HERAUT_FILE"
	SourceXDGConfig PathSource = ".config/heraut.yml"
	SourceDefault   PathSource = ".heraut.yml"
)

func ResolvePathWithSource added in v0.16.0

func ResolvePathWithSource(explicit string) (string, PathSource)

ResolvePathWithSource returns the config file to use and the source that determined it (see forge's Resolver: --config flag → HERAUT_FILE → .config/heraut.yml → .heraut.yml).

type Platform

type Platform struct {
	// Name identifies this platform instance, propagated from the owning forges[].name.
	Name string
	Type string
	// GitHub-specific
	Repository string
	Draft      bool
	Prerelease bool
	// GitLab-specific
	Project string
	// Shared
	BaseURL  string
	TokenEnv string
	Assets   []string
	// LenientAssets is set programmatically whenever this target has any assets to resolve —
	// inherited from release.assets or declared on the target itself (T228). When true, a glob
	// pattern that matches nothing emits a warning instead of an error: by the time assets are
	// resolved the tag has already been created and pushed, so a strict failure here would leave
	// the repository in a partially-completed state.
	LenientAssets bool
}

Platform is the config shape the internal/platforms/{github,gitlab} drivers accept. It has no YAML surface of its own — internal/app builds one per release.targets entry from the resolved port.ForgeIdentity (platformConfigFromTarget), so the drivers stay unchanged while the user-facing config moved to forges:/release.targets (ADR-0043/ADR-0044). No field carries a yaml tag: none of them are ever decoded from a .heraut.yml file (T173).

type Release

type Release struct {
	Notes *ContentDriver `yaml:"notes,omitempty"`
	// Assets lists glob patterns for files to attach to the GitHub/GitLab release.
	// Globs are expanded at release time; a pattern matching nothing emits a warning
	// but does not abort the release. Applied to all configured targets.
	Assets []string `yaml:"assets,omitempty"`
	// Targets lists release publish destinations, each referencing a forges[].name
	// (ADR-0043).
	Targets []Target `yaml:"targets,omitempty"`
}

Release holds release notes and publish target settings.

type Rendering added in v0.46.0

type Rendering struct {
	// Excludes drop matched commits from the rendered changelog/release-notes.
	Excludes []Exclude `yaml:"excludes,omitempty"`
	// Templates overrides built-in native template blocks by key (e.g. "commit.message",
	// "release.group", "commit.contributor", "release.section", "footer"): each value is a Go
	// text/template snippet. native only — deep-merged global → per-driver → per-env (ADR-0037,
	// ADR-0048, ADR-0059).
	Templates TemplateOverrides `yaml:"templates,omitempty"`
	// Commit groups rendering.templates.commit config that isn't itself a template-snippet
	// override — currently just Trailers. Named RenderingCommit, not Commit, to avoid colliding
	// with the unrelated top-level Commits struct (conventional-commit type/scope/ticket
	// taxonomy) in this same file. No yaml tag: populated by Rendering.UnmarshalYAML, not decoded
	// from its own top-level key (ADR-0060).
	Commit *RenderingCommit
}

Rendering configures content output (ADR-0033). It has a custom UnmarshalYAML (templates.go) because rendering.templates.commit.trailers (ADR-0060) is a list of rules, not a template-snippet string like its commit.message/commit.ticket/commit.contributor siblings, so it can't flow through Templates' flat TemplateOverrides map — the custom decode carves it out into Commit separately, from the same raw templates node TemplateOverrides also reads.

func (*Rendering) UnmarshalYAML added in v0.67.0

func (r *Rendering) UnmarshalYAML(value *yaml.Node) error

UnmarshalYAML decodes Rendering's excludes/templates fields, then carves rendering.templates.commit.trailers out of the same raw templates node into Commit (ADR-0060) — see the type's doc comment for why. A custom Unmarshaler bypasses the outer decoder's KnownFields strictness for its own node (forgeconfig.Decode's strict mode does not propagate into a type's own UnmarshalYAML), so this reimplements "unknown field" rejection for Rendering's own two keys itself, rather than silently accepting a typo.

type RenderingCommit added in v0.67.0

type RenderingCommit struct {
	// Trailers customizes how individual commit-message footer trailers render, matched by
	// token. native only — deep-merged global → per-driver → per-env, by token, like Templates
	// (ADR-0057; relocated here by ADR-0060).
	Trailers []FooterRule `yaml:"trailers,omitempty"`
}

RenderingCommit holds rendering.templates.commit's non-snippet fields (ADR-0060).

type ScopeRule added in v0.46.0

type ScopeRule struct {
	Name        string `yaml:"name"`
	Remove      bool   `yaml:"remove,omitempty"`
	Description string `yaml:"description,omitempty"`
}

ScopeRule configures one allowed commit scope, merged over a small built-in default set (dependency / release scopes — see defaultScopes) by name, like TypeRule. remove drops a default; description is shown beside the scope in the `heraut commit create` wizard.

func EffectiveScopes added in v0.46.0

func EffectiveScopes(user []ScopeRule) []ScopeRule

EffectiveScopes merges user scope rules over the built-in defaults, keyed by name (like EffectiveTypes): a listed scope replaces that default's entry, remove:true drops a name, an unknown name is appended. The result is the wizard's scope list and — when scopes_restricted is true — the verify allow-list.

type Target added in v0.55.0

type Target struct {
	Forge      string   `yaml:"forge,omitempty"` // → forges[].name; optional when exactly one forge
	Draft      bool     `yaml:"draft,omitempty"`
	Prerelease bool     `yaml:"prerelease,omitempty"`
	Assets     []string `yaml:"assets,omitempty"`
}

Target is one release publish destination: a reference to a forges[].name plus publish options.

func EffectiveTargets added in v0.57.0

func EffectiveTargets(cfg *Config, env string) []Target

EffectiveTargets resolves the publish targets for env: a non-empty per-environment list replaces the top-level one (it does not merge).

type TemplateOverrides added in v0.67.0

type TemplateOverrides map[string]string

TemplateOverrides is rendering.templates' value type: user overrides for native's overridable template blocks (ADR-0037/ADR-0048/ADR-0049), keyed by the block name they replace. Since ADR-0059, the release- and commit-cadence blocks are namespaced in YAML (release: {section: ..., ...}, commit: {message: ..., ...}) but flatten to dotted keys here (release.section, commit.message, ...) — every other layer (mergeRendering's deep-merge, effectiveTemplates, native's buildTemplateSet) still deals in a flat map[string]string, unaware the YAML surface is nested.

func (*TemplateOverrides) UnmarshalYAML added in v0.67.0

func (t *TemplateOverrides) UnmarshalYAML(value *yaml.Node) error

UnmarshalYAML flattens rendering.templates' release:/commit: namespaces into dotted keys. Any other top-level key decodes as a plain snippet string, exactly as before ADR-0059. A key named "release"/"commit" whose value isn't itself a mapping (e.g. a plain string) is not special-cased — it decodes as an ordinary flat key instead, since it is not a valid block name on its own; validateTemplateSnippets' "unknown template block" error catches it later, not this method. commit.trailers is skipped entirely: unlike every other commit.* key it is a list of rules, not a snippet string, so it can't flow through this flat map — Rendering.UnmarshalYAML extracts it separately from the same raw node (ADR-0060).

type Ticket added in v0.30.0

type Ticket struct {
	Pattern string `yaml:"pattern"`
	URL     string `yaml:"url"`
}

Ticket maps a commit ticket-ID pattern to a URL template. {ticket} in URL is the first capture group of Pattern (or the full match if Pattern has no group); the link label is always the full match.

type TypeRule added in v0.46.0

type TypeRule struct {
	Name        string `yaml:"name"`
	Order       *int   `yaml:"order,omitempty"`       // nil = unordered (sorts after ordered types)
	Render      string `yaml:"render,omitempty"`      // section label; empty = capitalize Name
	Remove      bool   `yaml:"remove,omitempty"`      // drop this default type from the effective set
	Description string `yaml:"description,omitempty"` // one-line hint shown in the commit wizard picker
}

TypeRule configures one conventional-commit type. User entries are merged over the built-in defaults by name (see EffectiveTypes): the type word, its changelog section label and order, and whether to drop a default type from the effective set.

func EffectiveTypes added in v0.46.0

func EffectiveTypes(user []TypeRule) []TypeRule

EffectiveTypes merges user type rules over the built-in defaults, keyed by name:

  • a user entry for an existing name replaces that default entry wholesale, so omitting render/order means "no label / unordered", not "inherit the default";
  • remove:true drops the name from the effective set;
  • an unknown name is appended after the defaults.

The result is the single effective type set consumed by `heraut commit verify`/`create` (the allow-list) and by the native renderer (the section taxonomy). Default order is preserved; user-added types follow.

type ValidationError

type ValidationError = forgeconfig.ValidationError

ValidationError and ValidationErrors are heraut's aliases for forge's structured validation errors (Path/Message/Hint). The validator produces them; cmd renders them.

type ValidationErrors

type ValidationErrors = forgeconfig.ValidationErrors

ValidationError and ValidationErrors are heraut's aliases for forge's structured validation errors (Path/Message/Hint). The validator produces them; cmd renders them.

func Validate

func Validate(cfg *Config) ValidationErrors

Validate runs all semantic validation layers against cfg. All errors are collected and returned; validation does not stop on the first error.

type Versioning

type Versioning struct {
	Strategy       string      `yaml:"strategy"`
	TagPrefix      *string     `yaml:"tag_prefix,omitempty"`
	InitialVersion string      `yaml:"initial_version,omitempty"`
	Bump           *BumpConfig `yaml:"bump,omitempty"`
	Format         string      `yaml:"format,omitempty"`
	Sprint         int         `yaml:"sprint,omitempty"`
	TagFormat      string      `yaml:"tag_format,omitempty"`
	TagType        string      `yaml:"tag_type,omitempty"`
	// CommitMessage is the git commit message template for the changelog commit heraut
	// creates, and — when the tag is annotated (TagType != "lightweight") — the tag's own
	// annotation message too (internal/pipeline/git.go's commitMessage()). "${version}" is
	// substituted with the resolved version. Defaults to "chore(release): ${version}".
	CommitMessage string `yaml:"commit_message,omitempty"`
}

Versioning holds version resolution settings.

func (Versioning) BumpMode added in v0.63.0

func (v Versioning) BumpMode() string

BumpMode returns the configured SemVer bump mode ("auto" or "manual"), defaulting to "auto" when bump is omitted or bump.mode is unset. Nil-safe.

func (Versioning) BumpOverrides added in v0.63.0

func (v Versioning) BumpOverrides() []BumpRule

BumpOverrides returns the configured version-bump override rules (versioning.bump.overrides), or nil. Nil-safe.

func (Versioning) StayAtV0 added in v0.69.0

func (v Versioning) StayAtV0() bool

StayAtV0 reports whether versioning.bump.stay_at_v0 is set. Nil-safe.

Jump to

Keyboard shortcuts

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