从提交和标记生成更改日志 [英] Generate changelog from commit and tag
本文介绍了从提交和标记生成更改日志的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试为项目(bitbucket.org中的repo)生成ChangeLog,但我找不到简单的解决方案。我们正在使用this pattern
(<type>(<scope>): <subject>)
填写提交消息,并将标记添加到版本(0.1、0.2、0.3)。
是否有开箱即用的功能(一些脚本、NPM包等)或者我能做的最好的事情就是使用git日志编写一些自定义脚本并解析数据(提交消息等)?
我知道有gihub-changelog-creator,但只要此repo在Bitbucket repo中,我就不能使用。
推荐答案
我们使用此简单的外壳脚本生成按标记排序的分层更改日志,最新标记位于顶部。
#!/usr/bin/env bash
previous_tag=0
for current_tag in $(git tag --sort=-creatordate)
do
if [ "$previous_tag" != 0 ];then
tag_date=$(git log -1 --pretty=format:'%ad' --date=short ${previous_tag})
printf "## ${previous_tag} (${tag_date})
"
git log ${current_tag}...${previous_tag} --pretty=format:'* %s [View](https://bitbucket.org/projects/test/repos/my-project/commits/%H)' --reverse | grep -v Merge
printf "
"
fi
previous_tag=${current_tag}
done
您可以将其作为某个外壳文件放在项目根目录中并运行它(根据您的平台,您可能需要使其成为可执行文件),如下所示
sh change-log-builder.sh > changelog.md
生成的changelog.md如下所示
v1.1.0(2017-08-29)
- 添加IPv6支持[查看]
- 添加TreeMaker类及其测试。[查看]
v1.0.9(2017-08-22)
- 更新Composer.json.lock[查看]
v1.0.8(2017-08-22)
- 将S3Gateway添加为替身类[查看]
- 删除不再使用的文件[查看]
这篇关于从提交和标记生成更改日志的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文