0

I wrote a pre-commit hook for bazaar which checks some syntax issues in our code. Something similar to:

http://bazaar.launchpad.net/~bialix/%2Bjunk/checkeol/annotate/head%3A/__init__.py

Everything works, however, I would like to additionally add a command line option, which could disable this hook, e.g.,

If I called bzr commit --ignore-my-hook it would skip my pre-commit hook.

I know that there exists also option --no-plugins but that disables all plugins. I would really like to know if this is possible. Any ideas? Thank you.

John Szakmeister
  • 44,691
  • 9
  • 89
  • 79
pisoir
  • 192
  • 3
  • 13

1 Answers1

0

You can set the environment variable:

BZR_DISABLE_PLUGIN=yourplugin

to disable one specific plugin.

Or alternatively, you can add functionality to your hook to not do anything if a certain option or environment variable is set. You can set configuration options from the command line, which you can access from the hook. T

There is no other custom command line input you can provide to the hook.

jelmer
  • 2,405
  • 14
  • 27
  • Thanks for the answer. My question was however more about that if the pre-commit hooks (or any hooks) can have input parameters, in general, which can be called directly from command line. I assume it must be possible, but unfortunately I had no luck to find out. – pisoir Jun 13 '17 at 18:22
  • I've clarified the answer. – jelmer Jun 13 '17 at 18:36
  • @jelmer is right that hooks cannot modify command-line parameters. But your plugin *can* override the commit command and substitute its own version that supports additional parameters. – Aaron Bentley Oct 26 '17 at 18:44