Skip to content

hooks: Improved validation and testing

Patrick Steinhardt requested to merge pks-hooks-validation into master

This MR improves validation of inputs for our hook implementations and implements a bunch of tests to improve test coverage. Most importantly, we're now checking that the passed environment contains a bunch of variables which are required to be present, as this has caused regressions in the past. Ideally, we'd just get rid of this env array and replace it with explicit parameters, but I'll rather leave that to a later point until we're finally starting to trust our hooks again.

Also missing is validation of parameters passed by Git, which most notably is stdin for pre-receive and post-receive hooks as well as the three argument passed to update. I've tried hard to get Git to not populate these, but failed. Which indicates that they should never be empty. I'm still a bit too hesitant to actually add those checks, which is why I'm instead deferring them to a follow-up MR.

Merge request reports