Commit 7121a58eb9e4dcb63d762e17a668f3bb4b0eaa85
1 parent
f72dc7f7
Exists in
master
and in
4 other branches
Advanced logging for post-receive worker
Showing
2 changed files
with
14 additions
and
3 deletions
Show diff stats
app/workers/post_receive.rb
@@ -4,12 +4,22 @@ class PostReceive | @@ -4,12 +4,22 @@ class PostReceive | ||
4 | sidekiq_options queue: :post_receive | 4 | sidekiq_options queue: :post_receive |
5 | 5 | ||
6 | def perform(repo_path, oldrev, newrev, ref, identifier) | 6 | def perform(repo_path, oldrev, newrev, ref, identifier) |
7 | - repo_path.gsub!(Gitlab.config.gitolite.repos_path.to_s, "") | 7 | + |
8 | + if repo_path.start_with?(Gitlab.config.gitolite.repos_path.to_s) | ||
9 | + repo_path.gsub!(Gitlab.config.gitolite.repos_path.to_s, "") | ||
10 | + else | ||
11 | + Gitlab::GitLogger.error("POST-RECEIVE: Check gitlab.yml config for correct gitolite.repos_path variable. \"#{Gitlab.config.gitolite.repos_path}\" does not match \"#{repo_path}\"") | ||
12 | + end | ||
13 | + | ||
8 | repo_path.gsub!(/.git$/, "") | 14 | repo_path.gsub!(/.git$/, "") |
9 | repo_path.gsub!(/^\//, "") | 15 | repo_path.gsub!(/^\//, "") |
10 | 16 | ||
11 | project = Project.find_with_namespace(repo_path) | 17 | project = Project.find_with_namespace(repo_path) |
12 | - return false if project.nil? | 18 | + |
19 | + if project.nil? | ||
20 | + Gitlab::GitLogger.error("POST-RECEIVE: Triggered hook for non-existing project with full path \"#{repo_path} \"") | ||
21 | + return false | ||
22 | + end | ||
13 | 23 | ||
14 | # Ignore push from non-gitlab users | 24 | # Ignore push from non-gitlab users |
15 | user = if identifier.eql? Gitlab.config.gitolite.admin_key | 25 | user = if identifier.eql? Gitlab.config.gitolite.admin_key |
config/gitlab.yml.example
@@ -106,7 +106,8 @@ backup: | @@ -106,7 +106,8 @@ backup: | ||
106 | ## Gitolite settings | 106 | ## Gitolite settings |
107 | gitolite: | 107 | gitolite: |
108 | admin_uri: git@localhost:gitolite-admin | 108 | admin_uri: git@localhost:gitolite-admin |
109 | - # repos_path must not be a symlink | 109 | + |
110 | + # REPOS_PATH MUST NOT BE A SYMLINK!!! | ||
110 | repos_path: /home/git/repositories/ | 111 | repos_path: /home/git/repositories/ |
111 | hooks_path: /home/git/.gitolite/hooks/ | 112 | hooks_path: /home/git/.gitolite/hooks/ |
112 | admin_key: gitlab | 113 | admin_key: gitlab |