Re: [TOPIC 2/17] Hooks in the future
- From
Junio C Hamano <gitster@pobox.com>
- Date
- Mar 13, 2020, 17:56 UTC
- Message-ID
- <xmqqeetwcf4k.fsf@gitster.c.googlers.com>
- In-Reply-To
- <20200312141628.GL212281@google.com>
Emily Shaffer <emilyshaffer@google.com> writes:
Show 9 quoted lines
> This means that we could do something like this: > > [hook "/path/to/executable.sh"] > event = pre-commit > order = 123 > mustSucceed = false > parallelizable = true > > etc, etc as needed.
You can do
[hook "pre-commit"] order = 123 path = "/path/to/executable.sh"
[hook "pre-commit"] order = 234 path = "/path/to/another-executable.sh"
as well, and using the second level for what hook the (sub)section is about, instead of "we have this path that is used for a hook. What hook is it?", feels (at least to me) more natural.
Show 5 quoted lines
> But I wonder if we also want to be able to do something like this: > > [hook "/etc/git-secrets/git-secrets"] > event = pre-commit > event = prepare-commit-msg
Once you start going this route, it no longer makes sense to give priority (you called it "order") to a path and have that same number used in contexts of different hooks. Your git-secrets script may want to be called early among pre-commit hooks but late among the prepare-commit-msg hooks, for example.
> I think, though, that something like > hook.pre-commit."path/to/executable.sh" won't work.
That is why Peff already suggested in the TOPIC notes to use "command" in the message you are responding to (I used "path" in the above description).