entities

package
v0.9.0 Latest Latest
Warning

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

Go to latest
Published: Mar 30, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const InitialReleaseVersion = "0.1.0"

InitialReleaseVersion is the version used when no previous release version is present in the changelog.

Variables

View Source
var (
	ErrNoVersionFoundInChangelog  = errors.New("no version found in the changelog")
	ErrNoChangesFoundInUnreleased = errors.New("no changes found in the unreleased section")
)

Functions

func DeduplicateEntries

func DeduplicateEntries(entries []string) []string

DeduplicateEntries removes duplicate and semantically overlapping changelog entries.

func FixSectionHeadings

func FixSectionHeadings(unreleasedSection []string)

FixSectionHeadings fixes the section headings in the unreleased section.

func InsertChangelogEntry

func InsertChangelogEntry(content string, entries []string) string

InsertChangelogEntry inserts one or more bullet entries into the "## [Unreleased]" / "### Changed" section of a Keep-a-Changelog formatted string.

func MakeNewSections

func MakeNewSections(
	sections map[string]*[]string,
	nextVersion semver.Version,
) []string

MakeNewSections creates new section contents for the beginning of the CHANGELOG file.

func MakeNewSectionsFromUnreleased

func MakeNewSectionsFromUnreleased(unreleasedSection []string, version semver.Version) []string

MakeNewSectionsFromUnreleased creates new section contents for initial release.

func ParseUnreleasedIntoSections

func ParseUnreleasedIntoSections(
	unreleasedSection []string,
	sections map[string]*[]string,
	currentSection *[]string,
	majorChanges, minorChanges, patchChanges *int,
)

ParseUnreleasedIntoSections parses the unreleased section into change type sections.

func ReclassifyEntriesByVerb added in v0.5.0

func ReclassifyEntriesByVerb(sections map[string]*[]string)

ReclassifyEntriesByVerb moves entries to the correct section based on their leading verb. For example, an entry "- removed old feature" under "### Changed" is moved to "### Removed".

func UpdateSection

func UpdateSection(
	unreleasedSection []string,
	nextVersion semver.Version,
) ([]string, *semver.Version, error)

UpdateSection updates the unreleased section and calculates the next version.

Types

type Changelog

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

Changelog encapsulates a Keep-a-Changelog formatted document as lines.

func NewChangelog

func NewChangelog(lines []string) *Changelog

NewChangelog creates a new Changelog from the given lines.

func (*Changelog) FindLatestVersion

func (c *Changelog) FindLatestVersion() (*semver.Version, error)

FindLatestVersion finds the latest version in the changelog lines.

func (*Changelog) IsUnreleasedEmpty

func (c *Changelog) IsUnreleasedEmpty() (bool, error)

IsUnreleasedEmpty checks whether the unreleased section of the changelog is empty.

func (*Changelog) Lines

func (c *Changelog) Lines() []string

Lines returns the underlying lines of the changelog.

func (*Changelog) Process

func (c *Changelog) Process() (*semver.Version, []string, error)

Process processes the changelog lines and returns the next version and the new content.

func (*Changelog) ProcessNew

func (c *Changelog) ProcessNew() (*semver.Version, []string, error)

ProcessNew handles changelogs that only have [Unreleased] section.

Jump to

Keyboard shortcuts

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