Hooks

Jelmer Vernooij jelmer at jelmer.uk
Fri Dec 11 15:46:14 UTC 2020


On Fri, Dec 11, 2020 at 03:32:46PM +0000, Sam Bull wrote:
> On Fri, 2020-12-11 at 15:13 +0000, Jelmer Vernooij wrote:
> > 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 ?
> 
> I think when I last looked it was still talking about bazaar, so it's probably
> been updated a little (although I notice it's still Python 2 syntax in the
> examples).
Ah, that's a good point. I'll update it to Python 3 syntax.

> I managed to do the pre-commit as you said, by adding it to the user config
> directory. Is there a way to make it local to a particular repo? Is it possible
> to have it part of the repo in such a way that it is automatically used? i.e.
> someone uses 'brz branch' and then when they commit it runs automatically, with
> no extra configuration.
The easiest is to have a user-local plugin that then checks a
configuration variable in the repository to see whether it needs to
act.

Unfortunately there are some security concerns with shipping these
kinds of hooks with the repo - you don't want to just run arbitrary
code from a branch you've cloned. There are ways around that - we
could allow branch-specific plugins under .bzr/plugins in the branch,
or something like that (so they're not cloned), but that's not implemented
or planned at the moment.

Cheers,

Jelmer

-- 
Jelmer Vernooij <jelmer at jelmer.uk>
PGP Key: https://www.jelmer.uk/D729A457.asc



More information about the bazaar mailing list