ITPub博客

首页 > Linux操作系统 > Linux操作系统 > Keep Your Hook Script in Source Control: Python

Keep Your Hook Script in Source Control: Python

原创 Linux操作系统 作者:jieforest 时间:2012-05-30 09:43:56 0 删除 编辑
[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/,如需转载,请注明出处,否则将追究法律责任。

请登录后发表评论 登录
全部评论

注册时间:2008-04-23

  • 博文量
    443
  • 访问量
    508131