Documentation
¶
Index ¶
- Constants
- Variables
- func BreakingHeadingPresent(changelogSection string) bool
- func BuildChangeBullet(summary string, prNumber int, prURL string) string
- func BuildCitation(prNumber int, prURL string) string
- func ExtractBreakingChanges(changelogSection string) (string, bool)
- func NormalizeBulletPrefix(line string) string
- func ParsedImpactIsKnownContractValue(trimmedImpact string) bool
- func Render(sec Section, opts RenderOpts) string
- func ValidateChangelogSection(parsed *Section) (bool, []string)
- func ValidateChangelogSectionFull(parsed *Section, opts ValidateOpts) (bool, []string)
- type AssemblyError
- type CustomerImpact
- type ExcludedPR
- type IncludedPR
- type MergedPR
- type RenderOpts
- type RenderResult
- type Section
- type ValidateOpts
Constants ¶
const RuleCBreakingOnlyWhenBreakingImpactMsg = "### Breaking changes section is only allowed when Customer impact: breaking; " +
"change to Customer impact: breaking or remove the ### Breaking changes heading."
RuleCBreakingOnlyWhenBreakingImpactMsg is the verbatim Rule C diagnostic from the PR changelog authoring spec.
Variables ¶
var ErrNoChangelogSection = errors.New("no ## Changelog section found in PR body")
ErrNoChangelogSection is returned by Parse when the PR body lacks a "## Changelog" heading.
Functions ¶
func BreakingHeadingPresent ¶
BreakingHeadingPresent reports whether changelogSection contains a ### Breaking changes heading line.
func BuildChangeBullet ¶
BuildChangeBullet matches buildChangeBullet in changelog-renderer.js.
func BuildCitation ¶
BuildCitation matches buildCitation in changelog-renderer.js.
func ExtractBreakingChanges ¶
ExtractBreakingChanges returns the markdown content under ### Breaking changes (heading line excluded), or ("", false) when the heading is absent or only whitespace content remains after trimEnd. Semantics match the legacy JavaScript breaking extractor (fences + end marker + ##/### boundaries).
func NormalizeBulletPrefix ¶
NormalizeBulletPrefix matches normalizeBulletPrefix in changelog-renderer.js.
func ParsedImpactIsKnownContractValue ¶
ParsedImpactIsKnownContractValue mirrors VALID_CUSTOMER_IMPACTS.has(customerImpact) in JS without mapping to enums.
func Render ¶
func Render(sec Section, opts RenderOpts) string
Render emits a deterministic markdown fragment for a single Included PR shaped like changelog-renderer.js' aggregated section parts (before multi-PR batching in RenderChangelogSection).
func ValidateChangelogSection ¶
ValidateChangelogSection mirrors the prior JavaScript validateChangelogSection helper.
func ValidateChangelogSectionFull ¶
func ValidateChangelogSectionFull(parsed *Section, opts ValidateOpts) (bool, []string)
ValidateChangelogSectionFull mirrors validateChangelogSectionFull from that same legacy implementation.
Types ¶
type AssemblyError ¶
type CustomerImpact ¶
type CustomerImpact int
CustomerImpact mirrors the changelog contract's discrete impact values. Explicit "Customer impact omitted" differs from Customer impact: none; use ImpactPresent and/or ImpactRaw alongside the enum (ImpactNone mirrors none but is ambiguous when ImpactPresent is false).
const ( ImpactNone CustomerImpact = iota ImpactFix ImpactEnhancement ImpactBreaking )
func ParseCustomerImpact ¶
func ParseCustomerImpact(s string) (CustomerImpact, bool)
ParseCustomerImpact maps a changelog line value to CustomerImpact when it is exactly one of none|fix|enhancement|breaking (case-sensitive, per workflow contract parity with JS helpers).
func (CustomerImpact) MarshalJSON ¶
func (i CustomerImpact) MarshalJSON() ([]byte, error)
func (CustomerImpact) RequiresSummary ¶
func (i CustomerImpact) RequiresSummary() bool
RequiresSummary mirrors validateChangelogSection: summary is required unless impact is exactly "none".
func (CustomerImpact) String ¶
func (i CustomerImpact) String() string
func (*CustomerImpact) UnmarshalJSON ¶
func (i *CustomerImpact) UnmarshalJSON(data []byte) error
type ExcludedPR ¶
type IncludedPR ¶
type RenderOpts ¶
RenderOpts selects PR metadata rendered into CHANGELOG citations.
changelog-renderer.js currently only consumes PR number + URL for deterministic output. Additional authoring metadata (contributor attribution, changelog links, etc.) is reserved here.
type RenderResult ¶
type RenderResult struct {
Success bool
SectionBody string
Errors []AssemblyError
Included []IncludedPR
Excluded []ExcludedPR
}
func RenderChangelogSection ¶
func RenderChangelogSection(merged []MergedPR) RenderResult
RenderChangelogSection matches renderChangelogSection in changelog-renderer.js.
type Section ¶
type Section struct {
CustomerImpact CustomerImpact `json:"customer_impact"`
ImpactPresent bool `json:"impact_present,omitempty"`
// ImpactRaw mirrors parseChangelogSection's trimmed customerImpact string (empty means missing capture).
ImpactRaw string `json:"impact_raw,omitempty"`
Summary string `json:"summary,omitempty"`
BreakingChanges string `json:"breaking_changes,omitempty"`
BreakingHeadingPresent bool `json:"breaking_heading_present"`
Raw string `json:"raw"`
}
Section is the canonical parsed representation of a PR body's ## Changelog section.
func Parse ¶
Parse parses a PR body's ## Changelog section into Section (parseChangelogSectionFull parity).
It returns ErrNoChangelogSection when ## Changelog is absent (including empty bodies).
Parsing is intentionally non-throwing beyond missing sections; callers apply ValidateChangelogSection / ValidateChangelogSectionFull to mirror the JS layering.
type ValidateOpts ¶
type ValidateOpts struct {
RelaxBreakingImpactMatch bool
}
ValidateOpts configures validateChangelogSectionFull parity checks.
By default (zero value), JS parity treats rule C ("### Breaking changes is only allowed when Customer impact: breaking...") as enabled, matching `{ enforceBreakingImpactMatch: true }` in validateChangelogSectionFull.
Set RelaxBreakingImpactMatch to replicate changelog-renderer.js release-time rendering, which disables that check via `{ enforceBreakingImpactMatch: false }`.