saa*_*ada 7 git testing githooks
我的git仓库中有一个预推脚本运行测试.如果测试通过,那么继续推进.如果测试失败,则中止推送.
脚本运行一段时间,直到测试开始超过3分钟.stdout在测试输出的中间显示"连接到远程主机关闭的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
Run Code Online (Sandbox Code Playgroud)
我最终git push --no-verify在成功案例内部打电话。所以它有效地推动了两次。
#!/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
# workaround to guarantee my push goes through even if the first attempt times out
git push --no-verify
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
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
2667 次 |
| 最近记录: |