Documentation
¶
Overview ¶
Package changelog generates and parses changelogs from Conventional Commits, in pure Go.
It serves two directions:
- Generation. GenerateFromRepo walks a repository's git history (via go-git), parses each Conventional Commit, groups the entries by release and Category, and renders a changelog — replacing an external tool such as git-cliff with an in-process, dependency-free implementation. Options (WithSinceTag, WithMaxReleases, WithIncludeAll) bound and shape the output.
- Parsing. Parse reads existing changelog notes back into a structured Changelog; ParseFromArchive extracts and parses a changelog bundled in a release archive; FormatSummary renders a concise summary of a parsed changelog.
Commit classification follows the Conventional Commits specification: `feat`/`fix`/`perf`/etc. map to a Category, and both the `BREAKING CHANGE:` footer and its `BREAKING-CHANGE:` hyphenated synonym mark a breaking change.
The built-in `changelog` command (see pkg/cmd) embeds and displays the generated changelog at runtime.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func FormatSummary ¶
FormatSummary produces a human-readable summary of the changelog suitable for terminal output. Breaking changes appear first with a warning prefix.
func GenerateFromRepo ¶
func GenerateFromRepo(repoPath string, opts ...GenerateOption) (string, error)
GenerateFromRepo reads git history from the repository at repoPath and produces a full CHANGELOG.md string. The output is compatible with Parse().
Types ¶
type Category ¶
type Category int
Category classifies a change entry.
const ( // CategoryBreaking represents a breaking change requiring user action. CategoryBreaking Category = iota // CategoryFeature represents a new feature. CategoryFeature // CategoryFix represents a bug fix. CategoryFix // CategoryPerformance represents a performance improvement. CategoryPerformance // CategoryOther represents any other change (refactor, docs, chore, etc.). CategoryOther )
type Changelog ¶
type Changelog struct {
// FromVersion is the starting version (exclusive).
FromVersion string
// ToVersion is the ending version (inclusive).
ToVersion string
// Releases contains parsed releases ordered from oldest to newest.
Releases []Release
}
Changelog represents the parsed changelog across multiple releases.
func Parse ¶
Parse parses raw release notes markdown (as returned by SelfUpdater.GetReleaseNotes) into a structured Changelog.
func ParseFromArchive ¶
ParseFromArchive extracts and parses a CHANGELOG.md file from a gzipped tar release archive reader. Returns nil (not an error) if no changelog is found in the archive, allowing callers to fall back to API-based retrieval.
func (*Changelog) BreakingChanges ¶
BreakingChanges returns all breaking change entries across all releases.
func (*Changelog) EntriesByCategory ¶
EntriesByCategory returns all entries matching the given category across all releases.
func (*Changelog) HasBreakingChanges ¶
HasBreakingChanges returns true if any release contains breaking changes.
type Entry ¶
type Entry struct {
// Category is the type of change.
Category Category
// Scope is the conventional commit scope (e.g., "http", "chat"). May be empty.
Scope string
// Description is the change description text.
Description string
// Raw is the original unparsed line from the release notes.
Raw string
}
Entry represents a single change within a release.
type GenerateOption ¶
type GenerateOption func(*generateConfig)
GenerateOption configures changelog generation.
func WithIncludeAll ¶
func WithIncludeAll() GenerateOption
WithIncludeAll includes non-conventional commits under "Other".
func WithMaxReleases ¶
func WithMaxReleases(n int) GenerateOption
WithMaxReleases limits output to the N most recent releases.
func WithSinceTag ¶
func WithSinceTag(tag string) GenerateOption
WithSinceTag limits generation to releases after the given tag.