按照惯例,我在 git 中创建故事分支,以在其中包含 Jira 问题 ID,例如FOO-1001。我有一个脚本可以帮我做到这一点。现在,我准备了另一个脚本,用于从 Jira API 获取 FOO-1001 的标题。我想在输入时实现这一目标:
$ git commit
我的编辑器打开时预填充了以下内容:
BUGFIX: FOO-1001 Some sample issue title downloaded using my script
使用我描述的脚本实现此目的最简单的方法是什么?我的想法是以某种方式将提交消息格式化为文件,以便 git 可以找到它并用作默认值。一种方法似乎是使用prepare-commit-msg
钩子,但我更愿意使用独立脚本来实现我的目标,而不需要任何配置.git
(以便我的同事可以轻松地重复使用它)。
The commit
命令有一个从模板读取提交消息的选项:
-t <file>, --template=<file>
When editing the commit message, start the editor with the contents
in the given file. The commit.template configuration variable is often
used to give this option implicitly to the command. This mechanism can
be used by projects that want to guide participants with some hints on
what to write in the message in what order. If the user exits the editor
without editing the message, the commit is aborted. This has no effect
when a message is given by other means, e.g. with the -m or -F options.
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)