Tiago Fernandez
Tiago Fernandez

Reputation: 1473

Forbidding pushes on Git/Mercurial

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

Upvotes: 1

Views: 565

Answers (4)

MBO
MBO

Reputation: 31025

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.

Upvotes: 3

Cascabel
Cascabel

Reputation: 497652

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.

Upvotes: 1

Ry4an Brase
Ry4an Brase

Reputation: 78350

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

Upvotes: 2

Matthew Schinckel
Matthew Schinckel

Reputation: 35649

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.

Upvotes: 2

Related Questions