Documentation
¶
Index ¶
- Constants
- Variables
- func AsDate(dateLike interface{}) (time.Time, error)
- func AsString(stringLike interface{}) (string, error)
- func EnsureReleasesUniqueValidAndMonotonic(rs []Release) error
- func ValidateReleases(rs []Release) error
- type History
- func (h *History) Changelog() (string, error)
- func (h *History) CurrentNotes() string
- func (h *History) CurrentRelease() Release
- func (h *History) CurrentVersion() Version
- func (h *History) DeclareReleases(releaseLikes ...interface{}) (*History, error)
- func (h *History) FirstRelease() Release
- func (h *History) MustChangelog() string
- func (h *History) MustDeclareReleases(releaseLikes ...interface{}) *History
- func (h *History) Project() string
- func (h *History) Release(versionLike interface{}) (Release, error)
- func (h *History) ReleasePairs() []ReleasePair
- func (h *History) URL() string
- func (h *History) WithChangelogTemplate(tmpl *template.Template) *History
- type ImmutableHistory
- type Release
- type ReleasePair
- type Version
Constants ¶
const ( VersionDateSeparator = " - " // Base of minor, major, and patch version numbers NumberBase = 10 // Number of bits to represent version numbers UintBits = 8 )
Variables ¶
var DefaultChangelogTemplate = template.Must(template.New("default_changelog_template").
Parse(`# [{{ .Project }}]({{ .ProjectURL }}) Changelog{{ range .Releases }}
## [{{ .Version }}]{{ if .Version.Dated }} - {{ .Version.FormatDate }}{{ end }}
{{ .Notes }}
{{ end }}
{{ range .ReleasePairs }}[{{ .Version }}]: {{ $.URL }}/compare/{{ .Previous.Version.Ref }}...{{ .Version.Ref }}
{{ end }}[{{ .FirstRelease.Version }}]: {{ $.URL }}/commits/{{ .FirstRelease.Version.Ref }}`))
var DefaultDateLayout = "2006-01-02"
var ZeroVersion = Version{}
Functions ¶
func ValidateReleases ¶
Checks that a sequence of releases are monotonically decreasing with each version being a simple major, minor, or patch bump of its successor in the slice
Types ¶
type History ¶
type History struct { ProjectName string ProjectURL string Releases []Release ChangelogTemplate *template.Template }
The purpose of History is to capture version changes and change logs in a single location and use that data to generate releases and print changes to the command line to automate releases and provide a single source of truth for improved certainty around versions and releases
func NewHistory ¶
Define a new project history to which releases can be added in code e.g. var history = relic.NewHistory().MustDeclareReleases(...)
func (*History) CurrentNotes ¶
Gets the release notes for the current version
func (*History) CurrentRelease ¶
func (*History) CurrentVersion ¶
func (*History) DeclareReleases ¶ added in v1.0.0
Adds releases to the History with the newest releases provided first (so latest is at top). Releases can be specified by pairs of version (string or struct), notes (string) or by sequence of Release (struct) or mixtures thereof.
func (*History) FirstRelease ¶
func (*History) MustChangelog ¶
Generates changelog, panicking if there is an error
func (*History) MustDeclareReleases ¶ added in v1.0.0
Like DeclareReleases but will panic if the Releases list becomes invalid
func (*History) ReleasePairs ¶
func (h *History) ReleasePairs() []ReleasePair
type ImmutableHistory ¶ added in v1.1.0
type ImmutableHistory interface { // Get latest version CurrentVersion() Version // Get latest release note CurrentNotes() string // Get the project name Project() string // Get complete changelog Changelog() (string, error) // Get complete changelog or panic if error MustChangelog() string // Find the release specified by Version struct or version string Release(versionLike interface{}) (Release, error) }
Provides the read-only methods of History to ensure releases are not accidentally mutated when it is not intended