How can I reject git pushes on an origin repo from a local repo if it does not pass unit tests?

独自空忆成欢 提交于 2019-12-07 12:27:26

问题


I have an origin repo that I have full access to and I don't want code to be pushed successfully to this repo unless the code being pushed successfully passes my unit tests. I saw many examples of .git/hooks/update scripts and they seem to break down into a few categories that do not fit my use case.

For example, in (http://git-scm.com/book/en/Customizing-Git-An-Example-Git-Enforced-Policy), the script accesses files locally in the .git/hooks/ directory (ACL example) or individual files in the new or old SHAs.

I need to do an entire build process on all the new files as if I were in the directory of the new commit and were running

.git/hooks/update

#!/usr/bin/bash
mvn test
exit $?

回答1:


I would recommend a guarded commit approach, where you are pushing to an intermediate repo, which:

  • triggers the mvn test
  • push, upon successful completion, to your actual intended repo.


来源:https://stackoverflow.com/questions/21154380/how-can-i-reject-git-pushes-on-an-origin-repo-from-a-local-repo-if-it-does-not-p

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!