Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func FindSectionEnd ¶
FindSectionEnd returns the exclusive index of the first ## line after startIndex, or len(lines) if none — matching changelog-rewriter.js findSectionEnd.
func RewriteSection ¶
func RewriteSection(content []byte, rewrite SectionRewrite, mode RewriteMode, targetVersion string) ([]byte, error)
RewriteSection mirrors rewriteChangelogSection from changelog-rewriter.js.
When mode is ModeRelease, targetVersion is the semver without a leading 'v'; otherwise it is ignored.
RewriteSection returns an error when mode is unrecognized.
func UpdateLinks ¶
UpdateLinks applies rewriteLinkTable from changelog-rewriter.js for each entry (sequentially).
Behaviour details (mirrors JS exactly for one entry — the common case): only the [Unreleased] line anchors mutation; inserting a missing [targetVersion]: line nests it adjacent to Unreleased, preserving ordering of unrelated link lines afterward.
Types ¶
type LinkEntry ¶
LinkEntry is one release bump for the changelog compare link table ([Unreleased]: / [x.y.z]: lines).
type RewriteMode ¶
type RewriteMode int
RewriteMode selects which CHANGELOG section heading rewriteChangelogSection targets.
const ( // ModeUnreleased updates the ## [Unreleased] section. ModeUnreleased RewriteMode = iota // ModeRelease updates by target version (and may remove Unreleased in the same pass). ModeRelease )
type SectionRewrite ¶
type SectionRewrite struct {
// Header is the literal heading without the leading "## ", e.g.
// "[Unreleased]" or "[1.2.3] - 2025-05-01".
Header string
// Body is the Markdown rendered under Header (parity with changelog-rewriter.js: pasted verbatim).
Body string
}
SectionRewrite describes a CHANGELOG release or Unreleased section to write in place.