Cre*_*eos 7 git intellij-idea android-studio android-gradle-plugin gradle-plugin
我正在使用 Android Studio (itellij) IDE 和对 Git 作为 VCS 的内置支持。
是否有任何钩子/选项来断言在成功运行某些 gradle 任务时提交提交。您可能会怀疑,我正在尝试自动运行整个单元测试套件,并在任何单元测试失败时阻止本地提交。
仍然需要研究 git commit hooks 是如何工作的
hooks
在您的.git
文件夹中创建一个目录并将文件命名为“pre-commit
”
(如果你不是在 Windows 上,也让它可执行)
但作为中提到你的链接的问题由sschuberth:
在
pre-commit
挂钩中添加长时间运行的任务通常是一个坏主意,因为它会阻止您工作。
此类检查应在 CI 系统上进行,该系统可对破坏测试的提交进行门控合并
换句话说,使用 pre-receive hook 提交并推送到一个中间 repo,如果整个单元测试套件在任何时候都失败,它将拒绝你的推送。
该OP Creos指出在评论中下面的pre-commit钩子要点例如由乍得莫恩,是一个很好的模板:
#!/bin/sh
# 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
# run the tests with the gradle wrapper
./gradlew test
# 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
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
2960 次 |
最近记录: |