Documentation ¶
Overview ¶
Package chglog implements main logic for the CHANGELOG generate.
Example ¶
gen := NewGenerator(NewLogger(os.Stdout, os.Stderr, false, true), &Config{ Bin: "git", WorkingDir: ".", Template: "CHANGELOG.tpl.md", Info: &Info{ Title: "CHANGELOG", RepositoryURL: "https://github.com/git-chglog/git-chglog", }, Options: &Options{ CommitFilters: map[string][]string{ "Type": { "feat", "fix", }, }, CommitSortBy: "Scope", CommitGroupBy: "Type", CommitGroupSortBy: "Title", CommitGroupTitleMaps: map[string]string{ "feat": "Features", "fix": "Bug Fixes", }, HeaderPattern: "^(\\w*)(?:\\(([\\w\\$\\.\\-\\*\\s]*)\\))?\\:\\s(.*)$", HeaderPatternMaps: []string{ "Type", "Scope", "Subject", }, IssuePrefix: []string{ "#", "gh-", }, RefActions: []string{}, MergePattern: "^Merge pull request #(\\d+) from (.*)$", MergePatternMaps: []string{ "Ref", "Source", }, RevertPattern: "^Revert \"([\\s\\S]*)\"$", RevertPatternMaps: []string{ "Header", }, NoteKeywords: []string{ "BREAKING CHANGE", }, }, }) buf := &bytes.Buffer{} err := gen.Generate(buf, "") if err != nil { log.Fatalln(err) } fmt.Println(buf.String())
Output:
Index ¶
- type Author
- type BitbucketProcessor
- type Commit
- type CommitGroup
- type Committer
- type Config
- type Contact
- type Generator
- type GitHubProcessor
- type GitLabProcessor
- type Hash
- type Info
- type JiraClient
- type JiraIssue
- type Logger
- type Merge
- type Note
- type NoteGroup
- type Options
- type Processor
- type Ref
- type RelateTag
- type RenderData
- type Revert
- type Tag
- type Unreleased
- type Version
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BitbucketProcessor ¶
type BitbucketProcessor struct { Host string // Host name used for link destination. Note: You must include the protocol (e.g. "https://bitbucket.org") // contains filtered or unexported fields }
BitbucketProcessor is optimized for CHANGELOG used in Bitbucket
The following processing is performed
- Mentions automatic link (@tsuyoshiwada -> [@tsuyoshiwada](https://bitbucket.org/tsuyoshiwada/))
- Automatic link to references (#123 -> [#123](https://bitbucket.org/owner/repo/issues/123/))
func (*BitbucketProcessor) Bootstrap ¶
func (p *BitbucketProcessor) Bootstrap(config *Config)
Bootstrap ...
func (*BitbucketProcessor) ProcessCommit ¶
func (p *BitbucketProcessor) ProcessCommit(commit *Commit) *Commit
ProcessCommit ...
type Commit ¶
type Commit struct { Hash *Hash Author *Author Committer *Committer Merge *Merge // If it is not a merge commit, `nil` is assigned Revert *Revert // If it is not a revert commit, `nil` is assigned Refs []*Ref Notes []*Note Mentions []string // Name of the user included in the commit header or body CoAuthors []Contact // (e.g. `Co-authored-by: user <user@email>`) Signers []Contact // (e.g. `Signed-off-by: user <user@email>`) JiraIssue *JiraIssue // If no issue id found in header, `nil` is assigned Header string // (e.g. `feat(core)[RNWY-310]: Add new feature`) Type string // (e.g. `feat`) Scope string // (e.g. `core`) Subject string // (e.g. `Add new feature`) JiraIssueID string // (e.g. `RNWY-310`) Body string TrimmedBody string // Body without any Notes/Refs/Mentions/CoAuthors/Signers }
Commit data
type CommitGroup ¶
type CommitGroup struct { RawTitle string // Raw title before conversion (e.g. `build`) Title string // Conversion by `CommitGroupTitleMaps` option, or title converted in title case (e.g. `Build`) Commits []*Commit }
CommitGroup is a collection of commits grouped according to the `CommitGroupBy` option
type Config ¶
type Config struct { Bin string // Git execution command WorkingDir string // Working directory Template string // Path for template file. If a relative path is specified, it depends on the value of `WorkingDir`. Info *Info Options *Options }
Config for generating CHANGELOG
type Generator ¶
type Generator struct {
// contains filtered or unexported fields
}
Generator of CHANGELOG
func NewGenerator ¶
NewGenerator receives `Config` and create an new `Generator`
func (*Generator) Generate ¶
Generate gets the commit based on the specified tag `query` and writes the result to `io.Writer`
tag `query` can be specified with the following rule
<old>..<new> - Commit contained in `<new>` tags from `<old>` (e.g. `1.0.0..2.0.0`) <tagname>.. - Commit from the `<tagname>` to the latest tag (e.g. `1.0.0..`) ..<tagname> - Commit from the oldest tag to `<tagname>` (e.g. `..1.0.0`) <tagname> - Commit contained in `<tagname>` (e.g. `1.0.0`)
type GitHubProcessor ¶
type GitHubProcessor struct { Host string // Host name used for link destination. Note: You must include the protocol (e.g. "https://github.com") // contains filtered or unexported fields }
GitHubProcessor is optimized for CHANGELOG used in GitHub
The following processing is performed
- Mentions automatic link (@tsuyoshiwada -> [@tsuyoshiwada](https://github.com/tsuyoshiwada))
- Automatic link to references (#123 -> [#123](https://github.com/owner/repo/issues/123))
func (*GitHubProcessor) Bootstrap ¶
func (p *GitHubProcessor) Bootstrap(config *Config)
Bootstrap ...
func (*GitHubProcessor) ProcessCommit ¶
func (p *GitHubProcessor) ProcessCommit(commit *Commit) *Commit
ProcessCommit ...
type GitLabProcessor ¶
type GitLabProcessor struct { Host string // Host name used for link destination. Note: You must include the protocol (e.g. "https://gitlab.com") // contains filtered or unexported fields }
GitLabProcessor is optimized for CHANGELOG used in GitLab
The following processing is performed
- Mentions automatic link (@tsuyoshiwada -> [@tsuyoshiwada](https://gitlab.com/tsuyoshiwada))
- Automatic link to references issues (#123 -> [#123](https://gitlab.com/owner/repo/issues/123))
- Automatic link to references merge request (!123 -> [#123](https://gitlab.com/owner/repo/merge_requests/123))
func (*GitLabProcessor) Bootstrap ¶
func (p *GitLabProcessor) Bootstrap(config *Config)
Bootstrap ...
func (*GitLabProcessor) ProcessCommit ¶
func (p *GitLabProcessor) ProcessCommit(commit *Commit) *Commit
ProcessCommit ...
type Info ¶
type Info struct { Title string // Title of CHANGELOG RepositoryURL string // URL of git repository }
Info is metadata related to CHANGELOG
type JiraClient ¶ added in v0.11.0
JiraClient is an HTTP client for Jira
func NewJiraClient ¶ added in v0.11.0
func NewJiraClient(config *Config) JiraClient
NewJiraClient returns an instance of JiraClient
type JiraIssue ¶ added in v0.11.0
JiraIssue is information about a jira ticket (type, summary, description, and labels)
type Logger ¶ added in v0.11.0
type Logger struct {
// contains filtered or unexported fields
}
Logger ...
type Options ¶
type Options struct { Processor Processor NextTag string // Treat unreleased commits as specified tags (EXPERIMENTAL) TagFilterPattern string // Filter tag by regexp Sort string // Specify how to sort tags; currently supports "date" (default) or by "semver". NoCaseSensitive bool // Filter commits in a case insensitive way CommitFilters map[string][]string // Filter by using `Commit` properties and values. Filtering is not done by specifying an empty value CommitSortBy string // Property name to use for sorting `Commit` (e.g. `Scope`) CommitGroupBy string // Property name of `Commit` to be grouped into `CommitGroup` (e.g. `Type`) CommitGroupSortBy string // Property name to use for sorting `CommitGroup` (e.g. `Title`) CommitGroupTitleOrder []string // Predefined sorted list of titles to use for sorting `CommitGroup`. Only if `CommitGroupSortBy` is `Custom` CommitGroupTitleMaps map[string]string // Map for `CommitGroup` title conversion HeaderPattern string // A regular expression to use for parsing the commit header HeaderPatternMaps []string // A rule for mapping the result of `HeaderPattern` to the property of `Commit` IssuePrefix []string // Prefix used for issues (e.g. `#`, `gh-`) RefActions []string // Word list of `Ref.Action` MergePattern string // A regular expression to use for parsing the merge commit MergePatternMaps []string // Similar to `HeaderPatternMaps` RevertPattern string // A regular expression to use for parsing the revert commit RevertPatternMaps []string // Similar to `HeaderPatternMaps` NoteKeywords []string // Keyword list to find `Note`. A semicolon is a separator, like `<keyword>:` (e.g. `BREAKING CHANGE`) JiraUsername string JiraToken string JiraURL string JiraTypeMaps map[string]string JiraIssueDescriptionPattern string Paths []string // Path filter }
Options is an option used to process commits
type Processor ¶
Processor hooks the internal processing of `Generator`, it is possible to adjust the contents
type Ref ¶
type Ref struct { Action string // (e.g. `Closes`) Ref string // (e.g. `123`) Source string // (e.g. `owner/repository`) }
Ref is abstract data related to commit. (e.g. `Issues`, `Pull Request`)
type RelateTag ¶
RelateTag is sibling tag data of `Tag`. If you give `Tag`, the reference hierarchy will be deepened. This struct is used to minimize the hierarchy of references
type RenderData ¶
type RenderData struct { Info *Info Unreleased *Unreleased Versions []*Version }
RenderData is the data passed to the template
type Unreleased ¶
type Unreleased struct { CommitGroups []*CommitGroup Commits []*Commit MergeCommits []*Commit RevertCommits []*Commit NoteGroups []*NoteGroup }
Unreleased is unreleased commit dataset