From c837da34391094b9d58763a67db5cfb706ca146f Mon Sep 17 00:00:00 2001 From: Jacob Vosmaer Date: Fri, 24 Mar 2017 16:54:22 +0100 Subject: Helper method for storage path stripping --- app/workers/post_receive.rb | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) (limited to 'app/workers') diff --git a/app/workers/post_receive.rb b/app/workers/post_receive.rb index 2cd87895c55..015a41b6e82 100644 --- a/app/workers/post_receive.rb +++ b/app/workers/post_receive.rb @@ -3,20 +3,16 @@ class PostReceive include DedicatedSidekiqQueue def perform(repo_path, identifier, changes) - if repository_storage = Gitlab.config.repositories.storages.find { |p| repo_path.start_with?(p[1]['path'].to_s) } - repo_path.gsub!(repository_storage[1]['path'].to_s, "") - else - log("Check gitlab.yml config for correct repositories.storages values. No repository storage path matches \"#{repo_path}\"") - end + repo_relative_path = Gitlab::RepoPath.strip_storage_path(repo_path) changes = Base64.decode64(changes) unless changes.include?(' ') # Use Sidekiq.logger so arguments can be correlated with execution # time and thread ID's. Sidekiq.logger.info "changes: #{changes.inspect}" if ENV['SIDEKIQ_LOG_ARGUMENTS'] - post_received = Gitlab::GitPostReceive.new(repo_path, identifier, changes) + post_received = Gitlab::GitPostReceive.new(repo_relative_path, identifier, changes) if post_received.project.nil? - log("Triggered hook for non-existing project with full path \"#{repo_path}\"") + log("Triggered hook for non-existing project with full path \"#{repo_relative_path}\"") return false end @@ -25,7 +21,7 @@ class PostReceive elsif post_received.regular_project? process_project_changes(post_received) else - log("Triggered hook for unidentifiable repository type with full path \"#{repo_path}\"") + log("Triggered hook for unidentifiable repository type with full path \"#{repo_relative_path}\"") false end end -- cgit v1.2.1