Documentation ¶
Index ¶
- Constants
- Variables
- func AppendFile(opener shared.OpenFiler, rootFile io.Writer, path string) error
- func CustomMapFromStrings(input []string) (map[string]string, error)
- func EnvVarMap(environ []string) map[string]string
- func FileExists(path string) (bool, error)
- func FindChangeFiles(config *Config, readDir shared.ReadDirer, searchPaths []string) ([]string, error)
- func GetAllVersions(readDir shared.ReadDirer, config *Config, skipPrereleases bool, ...) ([]*semver.Version, error)
- func GetLatestVersion(readDir shared.ReadDirer, config *Config, skipPrereleases bool, ...) (*semver.Version, error)
- func GetNextVersion(readDir shared.ReadDirer, config *Config, partOrVersion string, ...) (*semver.Version, error)
- func HighestAutoLevel(config *Config, allChanges []Change) (string, error)
- func LoadEnvVars(config *Config, envs []string) map[string]string
- func ValidBumpLevel(level string) bool
- func WriteNewlines(writer io.Writer, lines int) error
- type BatchData
- type BodyConfig
- type Change
- type ChangesConfigSorter
- type ComponentData
- type Config
- func (c *Config) ChangeFormatForKind(label string) string
- func (c *Config) EnvVars() map[string]string
- func (c *Config) Exists() (bool, error)
- func (c *Config) KindHeader(label string) string
- func (c *Config) Project(labelOrKey string) (*ProjectConfig, error)
- func (c *Config) ProjectLabels() []string
- func (c *Config) Save(wf shared.WriteFiler) error
- type Custom
- type CustomType
- type EditorRunner
- type GetVersions
- type KindConfig
- type KindData
- type NewlinesConfig
- type PostProcessConfig
- type ProjectConfig
- type Prompts
- type ReplaceData
- type Replacement
- type TemplateCache
- func (tc *TemplateCache) Bodies(changes []Change) ([]string, error)
- func (tc *TemplateCache) Components(changes []Change) ([]string, error)
- func (tc *TemplateCache) Count(value string, items []string) (int, error)
- func (tc *TemplateCache) Customs(changes []Change, key string) ([]string, error)
- func (tc *TemplateCache) Execute(text string, wr io.Writer, data interface{}) error
- func (tc *TemplateCache) Kinds(changes []Change) ([]string, error)
- func (tc *TemplateCache) Load(text string) (*template.Template, error)
- func (tc *TemplateCache) Times(changes []Change) ([]time.Time, error)
Constants ¶
const ( CreateFileMode os.FileMode = 0644 CreateDirMode os.FileMode = 0755 AutoLevel = "auto" MajorLevel = "major" MinorLevel = "minor" PatchLevel = "patch" NoneLevel = "none" EmptyLevel = "" )
Variables ¶
var ( ErrBadVersionOrPart = errors.New("part string is not a supported version or version increment") ErrMissingAutoLevel = errors.New("kind config missing auto level value for auto bumping") ErrNoChangesFoundForAuto = errors.New("no unreleased changes found for automatic bumping") )
var ConfigPaths []string = []string{
".changie.yaml",
".changie.yml",
}
Functions ¶
func CustomMapFromStrings ¶ added in v1.9.0
CustomMapFromStrings will parse a CLI argument of strings into a key value map where each string is a key value pair separated by an equal sign. Eg: Issue=15 turns into {"Issue": "15"}
func FileExists ¶ added in v1.13.0
func FindChangeFiles ¶ added in v1.5.0
func GetAllVersions ¶
func GetLatestVersion ¶
func GetNextVersion ¶
func HighestAutoLevel ¶ added in v1.11.0
func LoadEnvVars ¶ added in v1.10.0
func ValidBumpLevel ¶ added in v1.11.0
Types ¶
type BatchData ¶ added in v1.4.0
type BatchData struct { // Time of the change Time time.Time // Version of the change, will include "v" prefix if used Version string // Version of the release without the "v" prefix if used VersionNoPrefix string // Previous released version PreviousVersion string // Major value of the version Major int // Minor value of the version Minor int // Patch value of the version Patch int // Prerelease value of the version Prerelease string // Metadata value of the version Metadata string // Changes included in the batch Changes []Change // Env vars configured by the system. // See [envPrefix](#config-envprefix) for configuration. Env map[string]string }
Batch data is a common structure for templates when generating change fragments.
type BodyConfig ¶ added in v0.7.0
type BodyConfig struct { // Min length specifies the minimum body length MinLength *int64 `yaml:"minLength,omitempty" default:"no min"` // Max length specifies the maximum body length MaxLength *int64 `yaml:"maxLength,omitempty" default:"no max"` // Block allows multiline text inputs for body messages UseBlock bool `yaml:"block,omitempty" default:"false"` }
Body config allows you to customize the default body prompt
func (BodyConfig) CreateCustom ¶ added in v1.12.0
func (b BodyConfig) CreateCustom() *Custom
func (BodyConfig) Validate ¶ added in v1.9.0
func (b BodyConfig) Validate(input string) error
type Change ¶
type Change struct { // Project of our change, if one was provided. Project string `yaml:",omitempty" default:""` // Component of our change, if one was provided. Component string `yaml:",omitempty" default:""` // Kind of our change, if one was provided. Kind string `yaml:",omitempty" default:""` // Body message of our change, if one was provided. Body string `yaml:",omitempty" default:""` // When our change was made. Time time.Time `yaml:"" required:"true"` // Custom values corresponding to our options where each key-value pair is the key of the custom option // and value the one provided in the change. // example: yaml // custom: // - key: Issue // type: int // changeFormat: "{{.Body}} from #{{.Custom.Issue}}" Custom map[string]string `yaml:",omitempty" default:"nil"` // Env vars configured by the system. // This is not written in change fragments but instead loaded by the system and accessible for templates. // For example if you want to use an env var in [change format](#config-changeformat) you can, // but env vars configured when executing `changie new` will not be saved. // See [envPrefix](#config-envprefix) for configuration. Env map[string]string `yaml:"-" default:"nil"` // Filename the change was saved to. Filename string `yaml:"-"` }
Change represents an atomic change to a project.
func GetChanges ¶ added in v1.11.0
func LoadChange ¶
LoadChange will load a change from file path
func (*Change) PostProcess ¶ added in v1.16.0
func (change *Change) PostProcess(cfg *Config, kind *KindConfig) error
type ChangesConfigSorter ¶
type ChangesConfigSorter struct {
// contains filtered or unexported fields
}
func SortByConfig ¶
func SortByConfig(config *Config) *ChangesConfigSorter
func (*ChangesConfigSorter) Len ¶
func (s *ChangesConfigSorter) Len() int
Len is part of sort.Interface.
func (*ChangesConfigSorter) Less ¶
func (s *ChangesConfigSorter) Less(i, j int) bool
Less will compare two Change values with the config settings. * Components, if enabled, are sorted by index in config * Kind, if enabled, are sorted by index in config * Time sorted newest first
func (*ChangesConfigSorter) Sort ¶
func (s *ChangesConfigSorter) Sort(changes []Change)
Sort sorts the argument slice according to the less functions passed to OrderedBy.
func (*ChangesConfigSorter) Swap ¶
func (s *ChangesConfigSorter) Swap(i, j int)
Swap is part of sort.Interface.
type ComponentData ¶ added in v1.8.0
type ComponentData struct { // Name of the component Component string `required:"true"` // Env vars configured by the system. // See [envPrefix](#config-envprefix) for configuration. Env map[string]string }
Component data stores data related to writing component headers.
type Config ¶
type Config struct { // Directory for change files, header file and unreleased files. // Relative to project root. // example: yaml // changesDir: .changes ChangesDir string `yaml:"changesDir" required:"true"` // Directory for all unreleased change files. // Relative to [changesDir](#config-changesdir). // example: yaml // unreleasedDir: unreleased UnreleasedDir string `yaml:"unreleasedDir" required:"true"` // Header content included at the top of the merged changelog. // A default header file is created when initializing that follows "Keep a Changelog". // // Filepath for your changelog header file. // Relative to [changesDir](#config-changesdir). // example: yaml // headerPath: header.tpl.md HeaderPath string `yaml:"headerPath"` // Filepath for the generated changelog file. // Relative to project root. // ChangelogPath is not required if you are using projects. // example: yaml // changelogPath: CHANGELOG.md ChangelogPath string `yaml:"changelogPath"` // File extension for generated version files. // This should probably match your changelog path file. // Must not include the period. // example: yaml // # for markdown changelogs // versionExt: md VersionExt string `yaml:"versionExt" required:"true"` // Filepath for your version header file relative to [unreleasedDir](#config-unreleaseddir). // It is also possible to use the '--header-path' parameter when using the [batch command](/cli/changie_batch). VersionHeaderPath string `yaml:"versionHeaderPath,omitempty"` // It is also possible to use the '--footer-path' parameter when using the [batch command](/cli/changie_batch). VersionFooterPath string `yaml:"versionFooterPath,omitempty"` // Customize the file name generated for new fragments. // The default uses the component and kind only if configured for your project. // The file is placed in the unreleased directory, so the full path is: // // "{{.ChangesDir}}/{{.UnreleasedDir}}/{{.FragmentFileFormat}}.yaml" // example: yaml // fragmentFileFormat: "{{.Kind}}-{{.Custom.Issue}}" FragmentFileFormat string `` /* 142-byte string literal not displayed */ // Template used to generate version headers. VersionFormat string `yaml:"versionFormat,omitempty" templateType:"BatchData"` // Template used to generate component headers. // If format is empty no header will be included. // If components are disabled, the format is unused. ComponentFormat string `yaml:"componentFormat,omitempty" templateType:"ComponentData"` // Template used to generate kind headers. // If format is empty no header will be included. // If kinds are disabled, the format is unused. KindFormat string `yaml:"kindFormat,omitempty" templateType:"KindData"` // Template used to generate change lines in version files and changelog. // Custom values are created through custom choices and can be accessible through the Custom argument. // example: yaml // changeFormat: '* [#{{.Custom.Issue}}](https://github.com/miniscruff/changie/issues/{{.Custom.Issue}}) {{.Body}}' ChangeFormat string `yaml:"changeFormat" templateType:"Change"` // Template used to generate a version header. HeaderFormat string `yaml:"headerFormat,omitempty" templateType:"BatchData"` // example: yaml // # config yaml // custom: // - key: Author // type: string // minLength: 3 // footerFormat: | // ### Contributors // {{- range (customs .Changes "Author" | uniq) }} // * [{{.}}](https://github.com/{{.}}) // {{- end}} FooterFormat string `yaml:"footerFormat,omitempty" templateType:"BatchData"` // Options to customize the body prompt Body BodyConfig `yaml:"body,omitempty"` // Components are an additional layer of organization suited for projects that want to split // change fragments by an area or tag of the project. // An example could be splitting your changelogs by packages for a monorepo. // If no components are listed then the component prompt will be skipped and no component header included. // By default no components are configured. // example: yaml // components: // - API // - CLI // - Frontend Components []string `yaml:"components,omitempty"` // Kinds are another optional layer of changelogs suited for specifying what type of change we are // making. // If configured, developers will be prompted to select a kind. // // The default list comes from keep a changelog and includes; added, changed, removed, deprecated, fixed, and security. // example: yaml // kinds: // - label: Added // - label: Changed // - label: Deprecated // - label: Removed // - label: Fixed // - label: Security Kinds []KindConfig `yaml:"kinds,omitempty"` // Custom choices allow you to ask for additional information when creating a new change fragment. // These custom choices are included in the [change custom](#change-custom) value. // example: yaml // # github issue and author name // custom: // - key: Issue // type: int // minInt: 1 // - key: Author // label: GitHub Name // type: string // minLength: 3 CustomChoices []Custom `yaml:"custom,omitempty"` // Replacements to run when merging a changelog. // example: yaml // # nodejs package.json replacement // replacements: // - path: package.json // find: ' "version": ".*",' // replace: ' "version": "{{.VersionNoPrefix}}",' Replacements []Replacement `yaml:"replacements,omitempty"` // Newline options allow you to add extra lines between elements written by changie. Newlines NewlinesConfig `yaml:"newlines,omitempty"` // Post process options when saving a new change fragment. // example: yaml // # build a GitHub link from author choice // post: // - key: AuthorLink // value: "https://github.com/{{.Custom.Author}} // changeFormat: "* {{.Body}} by [{{.Custom.Author}}]({{.Custom.AuthorLink}})" Post []PostProcessConfig `yaml:"post,omitempty"` // Prefix of environment variables to load for templates. // The prefix is removed from resulting key map. // example: yaml // # if we have an environment variable like so: // # export CHANGIE_PROJECT=changie // # we can use that in our templates if we set the prefix // envPrefix: "CHANGIE_" // versionFormat: "New release for {{.Env.PROJECT}}" EnvPrefix string `yaml:"envPrefix,omitempty"` // Projects allow you to specify child projects as part of a monorepo setup. // example: yaml // projects: // - label: UI // key: ui // changelog: ui/CHANGELOG.md // - label: Email Sender // key: email_sender // changelog: services/email/CHANGELOG.md Projects []ProjectConfig `yaml:"projects,omitempty"` // ProjectsVersionSeparator is used to determine the final version when using projects. // The result is: project key + projectVersionSeparator + latest/next version. // example: yaml // projectsVersionSeparator: "_" ProjectsVersionSeparator string `yaml:"projectsVersionSeparator,omitempty"` // contains filtered or unexported fields }
Config handles configuration for a project.
Custom configuration path:
By default Changie will try and load ".changie.yaml" and ".changie.yml" before running commands. If you want to change this path set the environment variable `CHANGIE_CONFIG_PATH` to the desired file.
`export CHANGIE_CONFIG_PATH=./tools/changie.yaml`
[Template Cache](#templatecache-type) handles all the template executions.
When batching changes into a version, the headers and footers are placed as such:
1. Header file 1. Header template 1. All changes 1. Footer template 1. Footer file
All elements are optional and will be added together if all are provided.
func LoadConfig ¶
LoadConfig will load the config from the default path
func (*Config) ChangeFormatForKind ¶ added in v1.4.0
func (*Config) KindHeader ¶ added in v1.4.0
func (*Config) Project ¶ added in v1.13.0
func (c *Config) Project(labelOrKey string) (*ProjectConfig, error)
func (*Config) ProjectLabels ¶ added in v1.13.0
type Custom ¶
type Custom struct { // Value used as the key in the custom map for the change format. // This should only contain alpha numeric characters, usually starting with a capital. // example: yaml // key: Issue Key string `yaml:"" required:"true"` // Specifies the type of choice which changes the prompt. // // | value | description | options // | -- | -- | -- | // string | Freeform text | [minLength](#custom-minlength) and [maxLength](#custom-maxlength) // block | Multiline text | [minLength](#custom-minlength) and [maxLength](#custom-maxlength) // int | Whole numbers | [minInt](#custom-minint) and [maxInt](#custom-maxint) // enum | Limited set of strings | [enumOptions](#custom-enumoptions) is used to specify values Type CustomType `yaml:"" required:"true"` // If true, an empty value will not fail validation. // The optional check is handled before min so you can specify that the value is optional but if it // is used it must have a minimum length or value depending on type. // // When building templates that allow for optional values you can compare the custom choice to an // empty string to check for a value or empty. // // example: yaml // custom: // - key: TicketNumber // type: int // optional: true // changeFormat: >- // {{- if not (eq .Custom.TicketNumber "")}} // PROJ-{{.Custom.TicketNumber}} // {{- end}} // {{.Body}} Optional bool `yaml:",omitempty" default:"false"` // Description used in the prompt when asking for the choice. // If empty key is used instead. // example: yaml // label: GitHub Username Label string `yaml:",omitempty" default:""` // If specified the input value must be greater than or equal to minInt. MinInt *int64 `yaml:"minInt,omitempty" default:"nil"` // If specified the input value must be less than or equal to maxInt. MaxInt *int64 `yaml:"maxInt,omitempty" default:"nil"` // If specified the string input must be at least this long MinLength *int64 `yaml:"minLength,omitempty" default:"nil"` // If specified string input must be no more than this long MaxLength *int64 `yaml:"maxLength,omitempty" default:"nil"` // When using the enum type, you must also specify what possible options to allow. // Users will be given a selection list to select the value they want. EnumOptions []string `yaml:"enumOptions,omitempty"` }
Custom defines a custom choice that is asked when using 'changie new'. The result is an additional custom value in the change file for including in the change line.
A simple one could be the issue number or authors github name. example: yaml
- key: Author label: GitHub Name type: string minLength: 3
func (Custom) AskPrompt ¶ added in v1.12.0
CreatePrompt will create a promptui select or prompt from a custom choice
func (Custom) DisplayLabel ¶ added in v0.7.0
type CustomType ¶
type CustomType string
CustomType determines the possible custom choice types. Current values are: `string`, `block`, `int` and `enum`.
const ( CustomString CustomType = "string" CustomBlock CustomType = "block" CustomInt CustomType = "int" CustomEnum CustomType = "enum" )
type EditorRunner ¶ added in v1.13.0
type EditorRunner interface {
Run() error
}
func BuildCommand ¶ added in v1.13.0
func BuildCommand(editorFilePath string) (EditorRunner, error)
BuildCommand will create an exec command to run our editor.
type GetVersions ¶
GetVersions will return, in semver sorted order, all released versions
type KindConfig ¶
type KindConfig struct { // Label is the value used in the prompt when selecting a kind. // example: yaml // label: Feature Label string `yaml:",omitempty" required:"true"` // Format will override the root kind format when building the kind header. // example: yaml // format: '### {{.Kind}} **Breaking Changes**' Format string `yaml:",omitempty"` // Change format will override the root change format when building changes specific to this kind. // example: yaml // changeFormat: 'Breaking: {{.Custom.Body}} ChangeFormat string `yaml:"changeFormat,omitempty"` // Additional choices allows adding choices per kind AdditionalChoices []Custom `yaml:"additionalChoices,omitempty"` // Post process options when saving a new change fragment specific to this kind. Post []PostProcessConfig `yaml:"post,omitempty"` // Skip global choices allows skipping the parent choices options. SkipGlobalChoices bool `yaml:"skipGlobalChoices,omitempty" default:"false"` // Skip body allows skipping the parent body prompt. SkipBody bool `yaml:"skipBody,omitempty" default:"false"` // Skip global post allows skipping the parent post processing. SkipGlobalPost bool `yaml:"skipGlobalPost,omitempty" default:"false"` // Auto determines what value to bump when using `batch auto` or `next auto`. // Possible values are major, minor, patch or none and the highest one is used if // multiple changes are found. none will not bump the version. // Only none changes is not a valid bump and will fail to batch. // example: yaml // auto: minor AutoLevel string `yaml:"auto,omitempty"` }
Kind config allows you to customize the options depending on what kind was selected.
type KindData ¶ added in v1.8.0
type KindData struct { // Name of the kind Kind string `required:"true"` // Env vars configured by the system. // See [envPrefix](#config-envprefix) for configuration. Env map[string]string }
Kind data stores data related to writing kind headers.
type NewlinesConfig ¶ added in v1.8.0
type NewlinesConfig struct { // Add newlines after change fragment AfterChange int `yaml:"afterChange,omitempty" default:"0"` // Add newlines after the header file in the merged changelog AfterChangelogHeader int `yaml:"afterChangelogHeader,omitempty" default:"0"` // Add newlines after adding a version to the changelog AfterChangelogVersion int `yaml:"afterChangelogVersion,omitempty" default:"0"` // Add newlines after component AfterComponent int `yaml:"afterComponent,omitempty" default:"0"` AfterFooterFile int `yaml:"afterFooterFile,omitempty" default:"0"` AfterFooterTemplate int `yaml:"afterFooter,omitempty" default:"0"` // Add newlines after header file AfterHeaderFile int `yaml:"afterHeaderFile,omitempty" default:"0"` // Add newlines after header template AfterHeaderTemplate int `yaml:"afterHeaderTemplate,omitempty" default:"0"` // Add newlines after kind AfterKind int `yaml:"afterKind,omitempty" default:"0"` // Add newlines after version AfterVersion int `yaml:"afterVersion,omitempty" default:"0"` // Add newlines before change fragment BeforeChange int `yaml:"beforeChange,omitempty" default:"0"` // Add newlines before adding a version to the changelog BeforeChangelogVersion int `yaml:"beforeChangelogVersion,omitempty" default:"0"` // Add newlines before component BeforeComponent int `yaml:"beforeComponent,omitempty" default:"0"` BeforeFooterFile int `yaml:"beforeFooterFile,omitempty" default:"0"` BeforeFooterTemplate int `yaml:"beforeFooterTemplate,omitempty" default:"0"` // Add newlines before header file BeforeHeaderFile int `yaml:"beforeHeaderFile,omitempty" default:"0"` // Add newlines before header template BeforeHeaderTemplate int `yaml:"beforeHeaderTemplate,omitempty" default:"0"` // Add newlines before kind BeforeKind int `yaml:"beforeKind,omitempty" default:"0"` // Add newlines before version BeforeVersion int `yaml:"beforeVersion,omitempty" default:"0"` // Add newlines at the end of the version file EndOfVersion int `yaml:"endOfVersion,omitempty" default:"0"` }
Configuration options for newlines before and after different elements.
type PostProcessConfig ¶ added in v1.9.0
type PostProcessConfig struct { // Key to save the custom value with Key string `yaml:"key"` // Value of the custom value as a go template Value string `yaml:"value" templateType:"Change"` }
PostProcessConfig allows adding additional custom values to a change fragment after all the other inputs are complete. This will add additional keys to the `custom` section of the fragment. If the key already exists as part of a custom choice the value will be overridden.
type ProjectConfig ¶ added in v1.13.0
type ProjectConfig struct { // Label is the value used in the prompt when selecting a project. // example: yaml // label: Frontend Label string `yaml:"label"` // Key is the value used for unreleased and version output paths. // example: yaml // key: frontend Key string `yaml:"key"` // ChangelogPath is the path to the changelog for this project. // example: yaml // changelog: src/frontend/CHANGELOG.md ChangelogPath string `yaml:"changelog"` // Replacements to run when merging a changelog for our project. // example: yaml // # nodejs package.json replacement // replacements: // - path: ui/package.json // find: ' "version": ".*",' // replace: ' "version": "{{.VersionNoPrefix}}",' Replacements []Replacement `yaml:"replacements"` }
ProjectConfig extends changie to support multiple changelog files for different projects inside one repository. example: yaml projects:
- label: UI key: ui changelog: ui/CHANGELOG.md
- label: Email Sender key: email_sender changelog: services/email/CHANGELOG.md
type Prompts ¶ added in v1.16.0
type Prompts struct { Config *Config StdinReader io.Reader KindConfig *KindConfig BodyEditor bool CreateFiler shared.CreateFiler EditorCmdBuilder func(string) (EditorRunner, error) TimeNow shared.TimeNow // Values can be submitted from the environment or shell arguments. Projects []string Component string Kind string Body string Customs map[string]string }
func (*Prompts) BuildChanges ¶ added in v1.16.0
BuildChanges will ask the user prompts based on the configuration returning all changes as prompts are answered. A change relates to a single project and single change, so if the change affects multiple projects we will return multiple changes.
type ReplaceData ¶
type ReplaceData struct { // Version of the release, will include "v" prefix if used Version string // Version of the release without the "v" prefix if used VersionNoPrefix string // Major value of the version Major int // Minor value of the version Minor int // Patch value of the version Patch int // Prerelease value of the version Prerelease string // Metadata value of the version Metadata string }
Template data used for replacing version values.
type Replacement ¶
type Replacement struct { // Path of the file to find and replace in. Path string `yaml:"path" required:"true"` // Regular expression to search for in the file. Find string `yaml:"find" required:"true"` // Template string to replace the line with. Replace string `yaml:"replace" required:"true" templateType:"ReplaceData"` // Optional regular expression mode flags. // Defaults to the m flag for multiline such that ^ and $ will match the start and end of each line // and not just the start and end of the string. // // For more details on regular expression flags in Go view the // [regexp/syntax](https://pkg.go.dev/regexp/syntax). Flags string `yaml:"flags,omitempty" default:"m"` }
Replacement handles the finding and replacing values when merging the changelog. This can be used to keep version strings in-sync when preparing a release without having to manually update them. This works similar to the find and replace from IDE tools but also includes the file path of the file. example: yaml # NodeJS package.json replacements:
- path: package.json find: ' "version": ".*",' replace: ' "version": "{{.VersionNoPrefix}}",'
func (Replacement) Execute ¶
func (r Replacement) Execute( readFile shared.ReadFiler, writeFile shared.WriteFiler, data ReplaceData, ) error
type TemplateCache ¶
type TemplateCache struct {
// contains filtered or unexported fields
}
Template cache handles running all the templates for change fragments. Included options include the default [go template](https://golang.org/pkg/text/template/) and [sprig functions](https://masterminds.github.io/sprig/) for formatting. Additionally, custom template functions are listed below for working with changes. example: yaml format: | ### Contributors {{- range (customs .Changes "Author" | uniq) }} * [{{.}}](https://github.com/{{.}}) {{- end}}
func NewTemplateCache ¶
func NewTemplateCache() *TemplateCache
func (*TemplateCache) Bodies ¶ added in v1.8.0
func (tc *TemplateCache) Bodies(changes []Change) ([]string, error)
Bodies will return all the bodies from the provided changes. example: yaml format: "{{ bodies .Changes }} bodies"
func (*TemplateCache) Components ¶ added in v1.8.0
func (tc *TemplateCache) Components(changes []Change) ([]string, error)
Components will return all the components from the provided changes. example: yaml format: "{{components .Changes }} components"
func (*TemplateCache) Count ¶ added in v1.8.0
func (tc *TemplateCache) Count(value string, items []string) (int, error)
Count will return the number of occurrences of a string in a slice. example: yaml format: "{{ kinds .Changes | count \"added\" }} kinds"
func (*TemplateCache) Customs ¶ added in v1.8.0
func (tc *TemplateCache) Customs(changes []Change, key string) ([]string, error)
Customs will return all the values from the custom map by a key. If a key is missing from a change, it will be an empty string. example: yaml format: "{{ customs .Changes \"Author\" }} authors"
func (*TemplateCache) Execute ¶
func (tc *TemplateCache) Execute(text string, wr io.Writer, data interface{}) error