diff options
author | Patrick Steinhardt <psteinhardt@gitlab.com> | 2021-02-11 12:53:02 +0300 |
---|---|---|
committer | Patrick Steinhardt <psteinhardt@gitlab.com> | 2021-02-12 09:53:00 +0300 |
commit | cebe1d983e22fb5a3b95b3be7600883a1d37b7ee (patch) | |
tree | 1270cf7bf90e55fc51b637629f1b0305c277285b /cmd/gitaly-hooks | |
parent | d5de6a1b267caaac9f4b99fb3c5d3606728ad61a (diff) |
git: Add bitfield of requested hooks to HooksPayload
When we set up hooks via `configureHooks()`, then we tell git where to
find our git hooks via `core.hooksPath`. This allows it to find hooks
and execute them in case any hook needs to run in the context of the
current git command.
"Any" is the important part here, though: even if we want to only
execute e.g. the reference-transaction hook, any other hook would also
get executed if we call `configureHooks()`. This is unexpected any may
even be dangerous in some situations given that we now run unexpected
hooks with a potentially wrong setup. It would be fatal if we
accidentally started to execute the pre-receive or post-receive hooks if
we didn't intend to, as they do all kinds of things like triggering CI,
access checks and so on.
This commit thus introduces a new bitfield of requested hooks to the
hooks payload: any callsite which configures hooks is expected to say
exactly which kinds of hooks it wants to run. For any given hook that
gitaly-hooks is then about to execute, it will first check whether the
corresponding bit in that bitfield is set -- if not, it'll simply skip
execution and return successfully as if the hook didn't exist in the
first place.
This commit is only preparing for that actual change. Neither does it
change gitaly-hooks yet to pay attention to the bitfield, nor do we
correctly set up the bitfield. Instead, we use some fallback logic to
support zero-downtime upgrades and always set the bitfield to request
all hooks for now.
Diffstat (limited to 'cmd/gitaly-hooks')
0 files changed, 0 insertions, 0 deletions