开发者

Forbidding pushes on Git/Mercurial

Is there any plugin for distributed SCMs that forbids pushing cod开发者_StackOverflow中文版e that doesn't fulfil a certain criteria (e.g. min test coverage)?


https://git-scm.com/book/en/v2/Customizing-Git-Git-Hooks states that for server-side checking you could use update hooks.

You should place hooks in your central main repository of course.


You can do this with a pre-commit/pre-changeset hook.

The hgrc Man Page has some info. Probably better is the hg book section on hooks.


In mercurial, you'll want to use hooks. Use a controlling hook on the server side, pretxnchangegroup most likely. Here's a good example of a hook that prevents someone from doing a push that creates multiple heads: http://hg.netbeans.org/nb-hooks/file/tip/forbid_2head.py


Both current answers address Mercurial; with git, there are also hooks, and you will want either the pre-receive or update hook. See the githooks man page for information.

Be careful using them to check for things like test coverage, though - you don't want the user to have to wait for time-consuming tests to run while attempting to push.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜