Documentation ¶
Index ¶
- Constants
- type Changelog
- func (c *Changelog) AddUnreleasedChange(scope string, change string) error
- func (c *Changelog) CreateRelease(version, date string) (*Release, error)
- func (c *Changelog) CreateReleaseFromUnreleased(version, date string) (*Release, error)
- func (c *Changelog) CreateReleaseFromUnreleasedWithURL(version, date, url string) (*Release, error)
- func (c *Changelog) CreateReleaseWithURL(version, date, url string) (*Release, error)
- func (c *Changelog) GetRelease(version string) *Release
- func (c *Changelog) SaveToFile(filesystem Filesystem, filepath string) error
- func (c *Changelog) SetDescription(description string)
- func (c *Changelog) SetTitle(title string)
- func (c *Changelog) SetUnreleasedURL(link string) error
- func (c *Changelog) ToString() string
- type Changes
- type Filesystem
- type Parser
- type Release
- type Releases
- func (r *Releases) CreateRelease(version, date string) (*Release, error)
- func (r *Releases) CreateReleaseWithURL(version, date, url string) (*Release, error)
- func (r Releases) GetRelease(version string) *Release
- func (r Releases) Len() int
- func (r Releases) Less(i, j int) bool
- func (r Releases) Swap(i, j int)
Constants ¶
const ( // General EmptyLineRegex string = `^\s*$` URLRegex string = `` /* 242-byte string literal not displayed */ SemVerRegex string = `` /* 177-byte string literal not displayed */ DateRegex string = `([1-2][0-9][0-9][0-9])-([1-9]|[0][1-9]|[1][0-2])-([1-9]|[0][1-9]|[1-2][0-9]?|[3][0-1]?)` DateFormat string = `2006-01-02` // Margins TitleRegex string = `^#\s*(?P<title>\S*)\s*$` UnreleasedTitleRegex string = `^## \[(?P<title>Unreleased)\]$` UnreleasedTitleWithLinkRegex string = `^## \[(?P<title>Unreleased)\]\((?P<url>` + URLRegex + `)\)$` VersionTitleRegex string = `^## \[(?P<version>` + SemVerRegex + `)\] - (?P<date>` + DateRegex + `)(?P<yanked> \[YANKED\])?$` VersionTitleWithLinkRegex string = `^## \[(?P<version>` + SemVerRegex + `)\]\((?P<url>` + URLRegex + `)\) - (?P<date>` + DateRegex + `)(?P<yanked> \[YANKED\])?$` MarkdownUnreleasedTitleLinkRegex string = `^\[(?P<title>Unreleased)\]: (?P<url>` + URLRegex + `)$` MarkdownVersionTitleLinkRegex string = `^\[(?P<version>` + SemVerRegex + `)\]: (?P<url>` + URLRegex + `)$` // Scopes AddedScopeRegex string = `^### (?P<scope>Added)$` ChangedScopeRegex string = `^### (?P<scope>Changed)$` DeprecatedScopeRegex string = `^### (?P<scope>Deprecated)$` RemovedScopeRegex string = `^### (?P<scope>Removed)$` FixedScopeRegex string = `^### (?P<scope>Fixed)$` SecurityScopeRegex string = `^### (?P<scope>Security)$` EntryRegex string = `^(?P<marker>[-*+]\s*)(?P<entry>.*)$` )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Changelog ¶
Changelog reflects content of a complete changelog file
func NewChangelog ¶ added in v1.0.0
func NewChangelog() *Changelog
NewChangelog returns an empty changelog.
func (*Changelog) AddUnreleasedChange ¶ added in v1.0.0
AddUnreleasedChange adds a scoped change to Unreleased section.
Supported scopes: [added, changed, deprecated, removed, fixed, security].
func (*Changelog) CreateRelease ¶ added in v1.0.0
CreateRelease creates new empty release.
This is a helper function that wraps Releases.CreateRelease function.
func (*Changelog) CreateReleaseFromUnreleased ¶ added in v1.0.0
CreateReleaseFromUnreleased creates a new release with all the changes from Unreleased section. This will also cleanup the Unreleased section.
func (*Changelog) CreateReleaseFromUnreleasedWithURL ¶ added in v1.0.0
CreateReleaseFromUnreleased creates a new release with all the changes from Unreleased section. This will also cleanup the Unreleased section. Identical to CreateReleaseFromUnreleased but with an extra step of adding a URL to the release.
func (*Changelog) CreateReleaseWithURL ¶ added in v1.0.0
CreateReleaseWithURL creates new empty release.
This is a helper function that wraps Releases.CreateReleaseWithURL function.
Identical to CreateRelease but with an extra step of adding a URL to the release.
func (*Changelog) GetRelease ¶ added in v1.0.0
GetRelease returns a release for a provided version.
This is a helper function that wraps Releases.GetRelease function.
func (*Changelog) SaveToFile ¶ added in v1.0.0
func (c *Changelog) SaveToFile(filesystem Filesystem, filepath string) error
SaveToFile formats the changelog struct according to a predefined format and prints it to file.
Possible options for Filesystem are: [afero.NewOsFs(), afero.NewMemMapFs()].
func (*Changelog) SetDescription ¶ added in v1.0.0
SetDescription updates a description of the changelog.
func (*Changelog) SetUnreleasedURL ¶ added in v1.0.0
SetUnreleasedURL configures a markdown URL for an Unreleased section.
type Changes ¶
type Changes struct { Added *[]string Changed *[]string Deprecated *[]string Fixed *[]string Notice *string Removed *[]string Security *[]string }
Changes are scoped changelog entries for a single version.
func (*Changes) AddChange ¶ added in v1.0.0
AddChange adds a scoped change.
Supported scopes: [added, changed, deprecated, removed, fixed, security].
type Filesystem ¶ added in v0.0.2
type Filesystem interface { Stat(string) (fs.FileInfo, error) Open(string) (afero.File, error) Create(string) (afero.File, error) }
Filesystem is an interface of a filesystem.
Possible options: [afero.NewOsFs(), afero.NewMemMapFs()].
type Parser ¶
type Parser struct { Filepath string Filesystem Filesystem Buffer []string Margins struct { Lines []int Title *int Unreleased *int Releases []int Links []int Added []int Changed []int Deprecated []int Removed []int Fixed []int Security []int } }
Parser is basically a runtime that holds a raw changelog content, key file Margins, filesystem backend and other attributes.
func NewParserWithFilesystem ¶
func NewParserWithFilesystem(filesystem Filesystem, filepath string) (*Parser, error)
NewParser creates a new Changelog Parser using non default (OS) filesystem.
Possible options for Filesystem are: [afero.NewOsFs(), afero.NewMemMapFs()].
type Release ¶
Release is a single changelog version
func (*Release) AddChange ¶ added in v1.0.0
AddChange adds a scoped change to the release.
This is a helper function that wraps Changes.AddChange function.
func (*Release) AddNotice ¶ added in v1.0.0
AddNotice adds a notice to the release.
This is a helper function that wraps Changes.AddNotice function.
func (*Release) SetDate ¶ added in v1.0.0
SetDate configures a date of the release. Expected format: YYYY-MM-DD
func (*Release) SetVersion ¶ added in v1.0.0
SetVersion configures a Semantic Version of a release.
type Releases ¶ added in v1.0.0
type Releases []*Release
Releases is a slice of releases
func (*Releases) CreateRelease ¶ added in v1.0.0
CreateRelease creates new empty release.
func (*Releases) CreateReleaseWithURL ¶ added in v1.0.0
CreateReleaseWithURL creates new empty release.
Identical to CreateRelease but with an extra step of adding a URL to the release.
func (Releases) GetRelease ¶ added in v1.0.0
GetRelease returns a release for a provided version.