diff options
author | Michael Kozono <mkozono@gmail.com> | 2017-06-15 17:03:54 -0700 |
---|---|---|
committer | Michael Kozono <mkozono@gmail.com> | 2017-06-16 14:14:19 -0700 |
commit | af784cc6e22ca915f20111828ae3252619834419 (patch) | |
tree | c3afca6b57a9326f7a27adf20b65df713ffc13db /lib/gitlab/repo_path.rb | |
parent | 3a38e5f1ab914bc4eaeecda6e18caaa7ca9ea5a7 (diff) | |
download | gitlab-ce-af784cc6e22ca915f20111828ae3252619834419.tar.gz |
Add “Project moved” error to Git-over-SSH
Diffstat (limited to 'lib/gitlab/repo_path.rb')
-rw-r--r-- | lib/gitlab/repo_path.rb | 21 |
1 files changed, 15 insertions, 6 deletions
diff --git a/lib/gitlab/repo_path.rb b/lib/gitlab/repo_path.rb index 878e03f61d7..3591fa9145e 100644 --- a/lib/gitlab/repo_path.rb +++ b/lib/gitlab/repo_path.rb @@ -3,16 +3,18 @@ module Gitlab NotFoundError = Class.new(StandardError) def self.parse(repo_path) + wiki = false project_path = strip_storage_path(repo_path.sub(/\.git\z/, ''), fail_on_not_found: false) - project = Project.find_by_full_path(project_path) - if project_path.end_with?('.wiki') && !project - project = Project.find_by_full_path(project_path.chomp('.wiki')) + project, was_redirected = find_project(project_path) + + if project_path.end_with?('.wiki') && project.nil? + project, was_redirected = find_project(project_path.chomp('.wiki')) wiki = true - else - wiki = false end - [project, wiki] + redirected_path = project_path if was_redirected + + [project, wiki, redirected_path] end def self.strip_storage_path(repo_path, fail_on_not_found: true) @@ -30,5 +32,12 @@ module Gitlab result.sub(/\A\/*/, '') end + + def self.find_project(project_path) + project = Project.find_by_full_path(project_path, follow_redirects: true) + was_redirected = project && project.full_path.casecmp(project_path) != 0 + + [project, was_redirected] + end end end |