Add support for global custom hooks and chained hook directories

Elan Ruusamäe requested to merge glensc/gitlab-shell:pr-245 into master

This is continuation of PR#245 from GitHub and !89 (closed) addressing #32 (closed)

With changes of mine:

  1. process per project hooks <repository>.git/custom_hooks/<hook_name>.d/* as <repository>.git/custom_hooks is local dir for <repository>.git
  2. process global hooks from <repository>.git/hooks/<hook_name>.d/* because <repository>.git/hooks is symlink to gitlab-shell/hooks

the hooks matched by shell glob must be:

  1. executable (+x bit set)
  2. not matching editor backup files (*~)

the overview of the whole process:

  • <repository>.git/hooks/ - symlink to gitlab-shell/hooks global dir
  • <repository>.git/hooks/<hook_name> - executed by git itself, this is gitlab-shell/hooks/<hook_name>
  • <repository>.git/custom_hooks/<hook_name> - per project hook (this is already existing behavior)
  • <repository>.git/custom_hooks/<hook_name>.d/* - per project hooks
  • <repository>.git/hooks/<hook_name>.d/* - global hooks: all executable files (minus editor backup files)

the files matched by glob are also sorted so if order of hooks is important, one can name their hooks as:


Docs MR:

Merge request reports