Keep Your Hook Script in Source Control: Python

jieforest發表於2012-05-30
[i=s] 本帖最後由 jieforest 於 2012-5-30 09:40 編輯

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
2.git stash -q --keep-index
3.
4.# Test prospective commit
5....
6.
7.git stash pop -q

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/301743/viewspace-731437/,如需轉載,請註明出處,否則將追究法律責任。

相關文章