开发者

Forbidding pushes on Git/Mercurial

开发者 https://www.devze.com 2022-12-17 22:28 出处:网络
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

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

精彩评论

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

关注公众号