user2708750
user2708750

Reputation: 23

gitlab pre-receive hook is executed for all repositories though defined only for one

We have gitlab v7.10.5 While testing server-side pre-receive hooks I noticed some strange behavior. Hook defined for only one repository somehow getting executed for all repositories on the server.

I've written the test script that only outputs "Hello world" smile message. I've got it installed as the pre-receive hook for just ONE repository, say test.git. works fine.

When I push to the other repo, I get the "Hello world" message. The other repo has no connections to the test repo. Is that a bug?

Upvotes: 1

Views: 914

Answers (1)

JShumaker
JShumaker

Reputation: 300

The reason is because the hooks directory in gitlab repositories is just a symlink to the gitlab-shell hooks folder. If you overwrote that pre-receive script, you can actually break GitLab, as it depends upon this for applying it's permission levels. As it's a common hooks folder for all projects, yes it would run for all of them.

Instead there is support for a custom_hooks folder with a pre-receive script in it that the gitlab global hooks will detect and call.

Upvotes: 1

Related Questions