Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I share a commit-hook in mercurial with all fellow developers?

we are working with mercurial and now we would like to introduce precommit hooks to keep the code clean. We would like everyone to somehow get the hooks, but we would also like to be able to update this in some centralized way. Mercurial does not version control hooks, so what would be our alternative option? Do any of you have found a solution for this? Thanks in advance!

Nemmi

like image 881
Nemmi Avatar asked Feb 03 '23 21:02

Nemmi


2 Answers

Hooks are not cloned (as detailed in "Version-controlled extension configuration in Mercurial"), but you can have a common hgrc file (see hgrc Syntax):

A line of the form %include file will include file into the current configuration file

In that central configuration file, you can then modify the [hooks] section.

like image 97
VonC Avatar answered Feb 05 '23 10:02

VonC


If you have control over their desktops (it's a standard corporate install) you can put the hook in the system-wide entries /etc/mercurial/hgrc or /etc/mercurial/hgrc.d/ourcommithook

If you're remotely administering the machines you could automate this using something like the very excellent puppet or by building your own .rpm, .deb, or .msi installer which both installed Mercurial and places the everyone hooks in the machine-global config.

like image 36
Ry4an Brase Avatar answered Feb 05 '23 11:02

Ry4an Brase