tags:

views:

109

answers:

4

Is there any plugin for distributed SCMs that forbids pushing code that doesn't fulfil a certain criteria (e.g. min test coverage)?

+2  A: 

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.

Matthew Schinckel
pre-commit won't catch pushes, and pre-changeset doesn't have access to the incoming changesets. pretxnchangegroup is probably what he wants.
Ry4an
+2  A: 

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

Ry4an
+3  A: 

http://progit.org/book/ch7-3.html states that for server-side checking you could use update hook. Other source of hook documentation: http://book.git-scm.com/5_git_hooks.html.

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

MBO
The OP asks about pushing, not committing. Of course, maybe that was just an inaccurate word choice... either way, we agree, use hooks.
Jefromi
+1  A: 

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.

Jefromi