changelog

package
v0.0.0-...-03ca8a1 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RenderJSON

func RenderJSON(cl *ChangeLog, repoRoot string, baseDir string, w io.Writer) error

RenderJSON writes a full changelog in JSON format to w. baseDir controls image-path rewriting and resource collection (pass "" to skip).

func RenderLog

func RenderLog(cl *ChangeLog, baseDir string, previewMaxLen int, w io.Writer) error

RenderLog writes a human-readable, columnar overview of the changelog groups to w. baseDir is used to compute display-friendly relative paths (pass the repository root or working directory).

func RenderLogJSON

func RenderLogJSON(cl *ChangeLog, repoRoot string, hints *LogHints, w io.Writer) error

RenderLogJSON writes a JSON representation of the log view (typically staging or a single version) to w. hints may be nil when not applicable.

func RenderMarkdown

func RenderMarkdown(cl *ChangeLog, baseDir string, w io.Writer) error

RenderMarkdown writes a full changelog in standard Markdown format to w. Sections are grouped by version (newest first) then by change type. baseDir is used to rewrite relative image paths in entry bodies so they resolve correctly from the caller's working directory. Pass "" to skip image-path rewriting.

func ResolveVersion

func ResolveVersion(entry changeentry.Entry, addedAt time.Time, hasGit bool, tags []semver.Tag) string

ResolveVersion determines the version label for an entry given its git add time.

Types

type ChangeLog

type ChangeLog struct {
	Module         changeentry.ModuleConfig
	InvalidEntries []InvalidEntry
	Groups         []VersionGroup
}

ChangeLog is the full ordered set of version groups. Groups are ordered: staging first (when present), then newest tag → oldest.

func ApplyVersionFilter

func ApplyVersionFilter(cl *ChangeLog, opts VersionFilterOptions) *ChangeLog

ApplyVersionFilter restricts the changelog according to opts.

func LoadChangeLog

func LoadChangeLog(repoRoot string, module changeentry.ModuleConfig, filter FilterOptions) (*ChangeLog, error)

LoadChangeLog reads every .md file from changesDir, resolves each file's version using git tags discovered at repoRoot, applies filter, and returns the fully grouped changelog.

When git is unavailable, all entries are assigned to the staging bucket. When git is available but tag metadata cannot be read, an error is returned. File-system errors are returned as-is.

func StagingOnly

func StagingOnly(cl *ChangeLog) *ChangeLog

StagingOnly returns a changelog that contains only the staging group.

func VersionOnly

func VersionOnly(cl *ChangeLog, version string) *ChangeLog

VersionOnly returns a changelog that contains only the named version group. Version matching is case-insensitive and tolerates a leading "v" on either side.

type EntryWithMeta

type EntryWithMeta struct {
	Entry            changeentry.Entry
	Module           changeentry.ModuleConfig
	Path             string    // absolute path to the .md file
	AddedAt          time.Time // author date of the commit that first added the file
	AddedCommitHash  string    // commit hash where the file was first introduced
	OriginalFilename string    // filename at first introduction
	HasGit           bool      // false when the file is untracked or git is unavailable
	Version          string    // "staging" or a version tag name / pinned release value
}

EntryWithMeta pairs a parsed change entry with the metadata derived from git history: when the file was first committed and which version it belongs to.

func (EntryWithMeta) BodyWithoutPreviewLine

func (e EntryWithMeta) BodyWithoutPreviewLine() string

BodyWithoutPreviewLine returns the body with the first content line removed (the line that Preview() extracts). This avoids duplicating the preview text inside the body. Returns empty string when nothing remains.

func (EntryWithMeta) ID

func (e EntryWithMeta) ID() string

func (EntryWithMeta) Preview

func (e EntryWithMeta) Preview() string

Preview returns the first non-empty line of the entry body with markdown formatting stripped (headings, bold, italic, etc.), suitable for single-line display.

type FilterOptions

type FilterOptions struct {
	Audience  string // keep only entries whose audience list contains this value
	Component string // keep only entries whose component list contains this value
	Type      string // keep only entries whose type matches this value
}

FilterOptions controls which entries are retained after loading.

type InvalidEntry

type InvalidEntry struct {
	Path   string
	Errors []error
}

type LogHints

type LogHints struct {
	LatestTag string
	NextTag   string
}

LogHints contains version hint metadata for log JSON output.

type Resource

type Resource struct {
	AbsPath string `json:"abs_path"`
	RelPath string `json:"rel_path"`
	EntryID string `json:"entry_id"`
}

Resource represents a non-markdown file referenced by a change entry body (e.g. an image). AbsPath is the resolved location on disk; RelPath is the path relative to the caller's working directory.

type TypeGroup

type TypeGroup struct {
	ChangeType changeentry.ChangeType
	Title      string
	Entries    []EntryWithMeta
}

TypeGroup holds all entries that share the same change type within one version group.

type VersionFilterOptions

type VersionFilterOptions struct {
	N           int    // max tagged releases to include (0 = all)
	ShowStaging bool   // include staging group
	OnlyStaging bool   // include only staging group
	Since       string // lower version boundary (inclusive)
}

VersionFilterOptions controls which version groups are retained after loading.

Evaluation order:

  1. OnlyStaging: keep only the staging group.
  2. Since: keep staging (when ShowStaging) + every version >= Since.
  3. N + ShowStaging: keep up to N tagged versions newest-first, plus staging when ShowStaging. N = 0 means unlimited.

type VersionGroup

type VersionGroup struct {
	Version    string      // "staging" or a version tag/release name
	Tag        *semver.Tag // nil for staging and pinned-but-untagged versions
	TypeGroups []TypeGroup
}

VersionGroup holds all entries attributed to one version (or staging).

func (VersionGroup) FormattedDate

func (g VersionGroup) FormattedDate() string

FormattedDate returns the tag date as an RFC 3339 timestamp, or an empty string when the date is unknown.

func (VersionGroup) IsStaging

func (g VersionGroup) IsStaging() bool

IsStaging reports whether this group contains unreleased changes.

func (VersionGroup) TotalEntries

func (g VersionGroup) TotalEntries() int

TotalEntries returns the sum of all entries across all type groups.

func (VersionGroup) VersionTitle

func (g VersionGroup) VersionTitle() string

VersionTitle returns a display-friendly heading for the version. For released versions, it strips a leading "v" prefix so that "v1.2.3" becomes "1.2.3" while the raw tag is preserved in Version.

Jump to

Keyboard shortcuts

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