コミットメッセージが特定のガイドラインに準拠していない場合はユーザーに警告し、コミットメッセージを編集するか、警告を無視するか、コミットをキャンセルするかを選択できるようにします。問題は、私がstdinにアクセスできないように見えることです。
以下は私のcommit-msgファイルです:
function verify_info {
if [ -z "$(grep '$2:.*[a-zA-Z]' $1)" ]
then
echo >&2 $2 information should not be omitted
local_editor=`git config --get core.editor`
if [ -z "${local_editor}" ]
then
local_editor=${EDITOR}
fi
echo "Do you want to"
select CHOICE in "edit the commit message" "ignore this warning" "cancel the commit"; do
case ${CHOICE} in
i*) echo "Warning ignored"
;;
e*) ${local_editor} $1
verify_info "$1" $2
;;
*) echo "CHOICE = ${CHOICE}"
exit 1
;;
esac
done
fi
}
verify_info "$1" "Scope"
if [ $# -ne 0 ];
then
exit $#
fi
verify_info "$1" "Affects"
if [ $# -ne 0 ];
then
exit $#
fi
exit 0
スコープ情報を空白のままにした場合の出力は次のとおりです。
Scope information should not be omitted
Do you want to:
1) edit the commit message 3) cancel the commit
2) ignore this warning
#?
メッセージは正しいですが、実際には入力のために停止しません。より単純な「読み取り」コマンドを使用してみましたが、同じ問題があります。問題は、この時点でgitがstdinを制御し、独自の入力を提供していることだと思われます。これを修正するにはどうすればよいですか?
更新:これはこの質問の複製である可能性がありますが、残念ながら私は運が悪いことを示唆しているようです。