changelog

package
v0.1.5 Latest Latest
Warning

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

Go to latest
Published: Aug 29, 2022 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DefaultTemplate = template.Must(template.New("markdown").Funcs(funcs).Parse(markdownTemplateText))

Functions

func GroupEntries

func GroupEntries(c *Changelog) map[string][]*Entry

GroupEntries takes a changelog and returns a map of entry types to changes.

func NewTemplate

func NewTemplate(text string) (*template.Template, error)

func ParseScope

func ParseScope(config Config, value string, force bool) (string, []string, error)

ParseScope parses a scope string and returns the scope and its list of subscopes, if any.

No validation on allowed scopes/subscopes is done if "force" is set to true.

func PermittedScopesString

func PermittedScopesString(config Config, breakAfterItem bool) string

func PermittedTypesString

func PermittedTypesString(config Config) string

func ValidateType

func ValidateType(config Config, typ string) (string, error)

ValidateType ensures a type string is in the permitted list and always returns a non-empty string if given a non-empty string to allow "--force" behavior.

Types

type Changelog

type Changelog struct {
	// One or more change entries
	Entries []*Entry `yaml:"changes,omitempty"`
}

func (*Changelog) Merge

func (cl *Changelog) Merge(other Changelog) *Changelog

func (*Changelog) Template

func (c *Changelog) Template(config *Config, version string, date string) (*bytes.Buffer, error)

type Config

type Config struct {
	// Types is a map of short types to descriptive names to be used in rendering.
	Types ConfigTypes `yaml:"types"`

	// Scopes is a map of valid scopes to subscopes
	Scopes ConfigScopes `yaml:"scopes"`

	// GitHubRepository, e.g.: aaronfriel/go-change
	GitHubRepository GitHubRepository `yaml:"github,omitempty"`

	// Template is the template to use for rendering the changelog.
	Template RenderTemplate `yaml:"template"`
}

func (*Config) GetGitHubRepository

func (c *Config) GetGitHubRepository() (string, string, error)

Gets the configured GitHubRepository, or attempts to infer it from GITHUB_REPOSITORY.

type ConfigScopes

type ConfigScopes = OrderedMap[string, []string]

type ConfigTypes

type ConfigTypes = OrderedMap[string, string]

type Entry

type Entry struct {
	// Type is a noun describing the category of change: improvement, fix, and so on.
	Type string `yaml:"type,omitempty"`
	// Scope is a noun describing the part of the system improved, such as: cli, codegen, sdk, automation. Subscopes can
	// be represented with a slash after a scope, as in: cli/about, cli/display, auto/go, codegen/dotnet, sdk/nodejs.
	Scope Scope `yaml:"scope,omitempty"`
	// Description is a description of the change.
	Description string `yaml:"description,omitempty"`
	// Metadata contains additional, optional data for rendering the changelog, which may be set to override inferred
	// values.
	GitHubMeta GitHubMeta `yaml:"github,inline"`
}

Entry records a change by its category, the scope of the change, and metadata from GitHub needed to render a changelog.

Follows the conventional commits specification: https://www.conventionalcommits.org/en/v1.0.0/#specification

func (*Entry) Conventional

func (v *Entry) Conventional() string

type GitHubMeta

type GitHubMeta struct {
	// PullRequestNumbers are the GitHub Pull Requests used to implementing this change, typically a single PR.
	PullRequestNumbers []int `yaml:"prs,omitempty"`
}

type GitHubRepository

type GitHubRepository struct {
	Owner string
	Repo  string
}

func (GitHubRepository) MarshalYAML

func (r GitHubRepository) MarshalYAML() (any, error)

func (GitHubRepository) String

func (r GitHubRepository) String() string

func (*GitHubRepository) UnmarshalYAML

func (r *GitHubRepository) UnmarshalYAML(unmarshal func(any) error) (err error)

type Group

type Group struct {
	Type    string
	Changes []*Entry
}

type OrderedMap

type OrderedMap[K comparable, V any] struct {
	Items yaml.MapSlice `yaml:",inline"`
}

func (*OrderedMap[K, V]) Get

func (c *OrderedMap[K, V]) Get(key K) (V, bool)

func (*OrderedMap[K, V]) Keys

func (c *OrderedMap[K, V]) Keys() []string

func (*OrderedMap[K, V]) ToMap

func (c *OrderedMap[K, V]) ToMap() map[K]V

func (*OrderedMap[K, V]) UnmarshalYAML

func (c *OrderedMap[K, V]) UnmarshalYAML(unmarshal func(any) error) error

type RenderTemplate

type RenderTemplate struct {
	*template.Template
}

func (*RenderTemplate) UnmarshalYAML

func (t *RenderTemplate) UnmarshalYAML(unmarshal func(any) error) error

type Scope

type Scope struct {
	Primary   string
	SubScopes []string
}

Structured scope annotation, with YAML marshaling to and from a string.

func (Scope) MarshalYAML

func (s Scope) MarshalYAML() (any, error)

func (Scope) String

func (s Scope) String() string

func (*Scope) UnmarshalYAML

func (s *Scope) UnmarshalYAML(unmarshal func(any) error) error

type TemplateInputs

type TemplateInputs struct {
	Version string
	Date    string
	Groups  []Group
	Titles  map[string]string
}

Jump to

Keyboard shortcuts

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