Commit your hook script. (say pre-commit.sh) at the rootof your project and include the installation instructions in yourREADME/documentation to encourage all developers use it.
Installation is nothing more than:
CODE:
ln -s ../../pre-commit.sh .git/hooks/pre-commit[size=11.5pt]Then everyone benefits from running the same set of testsbefore committing and updates are picked up automatically.
[size=11.5pt]
[size=11.5pt]Stash unstaged changes before running tests[size=11.5pt]
[size=11.5pt]
[size=11.5pt]Ensure that code that isn't part of the prospectivecommit isn't tested within your pre-commit script. This is missed by manysample pre-commit scripts but is easily acheived with git stash:
CODE:
1.# pre-commit.sh来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/301743/viewspace-731437/ ,如需转载,请注明出处,否则将追究法律责任。