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 CurrentTag(runner port.Runner, cfg *config.Config, env string) (string, error)
- func CurrentVersion(runner port.Runner, cfg *config.Config, env string) (string, error)
- func HasResolvablePublishTarget(runner port.Runner, cfg *config.Config, env string) bool
- func IsPromotionGuard(err error) bool
- func NewMemoizingRunner(r port.Runner) port.Runner
- 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
- type CommitCheckResult
- type CommitSummary
- type PipelineOpts
- type RuntimeCheckItem
- type TicketCheckResult
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 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 HasResolvablePublishTarget ¶ added in v0.57.0
HasResolvablePublishTarget reports whether cfg has at least one publish destination for env: a non-empty effective release.targets list, or — when that list is empty — a forge that resolves to a type with a publish driver, from cfg/CI env/git origin (the same zero-config synthesis buildTargetPlatforms performs, via synthesizeDefaultTarget — T221 taught both to treat a driver-less resolved forge, e.g. azure_devops, as equivalent to no forge resolved at all, so this preflight and the pipeline's own behavior can never disagree). This is heraut release's pre-flight gate: with release.platforms gone, "no entry in release.targets and nothing auto-detects to a publishable forge" is the only shape left that must hard-fail before the pipeline runs (see buildTargetPlatforms — resolving zero forges is not itself an error, since a changelog-only flow legitimately needs no publish target at all).
An *explicit* release.targets entry naming a driver-less forge is deliberately not caught here — that is a user-authored reference, and buildPlatform's own "unsupported platform" error is already specific and actionable when the pipeline actually tries to build it (T221).
A forge-resolution error here (e.g. an ambiguous multi-token machine) is deliberately treated as "not resolvable" rather than propagated: BuildPipeline performs the same resolution again and surfaces that error with full context, so this pre-flight only needs a yes/no answer.
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 NewMemoizingRunner ¶ added in v0.57.0
NewMemoizingRunner wraps r so repeated identical Run calls are served from cache.
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 --set-version X.Y.Z is passed; when non-empty a StaticResolver is returned for all strategies, bypassing git calls entirely. buildID is set when --set-build-id <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 two sections: Git and Platforms. 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.Targets is non-empty, it replaces the root release.targets list entirely (same semantics as the release pipeline's effective-targets resolution). An empty env, or an env with no target override, checks the root list.
Check order:
Git: git binary → user.name → user.email → working tree
Platforms: one row per effective release.targets entry (resolved against
forges:/CI env/git origin, same as `heraut release`), or
glab (GitLab) → gh (GitHub) as a binary-only fallback when
nothing resolves
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 --set-build-id 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 --set-version value is usable as a tag/version override. Delegates to tagfmt so cmd does not import the versioning layer directly.
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 CommitSummary ¶ added in v0.59.0
type CommitSummary struct {
Type string
Scope string
Breaking bool
Description string
Tickets []native.TicketMatch
}
CommitSummary is a verified commit's structural breakdown plus any detected commits.tickets references, for `heraut commit verify`'s recap output (T242).
func VerifyCommit ¶ added in v0.40.0
func VerifyCommit(cfg *config.Config, message string) (*CommitSummary, error)
VerifyCommit validates message against the conventional-commit grammar and the configured (or default) type allow-list. Merge and fixup commits are always skipped, unconditionally — nil, nil in that case, since there is no commit to summarize. cfg may be nil (no .heraut.yml present) — the default type list applies and no tickets are configured to match against.
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
// HerautVersion is the running heraut binary's version, propagated to the native generator
// so templates can render .Heraut.Version. Empty for dev builds.
HerautVersion string
// ReadRunner performs read-only operations (currently: forge git-origin detection) with a
// real, non-dry-run runner so `--dry-run` never changes what is resolved — only what is
// executed. Mirrors the readRunner already threaded into ResolveEnv/NewResolver/ReadGPGSign
// in internal/cmd. Falls back to the pipeline runner passed to BuildPipeline /
// BuildChangelogPipeline when nil (that runner is a real runner outside dry-run anyway).
ReadRunner port.Runner
// RegenerateChangelog forces the native changelog generator to rebuild + re-enrich the whole
// file instead of incrementally splicing the new section. Native only.
RegenerateChangelog bool
// Logger receives operator-debug diagnostics (nil discards them). See forge ADR-0011.
Logger *slog.Logger
// InteractiveRunner runs commands that may need a real terminal — a GPG pinentry prompt during
// `git commit`/a signed tag (T260) — connecting stdin/stdout/stderr directly instead of
// capturing them (forge v0.19.0's CmdRunner.Interactive). Nil falls back to the pipeline
// runner, which behaves exactly as before this option existed.
InteractiveRunner port.Runner
// NoHooks skips every configured hook for this run (--no-hooks), without touching config
// (ADR-0053).
NoHooks bool
}
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.
type TicketCheckResult ¶ added in v0.59.0
type TicketCheckResult struct {
SHA string
Subject string
Matches []native.TicketMatch
}
TicketCheckResult is one commit's ticket-pattern matches for `heraut commit tickets`.
func CheckTicketsInRange ¶ added in v0.59.0
func CheckTicketsInRange(runner port.Runner, cfg *config.Config, revRange string) ([]TicketCheckResult, error)
CheckTicketsInRange walks every commit in revRange (or the full history reachable from HEAD when revRange is "") and matches each against cfg.Tickets() (commits.tickets) using native.MatchTickets — the exact same matching applied when rendering changelog/ release-notes ticket links, against the same text (subject, then body on its own line when non-empty). A nil cfg or unconfigured commits.tickets yields zero matches per commit, not an error — callers decide whether "nothing configured" is worth failing on.