summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--app/workers/post_receive.rb14
-rw-r--r--config/gitlab.yml.example3
2 files changed, 14 insertions, 3 deletions
diff --git a/app/workers/post_receive.rb b/app/workers/post_receive.rb
index a906f78f7e3..6d31c08fefc 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 4df8efa9c06..1a34d22417f 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