On Windows in a git commit-msg I want to run following script:
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
It runs fine when I use Git extensions.
But when I want to commit directly from Visual Studio (Team Explorer or Git Changes) an error with following message is occurring:
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.
My question: Is there a possibility to check, whether exec < /dev/tty can be executed? Otherwise I would just print a corresponding message.
Thanks in advance.