From 7121a58eb9e4dcb63d762e17a668f3bb4b0eaa85 Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets Date: Tue, 29 Jan 2013 11:32:05 +0200 Subject: [PATCH] Advanced logging for post-receive worker --- app/workers/post_receive.rb | 14 ++++++++++++-- config/gitlab.yml.example | 3 ++- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/app/workers/post_receive.rb b/app/workers/post_receive.rb index a906f78f7..6d31c08fe 100644 --- a/app/workers/post_receive.rb +++ b/app/workers/post_receive.rb @@ -4,12 +4,22 @@ class PostReceive sidekiq_options queue: :post_receive def perform(repo_path, oldrev, newrev, ref, identifier) - repo_path.gsub!(Gitlab.config.gitolite.repos_path.to_s, "") + + if repo_path.start_with?(Gitlab.config.gitolite.repos_path.to_s) + repo_path.gsub!(Gitlab.config.gitolite.repos_path.to_s, "") + else + 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}\"") + end + repo_path.gsub!(/.git$/, "") repo_path.gsub!(/^\//, "") project = Project.find_with_namespace(repo_path) - return false if project.nil? + + if project.nil? + Gitlab::GitLogger.error("POST-RECEIVE: Triggered hook for non-existing project with full path \"#{repo_path} \"") + return false + end # Ignore push from non-gitlab users user = if identifier.eql? Gitlab.config.gitolite.admin_key diff --git a/config/gitlab.yml.example b/config/gitlab.yml.example index 4df8efa9c..1a34d2241 100644 --- a/config/gitlab.yml.example +++ b/config/gitlab.yml.example @@ -106,7 +106,8 @@ backup: ## Gitolite settings gitolite: admin_uri: git@localhost:gitolite-admin - # repos_path must not be a symlink + + # REPOS_PATH MUST NOT BE A SYMLINK!!! repos_path: /home/git/repositories/ hooks_path: /home/git/.gitolite/hooks/ admin_key: gitlab -- 2.11.0