From 3095ac0ca45b044f2055cbd44654c83891245928 Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets Date: Thu, 27 Oct 2016 12:51:57 +0300 Subject: Make internal api work with full repo path instead of name Signed-off-by: Dmitriy Zaporozhets --- lib/api/internal.rb | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) (limited to 'lib/api/internal.rb') diff --git a/lib/api/internal.rb b/lib/api/internal.rb index 9a5d1ece070..8b5d2259b45 100644 --- a/lib/api/internal.rb +++ b/lib/api/internal.rb @@ -17,15 +17,25 @@ module API # helpers do + def project_path + @project_path ||= begin + project_path = params[:project].sub(/\.git\z/, '') + + Gitlab.config.repositories.storages.each do |_, storage_path| + project_path.sub!(storage_path, '') + end + + project_path + end + end + def wiki? - @wiki ||= params[:project].end_with?('.wiki') && - !Project.find_with_namespace(params[:project]) + @wiki ||= project_path.end_with?('.wiki') && + !Project.find_with_namespace(project_path) end def project @project ||= begin - project_path = params[:project] - # Check for *.wiki repositories. # Strip out the .wiki from the pathname before finding the # project. This applies the correct project permissions to -- cgit v1.2.1 From 440604ad1ba67dcbdd23633765b9140fae4bd4b9 Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets Date: Fri, 28 Oct 2016 15:55:55 +0300 Subject: Refactor storage path extraction from full repo path Signed-off-by: Dmitriy Zaporozhets --- lib/api/internal.rb | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) (limited to 'lib/api/internal.rb') diff --git a/lib/api/internal.rb b/lib/api/internal.rb index 8b5d2259b45..ccf181402f9 100644 --- a/lib/api/internal.rb +++ b/lib/api/internal.rb @@ -20,12 +20,7 @@ module API def project_path @project_path ||= begin project_path = params[:project].sub(/\.git\z/, '') - - Gitlab.config.repositories.storages.each do |_, storage_path| - project_path.sub!(storage_path, '') - end - - project_path + Repository.remove_storage_from_path(project_path) end end -- cgit v1.2.1