篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了sh 一个git pre commit hook,它使用gradle包装器运行测试任务相关的知识,希望对你有一定的参考价值。
#!/usr/bin/env bash
# this hook is in SCM so that it can be shared
# to install it, create a symbolic link in the projects .git/hooks folder
#
# i.e. - from the .git/hooks directory, run
# $ ln -s ../../git-hooks/pre-commit.sh pre-commit
#
# to skip the tests, run with the --no-verify argument
# i.e. - $ 'git commit --no-verify'
# stash any unstaged changes
git stash -q --keep-index
ABSOLUTE_PATH=$(cd `dirname "${BASH_SOURCE[0]}"`)
ABSOLUTE_PARENT_PATH="$(dirname "$ABSOLUTE_PATH")"
# run the tests with the gradle wrapper
sh $ABSOLUTE_PARENT_PATH/gradlew testMockedDebug testMockedRelease --daemon
# store the last exit code in a variable
RESULT=$?
# unstash the unstashed changes
git stash pop -q
# return the './gradlew test' exit code
exit $RESULT
以上是关于sh 一个git pre commit hook,它使用gradle包装器运行测试任务的主要内容,如果未能解决你的问题,请参考以下文章