IntelliJ中的交互式预提交钩子

4

我正在开发一个交互式的Git预提交钩子,以确保在提交之前满足一定的标准(例如更新存储库中的特定文件)。我的清单基于此处的示例。我的钩子具有相同的实现,但问题文本不同。目前,在Git Bash中它可以完美地工作。

然而,为了团队范围的实现,我需要它在IntelliJ中工作,因为大多数开发人员在IDE中使用Git功能。使用上面链接的示例钩子,我的提交失败并显示以下错误:

0 files committed, 1 file failed to commit: COMMIT TEST MESSAGE Would you like to play a game? .git/hooks/pre-commit: line 6: /dev/tty: No such device or address

如果可能的话,我希望完整的交互包含在IntelliJ中。如果这不是可能的,我将开始研究IntelliJ插件开发,以便在组织限制内实现它。

为方便起见,上面链接的Git钩子已粘贴如下。

#!/bin/sh

echo "Would you like to play a game?"

# Read user input, assign stdin to keyboard
exec < /dev/tty

while read -p "Have you double checked that only relevant files were added? (Y/n) " yn; do
case $yn in
    [Yy] ) break;;
    [Nn] ) echo "Please ensure the right files were added!"; exit 1;;
    * ) echo "Please answer y (yes) or n (no):" && continue;
esac
done
while read -p "Has the documentation been updated? (Y/n) " yn; do
case $yn in
    [Yy] ) break;;
    [Nn] ) echo "Please add or update the docs!"; exit 1;;
    * ) echo "Please answer y (yes) or n (no):" && continue;
esac
done
while read -p "Do you know which issue or PR numbers to reference? (Y/n) " yn; do
case $yn in
    [Yy] ) break;;
    [Nn] ) echo "Better go check those tracking numbers!"; exit 1;;
    * ) echo "Please answer y (yes) or n (no):" && continue;
    esac
done

exec <&-

你解决这个问题了吗? - Nick Div
1
不,这是2年前的事了,我接受了解释为什么不可能的回复。 - Chris
1个回答

1

我就怕是这样,感谢你确认了我的猜测。理论上,我可以实现一个打开终端并运行上述脚本的脚本吗?我的业务需求是它应该在IntelliJ中初始化,但不必完全驻留(或终止)于应用程序中。 - Chris

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接