Hooks
Jelmer Vernooij
jelmer at jelmer.uk
Fri Dec 11 15:13:14 UTC 2020
On Fri, Dec 11, 2020 at 02:51:20PM +0000, Sam Bull wrote:
> Can anybody provide an example of some simple hooks?
>
> I tried looking at documentation, but didn't get anywhere.
>
> For example, a pre-commit hook which returns false and blocks the commit and a
> hook that runs an arbitrary command after a pull/merge would be great.
Was the documentation that you looked at
https://www.breezy-vcs.org/doc/en/user-guide/hooks.html ?
You should be able to raise an exception from a pre-commit hook to
prevent the commit from going through.
There is a 'post_merge' hook that gets run after merge operations,
which gets called with a Merger object.
Something like this should work:
import breezy.merge
def merge_hook(merger):
subprocess.check_call("arbitrary command", cwd=merger.working_tree.basedir)
breezy.merge.Merger.hooks.install_named_hook('post_merge', merge_hook)
Jelmer
--
Jelmer Vernooij <jelmer at jelmer.uk>
PGP Key: https://www.jelmer.uk/D729A457.asc
More information about the bazaar
mailing list