Is there a way in mercurial to run a hook before doing a push. For example I'd like to run JSHint over the codebase when I type hg push
and abort the push when any errors are found.
I first tried using a pre-commit
hook. That worked, but it's a nuisance to wait a few seconds before each commit. Besides, I'd like to sometimes do intermediate commits with possibly broken code.
Reading the docs for hgrc I discovered preoutgoing
and pre-outgoing
which seemed like the thing I'd like. But these didn't work. The only thing they seem to do is run the hook when I type:
hg outgoing
Not useful for me at all.
Found a solution. Posting it here in case somebody else is wondering about the same thing.
Turns out the documentation was just confusing for me. It told:
I thought that the
<command>
it referred to is one of the hook types likeoutgoing
orcommit
and I couldn't find apush
hook listed there. But turns out the command is just any mercurial command, so I can just usepre-push
.Issue solved :)