changelogparser

package
v0.10.0 Latest Latest
Warning

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

Go to latest
Published: Jan 28, 2026 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	RegisterChangelogParserFn = registerChangelogParser
	GetChangelogParserFn      = getChangelogParser
)

Functions

func DetectFormat added in v0.8.0

func DetectFormat(content string) string

DetectFormat is exported for testing purposes.

func Register

func Register(cfg *Config)

Register registers the changelog parser plugin with the sley plugin system.

func ResetChangelogParser

func ResetChangelogParser()

ResetChangelogParser clears the registered changelog parser (for testing).

func Unregister

func Unregister()

Unregister removes the changelog parser plugin.

func ValidFormats added in v0.8.0

func ValidFormats() []string

ValidFormats returns the list of valid parser format names.

Types

type ChangelogInferrer

type ChangelogInferrer interface {
	Name() string
	Description() string
	Version() string
	InferBumpType() (string, error)
	ValidateHasEntries() error
}

ChangelogInferrer defines the interface for parsing changelog files.

type ChangelogParserPlugin

type ChangelogParserPlugin struct {
	// contains filtered or unexported fields
}

ChangelogParserPlugin implements the ChangelogInferrer interface.

func NewChangelogParser

func NewChangelogParser(cfg *Config) *ChangelogParserPlugin

NewChangelogParser creates a new changelog parser plugin.

func (*ChangelogParserPlugin) Description

func (p *ChangelogParserPlugin) Description() string

func (*ChangelogParserPlugin) GetConfig

func (p *ChangelogParserPlugin) GetConfig() *Config

func (*ChangelogParserPlugin) GetFormat added in v0.8.0

func (p *ChangelogParserPlugin) GetFormat() string

GetFormat returns the configured format.

func (*ChangelogParserPlugin) InferBumpType

func (p *ChangelogParserPlugin) InferBumpType() (string, error)

InferBumpType parses the changelog and infers the bump type.

func (*ChangelogParserPlugin) InferBumpTypeWithConfidence added in v0.8.0

func (p *ChangelogParserPlugin) InferBumpTypeWithConfidence() (bumpType, confidence string, err error)

InferBumpTypeWithConfidence returns bump type and confidence level.

func (*ChangelogParserPlugin) IsEnabled

func (p *ChangelogParserPlugin) IsEnabled() bool

func (*ChangelogParserPlugin) Name

func (p *ChangelogParserPlugin) Name() string

func (*ChangelogParserPlugin) ShouldTakePrecedence

func (p *ChangelogParserPlugin) ShouldTakePrecedence() bool

ShouldTakePrecedence returns true if changelog parser should take precedence.

func (*ChangelogParserPlugin) ValidateHasEntries

func (p *ChangelogParserPlugin) ValidateHasEntries() error

ValidateHasEntries validates that the Unreleased section has entries.

func (*ChangelogParserPlugin) Version

func (p *ChangelogParserPlugin) Version() string

type ChangelogSection

type ChangelogSection struct {
	Version     string
	Date        string
	Subsections map[string][]string
}

ChangelogSection represents a parsed section from CHANGELOG.md.

type Config

type Config struct {
	Enabled                  bool
	Path                     string
	RequireUnreleasedSection bool
	InferBumpType            bool
	Priority                 string
	Format                   string
	GroupedSectionMap        map[string]string
}

Config holds configuration for the changelog parser plugin.

func DefaultConfig

func DefaultConfig() *Config

DefaultConfig returns the default changelog parser configuration.

type ParsedEntry added in v0.8.0

type ParsedEntry struct {
	Category        string // Semantic: Added, Changed, Fixed, Removed, etc.
	OriginalSection string // As it appeared in changelog
	Description     string // Entry text (cleaned)
	Scope           string // Optional scope
	IsBreaking      bool
	CommitType      string // Original type if parseable
}

ParsedEntry represents a single changelog entry.

type ParsedSection added in v0.8.0

type ParsedSection struct {
	Version            string
	Date               string
	HasEntries         bool
	Entries            []ParsedEntry
	InferredBumpType   string // major, minor, patch, or empty
	BumpTypeConfidence string // high, medium, low, none
}

ParsedSection represents a parsed changelog section (format-agnostic).

type Parser added in v0.8.0

type Parser interface {
	// ParseUnreleased extracts the Unreleased/latest version section.
	ParseUnreleased(reader io.Reader) (*ParsedSection, error)
	// Format returns the format name this parser handles.
	Format() string
}

Parser defines the interface for changelog format parsers.

func NewParser added in v0.8.0

func NewParser(format string, cfg *Config) (Parser, error)

NewParser creates a parser for the specified format.

type UnreleasedSection

type UnreleasedSection struct {
	HasEntries  bool
	Added       []string
	Changed     []string
	Deprecated  []string
	Removed     []string
	Fixed       []string
	Security    []string
	Subsections map[string][]string
}

UnreleasedSection represents the parsed Unreleased section with change types.

func FromParsedSection added in v0.8.0

func FromParsedSection(ps *ParsedSection) *UnreleasedSection

FromParsedSection creates UnreleasedSection from ParsedSection.

func (*UnreleasedSection) InferBumpType

func (s *UnreleasedSection) InferBumpType() (string, error)

InferBumpType determines the bump type based on changelog entries.

func (*UnreleasedSection) ToParsedSection added in v0.8.0

func (s *UnreleasedSection) ToParsedSection() *ParsedSection

ToParsedSection converts UnreleasedSection to format-agnostic ParsedSection.

Jump to

Keyboard shortcuts

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