Documentation
¶
Index ¶
- Variables
- func DefaultExcludePatterns() []string
- func GroupCommits(commits []*ParsedCommit, groups []GroupConfig) map[string][]*GroupedCommit
- func Register(cfg *config.ChangelogGeneratorConfig)
- func ResetChangelogGenerator()
- func SortedGroupKeys(grouped map[string][]*GroupedCommit) []string
- type ChangelogGenerator
- type ChangelogGeneratorPlugin
- func (p *ChangelogGeneratorPlugin) Description() string
- func (p *ChangelogGeneratorPlugin) GenerateForVersion(version, previousVersion, bumpType string) error
- func (p *ChangelogGeneratorPlugin) GetConfig() *Config
- func (p *ChangelogGeneratorPlugin) IsEnabled() bool
- func (p *ChangelogGeneratorPlugin) Name() string
- func (p *ChangelogGeneratorPlugin) Version() string
- type CommitInfo
- type Config
- type Contributor
- type ContributorsConfig
- type GenerateResult
- type Generator
- func (g *Generator) GenerateVersionChangelog(version, previousVersion string, commits []CommitInfo) (string, error)
- func (g *Generator) GenerateVersionChangelogWithResult(version, previousVersion string, commits []CommitInfo) GenerateResult
- func (g *Generator) MergeVersionedFiles() error
- func (g *Generator) WriteUnifiedChangelog(newContent string) error
- func (g *Generator) WriteVersionedFile(version, content string) error
- type GroupCommitsResult
- type GroupConfig
- type GroupedCommit
- type ParsedCommit
- type RemoteInfo
- type RepositoryConfig
Constants ¶
This section is empty.
Variables ¶
var ( GetCommitsWithMetaFn = getCommitsWithMeta GetRemoteInfoFn = getRemoteInfo GetLatestTagFn = getLatestTag GetContributorsFn = getContributors )
Mockable functions for testing.
var ( RegisterChangelogGeneratorFn = registerChangelogGenerator GetChangelogGeneratorFn = getChangelogGenerator )
var KnownProviders = map[string]string{
"github.com": "github",
"gitlab.com": "gitlab",
"codeberg.org": "codeberg",
"gitea.io": "gitea",
"bitbucket.org": "bitbucket",
"sr.ht": "sourcehut",
}
KnownProviders maps hostnames to provider names.
Functions ¶
func DefaultExcludePatterns ¶
func DefaultExcludePatterns() []string
DefaultExcludePatterns returns the default patterns to exclude from changelog.
func GroupCommits ¶
func GroupCommits(commits []*ParsedCommit, groups []GroupConfig) map[string][]*GroupedCommit
GroupCommits groups parsed commits by their type using the configured groups. The order is derived from the position in the groups slice (index) unless explicitly overridden by the Order field (if > 0). If includeNonConventional is true, commits without a type are included in "Other Changes". If false, they are returned in SkippedNonConventional for warning purposes.
func Register ¶
func Register(cfg *config.ChangelogGeneratorConfig)
Register registers the changelog generator plugin with the given configuration.
func ResetChangelogGenerator ¶
func ResetChangelogGenerator()
ResetChangelogGenerator clears the registered changelog generator (for testing).
func SortedGroupKeys ¶
func SortedGroupKeys(grouped map[string][]*GroupedCommit) []string
SortedGroupKeys returns group labels sorted by their order.
Types ¶
type ChangelogGenerator ¶
type ChangelogGenerator interface {
Name() string
Description() string
Version() string
// GenerateForVersion generates changelog for a specific version bump.
GenerateForVersion(version, previousVersion, bumpType string) error
// IsEnabled returns whether the plugin is enabled.
IsEnabled() bool
// GetConfig returns the plugin configuration.
GetConfig() *Config
}
ChangelogGenerator defines the interface for changelog generation.
type ChangelogGeneratorPlugin ¶
type ChangelogGeneratorPlugin struct {
// contains filtered or unexported fields
}
ChangelogGeneratorPlugin implements the ChangelogGenerator interface.
func NewChangelogGenerator ¶
func NewChangelogGenerator(cfg *Config) *ChangelogGeneratorPlugin
NewChangelogGenerator creates a new changelog generator plugin.
func (*ChangelogGeneratorPlugin) Description ¶
func (p *ChangelogGeneratorPlugin) Description() string
Description returns the plugin description.
func (*ChangelogGeneratorPlugin) GenerateForVersion ¶
func (p *ChangelogGeneratorPlugin) GenerateForVersion(version, previousVersion, bumpType string) error
GenerateForVersion generates changelog for a version bump.
func (*ChangelogGeneratorPlugin) GetConfig ¶
func (p *ChangelogGeneratorPlugin) GetConfig() *Config
GetConfig returns the plugin configuration.
func (*ChangelogGeneratorPlugin) IsEnabled ¶
func (p *ChangelogGeneratorPlugin) IsEnabled() bool
IsEnabled returns whether the plugin is enabled.
func (*ChangelogGeneratorPlugin) Name ¶
func (p *ChangelogGeneratorPlugin) Name() string
Name returns the plugin name.
func (*ChangelogGeneratorPlugin) Version ¶
func (p *ChangelogGeneratorPlugin) Version() string
Version returns the plugin version.
type CommitInfo ¶
type CommitInfo struct {
Hash string
ShortHash string
Subject string
Author string
AuthorEmail string
}
CommitInfo represents a git commit with metadata.
type Config ¶
type Config struct {
// Enabled controls whether the plugin is active.
Enabled bool
// Mode determines output style: "versioned", "unified", or "both".
Mode string
// ChangesDir is the directory for version-specific changelog files.
ChangesDir string
// ChangelogPath is the path to the unified changelog file.
ChangelogPath string
// HeaderTemplate is the path to a custom header template file.
HeaderTemplate string
// Repository contains git repository settings for link generation.
Repository *RepositoryConfig
// Groups defines commit grouping rules.
Groups []GroupConfig
// ExcludePatterns lists regex patterns for commits to exclude.
ExcludePatterns []string
// IncludeNonConventional includes non-conventional commits in "Other Changes" section.
// When false (default), these commits are skipped with a warning.
IncludeNonConventional bool
// GroupIcons maps default group labels to icons (used when Groups is empty).
GroupIcons map[string]string
// Contributors configures the contributors section.
Contributors *ContributorsConfig
}
Config holds the internal configuration for the changelog generator plugin.
func DefaultConfig ¶
func DefaultConfig() *Config
DefaultConfig returns the default changelog generator configuration.
func FromConfigStruct ¶
func FromConfigStruct(cfg *config.ChangelogGeneratorConfig) *Config
FromConfigStruct converts the config package struct to internal config.
type Contributor ¶
type Contributor struct {
Name string
Username string
Email string
Host string // The git host for URL generation
}
Contributor represents a unique contributor.
type ContributorsConfig ¶
ContributorsConfig configures the contributors section.
type GenerateResult ¶
type GenerateResult struct {
Content string
SkippedNonConventional []*ParsedCommit
}
GenerateResult contains the generated changelog and any warnings.
type Generator ¶
type Generator struct {
// contains filtered or unexported fields
}
Generator handles changelog content generation.
func NewGenerator ¶
NewGenerator creates a new changelog generator.
func (*Generator) GenerateVersionChangelog ¶
func (g *Generator) GenerateVersionChangelog(version, previousVersion string, commits []CommitInfo) (string, error)
GenerateVersionChangelog generates the changelog content for a version.
func (*Generator) GenerateVersionChangelogWithResult ¶
func (g *Generator) GenerateVersionChangelogWithResult(version, previousVersion string, commits []CommitInfo) GenerateResult
GenerateVersionChangelogWithResult generates the changelog content and returns detailed result.
func (*Generator) MergeVersionedFiles ¶
MergeVersionedFiles merges all versioned changelog files into a unified CHANGELOG.md.
func (*Generator) WriteUnifiedChangelog ¶
WriteUnifiedChangelog writes to the unified CHANGELOG.md file.
func (*Generator) WriteVersionedFile ¶
WriteVersionedFile writes the changelog to a version-specific file.
type GroupCommitsResult ¶
type GroupCommitsResult struct {
Grouped map[string][]*GroupedCommit
SkippedNonConventional []*ParsedCommit
}
GroupCommitsResult contains grouped commits and any skipped non-conventional commits.
func GroupCommitsWithOptions ¶
func GroupCommitsWithOptions(commits []*ParsedCommit, groups []GroupConfig, includeNonConventional bool) GroupCommitsResult
GroupCommitsWithOptions groups commits with configurable handling of non-conventional commits.
type GroupConfig ¶
GroupConfig defines a grouping rule for commits.
func DefaultGroups ¶
func DefaultGroups() []GroupConfig
DefaultGroups returns the default commit grouping rules (git-cliff style). Order is derived from array position (first = 0, second = 1, etc.)
type GroupedCommit ¶
type GroupedCommit struct {
*ParsedCommit
GroupLabel string
GroupIcon string
GroupOrder int
}
GroupedCommit represents a commit with its group assignment.
type ParsedCommit ¶
type ParsedCommit struct {
CommitInfo
Type string // feat, fix, docs, etc.
Scope string // Optional scope in parentheses
Description string // The commit description after the colon
Breaking bool // Has breaking change indicator (! or BREAKING CHANGE footer)
PRNumber string // Extracted PR/MR number if present
}
ParsedCommit represents a fully parsed conventional commit.
func FilterCommits ¶
func FilterCommits(commits []*ParsedCommit, excludePatterns []string) []*ParsedCommit
FilterCommits filters out commits matching exclude patterns.
func ParseCommits ¶
func ParseCommits(commits []CommitInfo) []*ParsedCommit
ParseCommits parses a slice of CommitInfo into ParsedCommits.
func ParseConventionalCommit ¶
func ParseConventionalCommit(commit CommitInfo) *ParsedCommit
ParseConventionalCommit parses a commit message into its components. Returns nil if the commit doesn't follow conventional commit format.
type RemoteInfo ¶
type RemoteInfo struct {
Provider string // github, gitlab, codeberg, gitea, bitbucket, custom
Host string // e.g., github.com, gitlab.com, codeberg.org
Owner string
Repo string
}
RemoteInfo holds parsed git remote information. Supports multiple providers: github, gitlab, codeberg, gitea, bitbucket, etc.
type RepositoryConfig ¶
type RepositoryConfig struct {
// Provider is the git hosting provider: github, gitlab, codeberg, gitea, bitbucket, custom.
Provider string
// Host is the git server hostname (e.g., "github.com", "gitlab.com").
Host string
// Owner is the repository owner/organization.
Owner string
// Repo is the repository name.
Repo string
// AutoDetect enables automatic detection from git remote.
AutoDetect bool
}
RepositoryConfig holds git repository settings for changelog links. Supports multiple providers: github, gitlab, codeberg, gitea, bitbucket, custom.