changelog

package
v0.0.0-...-cca5969 Latest Latest
Warning

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

Go to latest
Published: Jan 2, 2022 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

Package changelog has been designed to parse CHANGELOG.md and give access to the information about existing releases. However, in the future, it may support manipulating and generating changelogs as well if that kind of behaviour will be needed in our CLI tools.

It's based on the "Keep a Changelog" v1.0.0 specification: https://keepachangelog.com/en/1.0.0/

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Changelog

type Changelog struct {
	// Releases holds a list of all releases.
	Releases []Release
	// contains filtered or unexported fields
}

Changelog represents the changelog itself.

func New

func New() *Changelog

New creates a new Changelog instance.

func (*Changelog) AddRelease

func (c *Changelog) AddRelease(r Release)

AddRelease adds a new release.

func (*Changelog) FirstRelease

func (c *Changelog) FirstRelease() *Release

FirstRelease returns the first Release which usually points to the "Initial release".

func (*Changelog) HasReleases

func (c *Changelog) HasReleases() bool

HasReleases checks if there are any releases.

func (*Changelog) LatestRelease

func (c *Changelog) LatestRelease() *Release

LatestRelease returns the latest Release which usually points to the "Unreleased" one.

func (*Changelog) Load

func (c *Changelog) Load(path string) error

Load loads and parses CHANGELOG.md from the provided path.

func (*Changelog) Src

func (c *Changelog) Src() []byte

Src returns the original source loaded earlier by Load.

type Controller

type Controller interface {
	Load(string) error
	AddRelease(Release)
	HasReleases() bool
	FirstRelease() *Release
	LatestRelease() *Release
}

Controller is the interface that wraps the Changelog methods.

type Release

type Release struct {
	// Title is an original release title. Usually, it's either "Unreleased" or,
	// as an example, "[1.0.0] - 2017-06-20".
	Title string

	// Date is a release date that is parsed from Title. For example,
	// "2017-06-20".
	Date *time.Time

	// Link is a release link which usually can be found in the footnotes.
	Link string

	// Version is a release version itself in a semantic versioning format:
	// https://semver.org/
	Version *semver.Version

	// Text is a release text that doesn't fit into changes. For example, the text
	// like "Initial release" in the first release.
	Text string

	// Added holds a list of all "Added" changes.
	Added []ReleaseChange

	// Changed holds a list of all "Changed" changes.
	Changed []ReleaseChange

	// Deprecated holds a list of all "Deprecated" changes.
	Deprecated []ReleaseChange

	// Removed holds a list of all "Removed" changes.
	Removed []ReleaseChange

	// Fixed holds a list of all "Fixed" changes.
	Fixed []ReleaseChange

	// Security holds a list of all "Security" changes.
	Security []ReleaseChange
}

Release represents a single CHANGELOG.md release.

func NewRelease

func NewRelease() *Release

NewRelease creates a new Release instance.

func (*Release) AddAdded

func (r *Release) AddAdded(desc string)

AddAdded adds a new "Added" change.

func (*Release) AddChanged

func (r *Release) AddChanged(desc string)

AddChanged adds a new "Changed" change.

func (*Release) AddDeprecated

func (r *Release) AddDeprecated(desc string)

AddDeprecated adds a new "Deprecated" change.

func (*Release) AddFixed

func (r *Release) AddFixed(desc string)

AddFixed adds a new "Fixed" change.

func (*Release) AddRemoved

func (r *Release) AddRemoved(desc string)

AddRemoved adds a new "Removed" change.

func (*Release) AddSecurity

func (r *Release) AddSecurity(desc string)

AddSecurity adds a new "Fixed" change.

func (*Release) CountChanges

func (r *Release) CountChanges() int

CountChanges counts the total number of changes.

func (*Release) DateString

func (r *Release) DateString() string

DateString returns a string representation of a Date.

func (*Release) HasChanges

func (r *Release) HasChanges() bool

HasChanges checks if a release has any changes.

func (*Release) HasText

func (r *Release) HasText() bool

HasText checks if a release has any text.

type ReleaseChange

type ReleaseChange struct {
	Value string
}

ReleaseChange represents a single release change. Created to be extended in the future to hold values in different formats like Plain Text, Markdown and Steam Workshop.

func NewReleaseChange

func NewReleaseChange(value string) *ReleaseChange

NewReleaseChange creates a new ReleaseChange instance with the provided value.

type ReleaseController

type ReleaseController interface {
	AddAdded(string)
	AddChanged(string)
	AddDeprecated(string)
	AddRemoved(string)
	AddFixed(string)
	AddSecurity(string)
	CountChanges() int
	HasChanges() bool
	HasText() bool
	DateString() string
}

ReleaseController is the interface that wraps the Release methods.

Jump to

Keyboard shortcuts

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