Documentation
¶
Index ¶
- Variables
- func AllowedCommitTypes(cfg *config.Config) []string
- func BuildChangelogPipeline(runner port.Runner, cfg *config.Config, resolver versioning.Resolver, ...) (*pipeline.ChangelogPipeline, error)
- func BuildPipeline(runner port.Runner, cfg *config.Config, resolver versioning.Resolver, ...) (*pipeline.Pipeline, error)
- func CheckBranch(runner port.Runner, cfg *config.Config, env string, force bool) error
- func CheckCliff(runner port.Runner, driver *config.ContentDriver, mode, policy string) (bool, error)
- func CurrentTag(runner port.Runner, cfg *config.Config, env string) (string, error)
- func CurrentVersion(runner port.Runner, cfg *config.Config, env string) (string, error)
- func EffectiveCliffConfig(cfg *config.Config, driver *config.ContentDriver, mode, env string) (string, error)
- func IsPromotionGuard(err error) bool
- func NewResolver(cfg *config.Config, env string, force bool, versionOverride, buildID string, ...) (versioning.Resolver, error)
- func PreflightCheck(runner port.Runner) error
- func ReadGPGSign(runner port.Runner) bool
- func ResolveEnv(env string, cfg *config.Config, runner port.Runner) (string, error)
- func ResolveFromLatestTag(runner port.Runner, cfg *config.Config, env string) (string, bool, error)
- func RuntimeCheck(runner port.Runner, cfg *config.Config, env string, header func(title string), ...)
- func ValidateBuildID(build string) error
- func ValidateVersionOverride(version string) error
- func VerifyCommit(cfg *config.Config, message string) error
- type CommitCheckResult
- type PipelineOpts
- type RuntimeCheckItem
Constants ¶
This section is empty.
Variables ¶
var DefaultCommitTypes = commitTypeNames(config.EffectiveTypes(nil))
DefaultCommitTypes is the type allow-list applied when commits.types adds no overrides: the names of the built-in default type set (config.EffectiveTypes(nil)).
Functions ¶
func AllowedCommitTypes ¶ added in v0.44.0
AllowedCommitTypes returns the effective commit-type allow-list: the names of config.EffectiveTypes(commits.types) — the built-in defaults with the user's commits.types merged over them. Single source of truth shared by VerifyCommit and the commit wizard.
func BuildChangelogPipeline ¶ added in v0.6.0
func BuildChangelogPipeline(runner port.Runner, cfg *config.Config, resolver versioning.Resolver, opts PipelineOpts) (*pipeline.ChangelogPipeline, error)
BuildChangelogPipeline constructs a ChangelogPipeline from config.
func BuildPipeline ¶
func BuildPipeline(runner port.Runner, cfg *config.Config, resolver versioning.Resolver, opts PipelineOpts) (*pipeline.Pipeline, error)
BuildPipeline constructs a release Pipeline from config. All generator and platform instances are created here — none are created in internal/cmd/.
func CheckBranch ¶ added in v0.20.0
CheckBranch enforces the per-environment branch guard: when the active environment declares a branch, the current git branch must match it. This prevents operating on an environment (e.g. releasing prod) from the wrong branch. It is a no-op when env is empty or the environment has no branch set. force bypasses the check entirely.
func CheckCliff ¶ added in v0.6.0
func CheckCliff(runner port.Runner, driver *config.ContentDriver, mode, policy string) (bool, error)
CheckCliff runs git-cliff --context --no-exec against the effective merged config for the given content driver, applying the remote_metadata policy. mode must be "changelog" or "release-notes". Returns whether the check fell back to --offline (degraded, optional policy) and an error if git-cliff rejected the config. The caller's driver is never mutated — the policy is applied to a copy.
func CurrentTag ¶ added in v0.4.0
CurrentTag returns the latest existing git tag for the given strategy and environment. For single-env strategies, env is ignored. For per-env strategies, env is required.
func CurrentVersion ¶ added in v0.19.0
CurrentVersion returns the bare semantic version of the latest tag (the tag with any prefix / env / build components stripped). For per-env strategies the version is parsed via the effective tag_format; for single-env strategies the tag prefix is stripped.
func EffectiveCliffConfig ¶ added in v0.6.0
func EffectiveCliffConfig(cfg *config.Config, driver *config.ContentDriver, mode, env string) (string, error)
EffectiveCliffConfig returns the effective merged git-cliff TOML for the given content driver and mode ("changelog" or "release-notes"). cfg and env are used to derive the build-id postprocessor (when versioning.tag_format contains {build}) so the output matches what the pipeline actually feeds git-cliff.
If driver is nil or has no generator set, the embedded default TOML is returned. Returns an error if driver.Generator is set to something other than "git-cliff".
func IsPromotionGuard ¶ added in v0.8.0
IsPromotionGuard reports whether err is one of the per-env promotion guards (E001/E002/E003 from ADR-0007). The cmd layer uses this to map such failures to exit code 4 without importing the perenv package directly.
func NewResolver ¶
func NewResolver(cfg *config.Config, env string, force bool, versionOverride, buildID string, runner port.Runner) (versioning.Resolver, error)
NewResolver builds the appropriate versioning.Resolver from config. env is the active environment name (empty for non-per-env strategies). force is the --force flag value. versionOverride is set when --version X.Y.Z is passed; when non-empty a StaticResolver is returned for all strategies, bypassing git calls entirely. buildID is set when --build <id> is passed; requires versionOverride to be set.
func PreflightCheck ¶ added in v0.6.0
PreflightCheck verifies git binary availability and git user name/email. Called automatically before heraut release and heraut changelog.
func ReadGPGSign ¶ added in v0.12.0
ReadGPGSign reads tag.gpgSign from git config and returns true when it is set to "true". Any error (key absent, git not available) is treated as false — non-signing is the safe default. Callers should pass a non-dry-run runner so the config is always read regardless of --dry-run.
func ResolveEnv ¶ added in v0.34.0
ResolveEnv resolves the --env flag value before any pipeline work. When env is "auto", it reads the current branch and matches it against configured environments' branch fields. All other values (including "") are returned as-is without calling git.
func ResolveFromLatestTag ¶ added in v0.45.0
ResolveFromLatestTag returns a rev-range string of the form "<tag>..HEAD". With cfg it delegates to CurrentTag (strategy-aware); without cfg it falls back to git describe --tags --abbrev=0. Returns ("", true, nil) when no tags exist — the caller should warn and check full history. Returns ("", false, err) on unexpected git failures.
func RuntimeCheck ¶ added in v0.6.0
func RuntimeCheck( runner port.Runner, cfg *config.Config, env string, header func(title string), dispatch func(name string, run func() RuntimeCheckItem), )
RuntimeCheck verifies all runtime dependencies, grouped into three sections: Git, Platforms, and Generators. header is called once per section before its items. dispatch is called once per item with the label shown while the check runs; the run function performs the check and returns the result.
env selects the active environment for the Platforms section: when non-empty and cfg.Environments[env].Release.Platforms is non-empty, it replaces the root release.platforms list entirely (same semantics as the release pipeline's effective-platforms resolution). An empty env, or an env with no platform override, checks the root list.
Check order:
Git: git binary → user.name → user.email → working tree
Platforms: one row per effective release.platforms entry, or
glab (GitLab) → gh (GitHub) as a binary-only fallback
Generators: git-cliff → communique
Configured tools are hard errors when missing; unconfigured-but-supported tools warn when absent and succeed silently when present.
func ValidateBuildID ¶ added in v0.19.0
ValidateBuildID reports whether a --build value is usable as a tag component. Delegates to tagfmt so cmd does not import the versioning layer directly.
func ValidateVersionOverride ¶ added in v0.32.0
ValidateVersionOverride reports whether a --version value is usable as a tag/version override. Delegates to tagfmt so cmd does not import the versioning layer directly.
func VerifyCommit ¶ added in v0.40.0
VerifyCommit validates message against the conventional-commit grammar and the configured (or default) type allow-list. Merge and fixup commits are always skipped, unconditionally. cfg may be nil (no .heraut.yml present) — the default type list applies.
Types ¶
type CommitCheckResult ¶ added in v0.43.0
type CommitCheckResult struct {
SHA string // git's abbreviated hash (%h) — length varies with repo size/core.abbrev
Subject string // first line of the message
Err error // nil = valid (or skipped merge/fixup)
}
CommitCheckResult records the outcome of validating one commit in a range.
func CheckCommitRange ¶ added in v0.43.0
func CheckCommitRange(runner port.Runner, cfg *config.Config, revRange string) ([]CommitCheckResult, error)
CheckCommitRange validates every commit in revRange (or the full history reachable from HEAD when revRange is "") against the same grammar and type allow-list VerifyCommit applies to a single message. Every commit is evaluated — an invalid commit does not stop the scan. Merge and fixup commits are skipped via VerifyCommit's existing, unconditional skip — no separate handling needed here.
type PipelineOpts ¶
type PipelineOpts struct {
DryRun bool
Force bool
VersionOverride string
Env string
Out io.Writer
// Commit and Tag are used by the changelog pipeline only.
Commit bool
Tag bool
// NoPush is used by the changelog pipeline only: when true, the commit and tag
// are created locally but not pushed.
NoPush bool
// SignTags mirrors git config tag.gpgSign — when true the pipeline creates
// signed tags (-s) instead of annotated ones. Set by the caller via ReadGPGSign.
SignTags bool
// Logger receives operator-debug diagnostics (nil discards them). See forge ADR-0011.
Logger *slog.Logger
}
PipelineOpts carries runtime options for building a pipeline.
type RuntimeCheckItem ¶ added in v0.6.0
type RuntimeCheckItem struct {
Name string
Value string // resolved value (e.g. version string, identity, "clean")
Err error
IsWarn bool // advisory only — shown with ! but does not fail the overall check
}
RuntimeCheckItem records the outcome of one runtime check.