CHANGELOG generator implemented in Go (Golang).Anytime, anywhere, Write your CHANGELOG.
$ git-chglog
.git-chglog
internally uses the git
command to get data to include in theCHANGELOG. The basic steps are as follows.
tagA
and tagB
.We will start with installation and introduce the steps up to the automatic generationof the configuration file and template.
Please install git-chglog
in a way that matches your environment.
brew tap git-chglog/git-chglog
brew install git-chglog
scoop install git-chglog
asdf plugin-add git-chglog https://github.com/GoodwayGroup/asdf-git-chglog.git
asdf install git-chglog latest
go get -u github.com/git-chglog/git-chglog/cmd/git-chglog
The compiled docker images are maintained on quay.io.We maintain the following tags:
edge
: Image that is build from the current HEAD
of the main line branch.latest
: Image that is built from the latest released versionx.y.y
(versions): Images that are build from the tagged versions within Github.docker pull quay.io/git-chglog/git-chglog:latest
docker run -v "$PWD":/workdir quay.io/git-chglog/git-chglog --version
If you are using another platform, you can download a binary from the releases pageand place it in a directory in your $PATH
.
You can check with the following command whether the git-chglog
command wasincluded in a directory that is in your $PATH
.
$ git-chglog --version
# outputs the git-chglog version
git-chglog
requires configuration files and templates to generate a CHANGELOG.
However, it is a waste of time to create configuration files and templates from scratch.
Therefore we recommend using the --init
option which will create them interactively
git-chglog --init
You are now ready for configuration files and templates!
Let's immediately generate a CHANGELOG of your project.By doing the following simple command, Markdown for your CHANGELOG is displayedon stdout.
git-chglog
Use -o
(--output
) option if you want to output to a file instead of stdout.
git-chglog -o CHANGELOG.md
You now know basic usage of git-chglog
!
In order to make a better CHANGELOG, please refer to the following document andcustomize it.
$ git-chglog --help
USAGE:
git-chglog [options] <tag query>
There are the following specification methods for <tag query>.
1. <old>..<new> - Commit contained in <old> tags from <new>.
2. <name>.. - Commit from the <name> to the latest tag.
3. ..<name> - Commit from the oldest tag to <name>.
4. <name> - Commit contained in <name>.
OPTIONS:
--init generate the git-chglog configuration file in interactive (default: false)
--path value Filter commits by path(s). Can use multiple times.
--config value, -c value specifies a different configuration file to pick up (default: ".chglog/config.yml")
--template value, -t value specifies a template file to pick up. If not specified, use the one in config
--repository-url value specifies git repo URL. If not specified, use 'repository_url' in config
--output value, -o value output path and filename for the changelogs. If not specified, output to stdout
--next-tag value treat unreleased commits as specified tags (EXPERIMENTAL)
--silent disable stdout output (default: false)
--no-color disable color output (default: false) [$NO_COLOR]
--no-emoji disable emoji output (default: false) [$NO_EMOJI]
--no-case disable case sensitive filters (default: false)
--tag-filter-pattern value Regular expression of tag filter. Is specified, only matched tags will be picked
--jira-url value Jira URL [$JIRA_URL]
--jira-username value Jira username [$JIRA_USERNAME]
--jira-token value Jira token [$JIRA_TOKEN]
--sort value Specify how to sort tags; currently supports "date" or by "semver" (default: date)
--help, -h show help (default: false)
--version, -v print the version (default: false)
EXAMPLE:
$ git-chglog
If <tag query> is not specified, it corresponds to all tags.
This is the simplest example.
$ git-chglog 1.0.0..2.0.0
The above is a command to generate CHANGELOG including commit of 1.0.0 to 2.0.0.
$ git-chglog 1.0.0
The above is a command to generate CHANGELOG including commit of only 1.0.0.
$ git-chglog $(git describe --tags $(git rev-list --tags --max-count=1))
The above is a command to generate CHANGELOG with the commit included in the latest tag.
$ git-chglog --output CHANGELOG.md
The above is a command to output to CHANGELOG.md instead of standard output.
$ git-chglog --config custom/dir/config.yml
The above is a command that uses a configuration file placed other than ".chglog/config.yml".
$ git-chglog --path path/to/my/component --output CHANGELOG.component.md
Filter commits by specific paths or files in git and output to a component specific changelog.
tag query
You can specify which commits to include in the generation of CHANGELOG using <tag query>
.
The table below shows Query patterns and summaries, and Query examples.
Query | Description | Example |
---|---|---|
<old>..<new> |
Commit contained in <new> tags from <old> . |
$ git-chglog 1.0.0..2.0.0 |
<name>.. |
Commit from the <name> to the latest tag. |
$ git-chglog 1.0.0.. |
..<name> |
Commit from the oldest tag to <name> . |
$ git-chglog ..2.0.0 |
<name> |
Commit contained in <name> . |
$ git-chglog 1.0.0 |
The git-chglog
configuration is a yaml file. The default location is.chglog/config.yml
.
Below is a complete list that you can use with git-chglog
.
bin: git
style: ""
template: CHANGELOG.tpl.md
info:
title: CHANGELOG
repository_url: https://github.com/git-chglog/git-chglog
options:
tag_filter_pattern: '^v'
sort: "date"
commits:
filters:
Type:
- feat
sort_by: Scope
commit_groups:
group_by: Type
sort_by: Title
title_order:
- feat
title_maps:
feat: Features
header:
pattern: "<regexp>"
pattern_maps:
- PropName
issues:
prefix:
- #
refs:
actions:
- Closes
- Fixes
merges:
pattern: "^Merge branch '(\\w+)'$"
pattern_maps:
- Source
reverts:
pattern: "^Revert \"([\\s\\S]*)\"$"
pattern_maps:
- Header
notes:
keywords:
- BREAKING CHANGE
bin
Git execution command.
Required | Type | Default | Description |
---|---|---|---|
N | String | "git" |
- |
style
CHANGELOG style. Automatic linking of issues and notices, initial value settingsuch as merges etc. are done automatically.
Required | Type | Default | Description |
---|---|---|---|
N | String | "none" |
Should be "github" "gitlab" "bitbucket" "none" |
template
Path for the template file. It is specified by a relative path from the settingfile. Absolute paths are also ok.
Required | Type | Default | Description |
---|---|---|---|
N | String | "CHANGELOG.tpl.md" |
- |
info
Metadata for CHANGELOG. Depending on Style, it is sometimes used in processing,so it is recommended to specify it.
Key | Required | Type | Default | Description |
---|---|---|---|---|
title |
N | String | "CHANGELOG" |
Title of CHANGELOG. |
repository_url |
N | String | none | URL of git repository. |
options
Options used to process commits.
options.sort
Options concerning the acquisition and sort of commits.
Required | Type | Default | Description |
---|---|---|---|
N | String | "date" |
Defines how tags are sorted in the generated change log. Values: "date", "semver". |
options.commits
Options concerning the acquisition and sort of commits.
Key | Required | Type | Default | Description |
---|---|---|---|---|
filters |
N | Map in List | none | Filter by using Commit properties and values. Filtering is not done by specifying an empty value. |
sort_by |
N | String | "Scope" |
Property name to use for sorting Commit . See Commit. |
options.commit_groups
Options for groups of commits.
Key | Required | Type | Default | Description |
---|---|---|---|---|
group_by |
N | String | "Type" |
Property name of Commit to be grouped into CommitGroup . See CommitGroup. |
sort_by |
N | String | "Title" |
Property name to use for sorting CommitGroup . See CommitGroup. |
title_order |
N | List | none | Predefined order of titles to use for sorting CommitGroup . Only if sort_by is Custom |
title_maps |
N | Map in List | none | Map for CommitGroup title conversion. |
options.header
This option is used for parsing the commit header.
Key | Required | Type | Default | Description |
---|---|---|---|---|
pattern |
Y | String | none | A regular expression to use for parsing the commit header. |
pattern_maps |
Y | List | none | A rule for mapping the result of HeaderPattern to the property of Commit . See Commit. |
options.issues
This option is used to detect issues.
Key | Required | Type | Default | Description |
---|---|---|---|---|
prefix |
N | List | none | Prefix used for issues. (e.g. # , #gh- ) |
options.refs
This option is for parsing references.
Key | Required | Type | Default | Description |
---|---|---|---|---|
actions |
N | List | none | Word list of Ref.Action . See Ref. |
options.merges
Options to detect and parse merge commits.
Key | Required | Type | Default | Description |
---|---|---|---|---|
pattern |
N | String | none | Similar to options.header.pattern . |
pattern_maps |
N | List | none | Similar to options.header.pattern_maps . |
options.reverts
Options to detect and parse revert commits.
Key | Required | Type | Default | Description |
---|---|---|---|---|
pattern |
N | String | none | Similar to options.header.pattern . |
pattern_maps |
N | List | none | Similar to options.header.pattern_maps . |
options.notes
Options to detect notes contained in commit bodies.
Key | Required | Type | Default | Description |
---|---|---|---|---|
keywords |
N | List | none | Keyword list to find Note . A semicolon is a separator, like <keyword>: (e.g. BREAKING CHANGE ). |
The git-chglog
template uses the text/template
package and enhanced templating functions provided by Sprig. For basic usage please refer to the following.
We have implemented the following custom template functions. These override functions provided by Sprig.
Name | Signature | Description |
---|---|---|
contains |
func(s, substr string) bool |
Reports whether substr is within s using strings.Contains |
datetime |
func(layout string, input time.Time) string |
Generate a formatted Date string based on layout |
hasPrefix |
func(s, prefix string) bool |
Tests whether the string s begins with prefix using strings.HasPrefix |
hasSuffix |
func(s, suffix string) bool |
Tests whether the string s ends with suffix . using strings.HasPrefix |
indent |
func(s string, n int) string |
Indent all lines of s by n spaces |
replace |
func(s, old, new string, n int) string |
Replace old with new within string s , n times using strings.Replace |
upperFirst |
func(s string) string |
Upper case the first character of a string |
If you are not satisfied with the prepared template please try customizing one.
The basic templates are as follows.
Example:
{{ if .Versions -}}
<a name="unreleased"></a>
## [Unreleased]
{{ if .Unreleased.CommitGroups -}}
{{ range .Unreleased.CommitGroups -}}
### {{ .Title }}
{{ range .Commits -}}
- {{ if .Scope }}**{{ .Scope }}:** {{ end }}{{ .Subject }}
{{ end }}
{{ end -}}
{{ end -}}
{{ end -}}
{{ range .Versions }}
<a name="{{ .Tag.Name }}"></a>
## {{ if .Tag.Previous }}[{{ .Tag.Name }}]{{ else }}{{ .Tag.Name }}{{ end }} - {{ datetime "2006-01-02" .Tag.Date }}
{{ range .CommitGroups -}}
### {{ .Title }}
{{ range .Commits -}}
- {{ if .Scope }}**{{ .Scope }}:** {{ end }}{{ .Subject }}
{{ end }}
{{ end -}}
{{- if .RevertCommits -}}
### Reverts
{{ range .RevertCommits -}}
- {{ .Revert.Header }}
{{ end }}
{{ end -}}
{{- if .MergeCommits -}}
### Pull Requests
{{ range .MergeCommits -}}
- {{ .Header }}
{{ end }}
{{ end -}}
{{- if .NoteGroups -}}
{{ range .NoteGroups -}}
### {{ .Title }}
{{ range .Notes }}
{{ .Body }}
{{ end }}
{{ end -}}
{{ end -}}
{{ end -}}
{{- if .Versions }}
[Unreleased]: {{ .Info.RepositoryURL }}/compare/{{ $latest := index .Versions 0 }}{{ $latest.Tag.Name }}...HEAD
{{ range .Versions -}}
{{ if .Tag.Previous -}}
[{{ .Tag.Name }}]: {{ $.Info.RepositoryURL }}/compare/{{ .Tag.Previous.Name }}...{{ .Tag.Name }}
{{ end -}}
{{ end -}}
{{ end -}}
See the godoc RenderData documentation for available variables.
Name | Status | Features |
---|---|---|
GitHub |
|
Mentions automatic link. Automatic link to references. |
GitLab |
|
Mentions automatic link. Automatic link to references. |
Bitbucket |
|
Mentions automatic link. Automatic link to references. |
�� Even with styles that are not yet supported, it is possible to makeordinary CHANGELOG.
Jira is a popular project management tool. When a project uses Jira to trackfeature development and bug fixes, it may also want to generate change log basedinformation stored in Jira. With embedding a Jira story id in git commit header,the git-chglog tool may automatically fetch data of the story from Jira, thosedata then can be used to render the template.
Take the following steps to add Jira integration:
Where Jira issue is identical Jira story.
The following is a sample pattern:
header:
pattern: "^(?:(\\w*)|(?:\\[(.*)\\])?)\\:\\s(.*)$"
pattern_maps:
- Type
- JiraIssueID
- Subject
This sample pattern can match both forms of commit headers:
feat: new feature of something
[JIRA-ID]: something
The following is a sample:
jira:
info:
username: u
token: p
url: https://jira.com
issue:
type_maps:
Task: fix
Story: feat
description_pattern: "<changelog>(.*)</changelog>"
Here you need to define Jira URL, access username and token (password). If youdon't want to write your Jira access credential in configure file, you may definethem with environment variables: JIRA_URL
, JIRA_USERNAME
and JIRA_TOKEN
.
You also needs to define a issue type map. In above sample, Jira issue type Task
will be mapped to fix
and Story
will be mapped to feat
.
As a Jira story's description could be very long, you might not want to includethe entire description into change log. In that case, you may define description_pattern
like above, so that only content embraced with <changelog> ... </changelog>
will be included.
In the template, if a commit contains a Jira issue id, then you may show Jiradata. For example:
{{ range .CommitGroups -}}
### {{ .Title }}
{{ range .Commits -}}
- {{ if .Scope }}**{{ .Scope }}:** {{ end }}{{ .Subject }}
{{ if .JiraIssue }} {{ .JiraIssue.Description }}
{{ end }}
{{ end }}
{{ end -}}
Within a Commit
, the following Jira data can be used in template:
.JiraIssue.Summary
- Summary of the Jira story.JiraIssue.Description
- Description of the Jira story.JiraIssue.Type
- Original type of the Jira story, and .Type
will be mapped type..JiraIssue.Labels
- A list of strings, each is a Jira label.It is ideal to describe everything included in CHANGELOG in your commits. Butactually it is very difficult to do it perfectly.
There are times when you need to edit the generated output to write a great CHANGELOG.
By displaying it on the standard output, it makes it easy to change the contents.
Yes, it can be solved by using the --next-tag
flag.
For example, let's say you want to upgrade your project to 2.0.0
.You can create CHANGELOG containing 2.0.0
as follows.
git-chglog --next-tag 2.0.0 -o CHANGELOG.md
git commit -am "release 2.0.0"
git tag 2.0.0
The point to notice is that before actually creating a tag with git
, it isconveying the next version with --next-tag
This is a step that is necessary for project operation in many cases.
Yes, it can be solved by use the --tag-filter-pattern
flag.
For example, the following command will only include tags starting with "v":
git-chglog --tag-filter-pattern '^v'
git-chglog
is inspired by conventional-changelog. Thank you!
We alway welcome your contributions
>= 1.16
$ make test
command and confirm that it passes
$ make lint
command and confirm it passes
master
branch
Bugs, feature requests and comments are more than welcome in the issues.
There is a release
target within the Makefile that wraps up the steps torelease a new version.
NOTE: Pass the
VERSION
variable when running the command to properly setthe tag version for the release.
$ VERSION=vX.Y.Z make release
# EXAMPLE:
$ VERSION=v0.11.3 make release
Once the tag
has been pushed, the goreleaser
github action will take careof the rest.
I would like to make git-chglog
a better tool.The goal is to be able to use in various projects.
Therefore, your feedback is very useful.I am very happy to tell you your opinions on Issues and PR
See CHANGELOG.md
git-chglog
.git 撤销变更 Say you are a developer, and you use Git for one of your projects. You want to share the changes you made with your users, but you don’t know how. Well, then this article is for you. 假设您是一名开发
git .git目录提交 Are you a developer who has recently started using Git? If you are wondering how to create a good commit message for your project, then this article is made for you. 您是最近开始使用Git的开发人员吗? 如果
创建一个新文件 ~/.gitignore ,并将以下内容添加进去,这样全部 git 仓库将会忽略以下内容所提及的文件。 # Folder view configuration files .DS_Store Desktop.ini # Thumbnail cache files ._* Thumbs.db # Files that might appear on external disks .S
功能分支(feature branches)、发布分支(release branches)、主干(master)、开发分支(develop)、紧急修复分支(hotfixes)和标签(tag)。 Git Flow 太复杂 Git Flow 违背了分支的“短命”原则:在使用 Git 时,在同一个分支上开发代码的人越多,出现合并冲突的几率就越高。在使用 Git Flow 后,冲突几率会变得更高,因为还有
规范建设 commit message格式 <type>(<scope>): <subject> type(必须) 用于说明git commit的类别,只允许使用下面的标识。 feat:新功能(feature)。 fix/to:修复bug,可以是QA发现的BUG,也可以是研发自己发现的BUG。 fix:产生diff并自动修复此问题。适合于一次提交直接修复问题 to:只产生diff不自动修复此问题
集中式与分布式 中心服务器 工作流 分支实现 冲突 Fast forward 储藏(Stashing) SSH 传输设置 .gitignore 文件 Git 命令一览 参考资料 集中式与分布式 Git 属于分布式版本控制系统,而 SVN 属于集中式。 集中式版本控制只有中心服务器拥有一份代码,而分布式版本控制每个人的电脑上就有一份完整的代码。 集中式版本控制有安全性问题,当中心服务器挂了所有人都没
作为一名开发者怎么可能没有 Git 呢? 我们马上就来安装: $ brew install git 好的,现在我们来测试一下 git 是否安装完好: $ git --version 运行 $ which git 将会输出 /usr/local/bin/git. 接着,我们将定义你的 Git 帐号(与你在 GitHub 使用的用户名和邮箱一致) $ git config --global user.
Name git - 迟钝的内容跟踪器 概要 git [--version] [--help] [-C <path>] [-c <name>=<value>] [--exec-path[=<path>]] [--html-path] [--man-path] [--info-path] [-p|--paginate|--no-pager] [--no-replace-objects]
Overview 始终没有很好的掌握Git, 这又是Stage又是Stack的,每次冲突都要找同事来帮忙解决。 Tools 貌似SmartGit最美观最好用,但License始终是个问题,只有非商业软件才能免费用。 SourceTree最大问题是不能按目录来查看文件和Log。 Commands remove tag remotelly git tag -d V4.0.0.GA git push o
Git 可以为项目做版本控制项目。 先搜索一下: yum search git 我看到一些 git2u 这个前缀的包,这应该是 ius 仓库提供的。 安装 Git: sudo yum install git2u -y 如果出现冲突的提示,是因为你的系统里已经包含了 Git,需要先删除掉系统里的 Git 才能继续安装。 再做一点简单的配置,告诉 Git 我们是谁: git config --g