【发布时间】:2016-01-11 14:48:30
【问题描述】:
我的 git 存储库中有一个运行测试的预推送脚本。如果测试通过,则推送继续。如果测试失败,它将中止推送。
脚本运行了一段时间,直到测试开始超过 3 分钟。标准输出在测试输出中间显示“与远程主机关闭的 bitbucket 的连接”。然后所有的测试都通过了,推送实际上并没有通过。
这是预推送脚本
#!/bin/sh
DIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )
# This script runs tests before any push to the MASTER branch and fails
current_branch=$(git symbolic-ref HEAD | sed -e 's,.*/\(.*\),\1,')
echo "Current branch: "$current_branch
if [ $current_branch = "master" ]
then
echo "Pushing to MASTER branch requires tests to pass..."
./run.sh test
if [ $? = 0 ]
then
exit 0
else
echo "***ERROR> Failed to pass tests! Get tests to pass and then try again..."
exit 1
fi
else
echo "Skipping tests since we're not pushing to MASTER..."
fi
【问题讨论】:
-
@greg0ire,我已经尝试过 600 次睡眠,它对我来说效果很好。 exit 1 代码停止推送
-
没看懂,能详细点吗?