【发布时间】:2019-06-29 02:28:18
【问题描述】:
在 git commit-msg 中的 Windows 上,我想运行以下脚本:
MSG="$1"
if ! grep -s -qE "#[0-9]" "$MSG";then
exec < /dev/tty
cat "$MSG"
echo "Your commit message does not contain a reference to a work item. Continue? [y/n]"
read -s -n 1 sure
if [[ $sure == "y" ]]; then
exit 0
else
echo "Aborting commit..."
exit 1
fi
fi
当我使用 Git 扩展时它运行良好。
但是,当我想直接从 Visual Studio(团队资源管理器或 Git 更改)提交时,会出现以下错误消息:
Your git-hook, '.git/hooks/commit-msg' (line 23) is not supported, likely because it expects interactive console support./r/nSee your administrator for additional assistance.
我的问题: 有没有可能检查 exec/tty 是否可以执行?否则我只会打印一条相应的消息。
提前致谢。
【问题讨论】: