section

package
v0.16.0 Latest Latest
Warning

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

Go to latest
Published: May 25, 2026 License: Apache-2.0 Imports: 8 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

View Source
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

View Source
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

func BreakingHeadingPresent(changelogSection string) bool

BreakingHeadingPresent reports whether changelogSection contains a ### Breaking changes heading line.

func BuildChangeBullet

func BuildChangeBullet(summary string, prNumber int, prURL string) string

BuildChangeBullet matches buildChangeBullet in changelog-renderer.js.

func BuildCitation

func BuildCitation(prNumber int, prURL string) string

BuildCitation matches buildCitation in changelog-renderer.js.

func ExtractBreakingChanges

func ExtractBreakingChanges(changelogSection string) (string, bool)

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

func NormalizeBulletPrefix(line string) string

NormalizeBulletPrefix matches normalizeBulletPrefix in changelog-renderer.js.

func ParsedImpactIsKnownContractValue

func ParsedImpactIsKnownContractValue(trimmedImpact string) bool

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

func ValidateChangelogSection(parsed *Section) (bool, []string)

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 AssemblyError struct {
	PRNumber int
	PRURL    string
	Reason   string
}

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 ExcludedPR struct {
	PRNumber        int
	PRURL           string
	Reason          string
	BreakingChanges *string
}

type IncludedPR

type IncludedPR struct {
	PRNumber        int
	PRURL           string
	Summary         string
	BreakingChanges *string
}

type MergedPR

type MergedPR struct {
	Number         int
	Title          string
	URL            string
	Labels         []string
	Body           string
	MergeCommitSHA string
	AuthorLogin    string
}

type RenderOpts

type RenderOpts struct {
	PRNumber int
	PRURL    string
}

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

func Parse(body []byte) (Section, error)

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 }`.

Jump to

Keyboard shortcuts

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