commitizen / commitizen/cz-cli
Git-generated trailers are not preserved
- 主要言語
- JavaScript
- スター
- 17.5k
- フォーク
- 566
- 平均マージ
- 8時間 16分
- マージ済み PR(30日)
- 1
説明
Commitizen's `--hook` option truncates the `COMMIT_EDITMSG` file. This wipes the `Signed-off-by` trailer generated by Git's `-s` flag, as well as any other trailers that might have been there before running Commitizen, and forces us to amend our commits after the fact.
We have a temporary workaround in our hook for this, which might offer some insight:
```sh
#!/bin/bash
file="$1"
type="$2"
if [ -z "$type" ]; then # only run on new commits
#
# Save any commit message trailers generated by Git.
#
trailers=$(git interpret-trailers --parse "$file")
#
# Execute the Commitizen hook.
#
(exec < "/dev/tty" && npx --no-install git-cz --hook) || true
#
# Restore any trailers that Commitizen might have overwritten.
#
printf "\n" >> "$file"
while IFS= read -r trailer; do
git interpret-trailers --in-place --trailer "$trailer" "$file"
done <<< "$trailers"
fi
```
Version: cz-cli@4.2.2, cz-conventional-changelog@3.3.0
コントリビューションガイド
調査の方向性
issue ではソースファイルもテストも指定されていません。まず、`COMMIT_EDITMSG` を書き換える `--hook` の経路を追跡し、Git の `-s` および `interpret-trailers` の動作と比較してください。Git が生成した trailer と既存の trailer が、post-commit の修正を必要とせずに hook を通過すれば完了です。
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- git, javascript, shell
- 領域
- cli
- issue の種類
- バグ
- 難易度
- 3/5
- 見積もり時間
- 1〜2日
- 活発さ
- 停滞
- 明瞭さ
- おおむね明確
- 初心者へのやさしさ
- 35/100