
来自 AngularJS 所用的规范,格式如下:
<type>(<scope>): <subject> <body> <footer> 各段内容说明:
标准化的 Git Commit Message 可以用工具过滤出 feat 和 fix 的 Commit 生成 ChangeLog,例如:
git log --format='%s (%h)' --reverse --grep '^\(feat\|fix\)' --since=2020-01-01 --before=2020-02-01 | sed 's/([^)]*):/:/' | sort -k1,1 -s 可以添加到 ~/.gitconfig 里:
[alias] change-of-last-mOnth= !sh -c 'git log --format=\"%s (%h)\" --reverse --grep \"^\\(docs\\|feat\\|fix\\|perf\\|refactor\\|test\\)\" --since=`date -v-1m +\"%Y-%m-01\"` --before=`date +\"%Y-%m-01\"` | sed \"s/([^)]*):/:/\" | sort -k1,1 -s' 之后用 git change-of-last-month 就可以输出上个月的 ChangeLog。
比如这是我的模板,权作 Commit 时的提醒:
# feat/fix/docs/refactor/perf/test/style/revert/chore(scope/issue): changelog # Modify issues if necessary # Details if any # 开头的行会被作为注释过滤掉。
git config --global commit.template path/to/template 也可以在 ~/.gitconfig 中手动添加
[commit] template = path/to/template 之后提交时,使用 git commit 不带 -m 参数,就可以调出模板。
1 loading 2020-03-12 21:29:57 +08:00 via Android |
2 hantsy 2020-03-12 22:01:33 +08:00 Good job |
3 labulaka521 2020-03-12 22:09:05 +08:00 收藏了 |
4 hallDrawnel 2020-03-12 22:31:11 +08:00 |
5 xiqingongzi 2020-03-12 22:43:24 +08:00 via iPhone gitstyle.js.orf |
6 xiqingongzi 2020-03-12 22:43:31 +08:00 via iPhone |
7 Smash 2020-03-12 23:06:07 +08:00 Google 的规范 Github 上应用得挺广泛的 |
8 sunwei0325 2020-03-12 23:33:38 +08:00 生成 changelog 的不错, 现在用的是一个 npm 命令 conventional-changelog |
9 noqwerty 2020-03-13 00:11:59 +08:00 via Android 用了一段时间 commitizen 了,挺香的,逼着自己写详细的 commit message |
11 noqwerty 2020-03-13 00:20:37 +08:00 @xiadada #10 很方便啊,如果用 Angular 规范的话按着文档来就三行命令的事,之后就 git cz 就可以了。 https://github.com/commitizen/cz-cli#conventional-commit-messages-as-a-global-utility |
12 CBS 2020-03-13 01:22:52 +08:00 学习了。 |
13 geelaw 2020-03-13 03:13:11 +08:00 via iPhone Imperative 是“祈使语气”,而不是“第一人称”,而且根据最先的原文这个只适用于对代码改变的描述(原因描述需要其他人称和语气)。 |
14 blueset 2020-03-13 07:01:08 +08:00 via Android |
15 zhuzhibin 2020-03-13 09:06:51 +08:00 via iPhone 不是 git cz? |
16 RoshanWu 2020-03-13 09:43:05 +08:00 自动生成 ChangeLog 如果不那么追求定制化,需要比较傻瓜的方式,可以用用我的这个: https://github.com/roshanca/autochangelog 这里是生成的例子: https://github.com/roshanca/autochangelog/blob/master/CHANGELOG.md |
17 ethusdt 2020-03-13 10:45:11 +08:00 style 这种类型是对代码层面对优化 lint,还是指前端样式上的调整? |
18 Poarry 2020-03-13 15:25:11 +08:00 收藏了 |
19 sepdy 2020-03-14 03:57:54 +08:00 via iPhone 我倒是觉得能表述的内容太少。gitmoji 用起来更好玩。看起来没那么“单调” |