Skip to content

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:

  1. 01-hook1.sh
  2. 02-hook2.pl
  3. 03-hook3.py

Docs MR: https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/6721

Merge request reports