12

慣例により、FOO-1001 などの Jira 課題 ID を含めるために、git でストーリー ブランチを作成します。私はそれを行うためのスクリプトを持っています。ここで、Jira API から FOO-1001 のタイトルを取得する別のスクリプトを用意しました。入力したときにそれを達成したい:

$ git commit

私のエディターが開き、次の情報が事前に入力されます。

BUGFIX: FOO-1001 Some sample issue title downloaded using my script

私が説明したスクリプトを使用してこれを実現する最も簡単な方法は何ですか? 私の考えは、gitがそれを見つけてデフォルトとして使用できるように、何らかの方法でコミットメッセージをファイルにフォーマットすることです。1 つの方法はフックを使用することですが、(同僚が簡単に再利用できるように)prepare-commit-msg構成を行わずに、スタンドアロン スクリプトを使用して目的を達成することをお勧めします。.git

4

2 に答える 2

17

この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.
于 2013-03-21T20:58:46.697 に答える