diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-01-27 18:08:51 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-01-27 18:08:51 +0300 |
commit | 1ea1db491c8bc90789acda45c9002aaa5c4dc498 (patch) | |
tree | 46d974fed38f2ea63e69bad9d43760c62611c958 /lib/gitlab/repo_path.rb | |
parent | 22e9af3c8b8aedf7f46b786be968862b74a2d07e (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'lib/gitlab/repo_path.rb')
-rw-r--r-- | lib/gitlab/repo_path.rb | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/lib/gitlab/repo_path.rb b/lib/gitlab/repo_path.rb index 1baa2a9e461..e8c749cac14 100644 --- a/lib/gitlab/repo_path.rb +++ b/lib/gitlab/repo_path.rb @@ -4,8 +4,9 @@ module Gitlab module RepoPath NotFoundError = Class.new(StandardError) - def self.parse(repo_path) - project_path = repo_path.sub(/\.git\z/, '').sub(%r{\A/}, '') + def self.parse(path) + repo_path = path.sub(/\.git\z/, '').sub(%r{\A/}, '') + redirected_path = nil # Detect the repo type based on the path, the first one tried is the project # type, which does not have a suffix. @@ -14,10 +15,13 @@ module Gitlab # type. # We'll always try to find a project with an empty suffix (for the # `Gitlab::GlRepository::PROJECT` type. - next unless project_path.end_with?(type.path_suffix) + next unless type.valid?(repo_path) - project, was_redirected = find_project(project_path.chomp(type.path_suffix)) - redirected_path = project_path if was_redirected + # Removing the suffix (.wiki, .design, ...) from the project path + full_path = repo_path.chomp(type.path_suffix) + + project, was_redirected = find_project(full_path) + redirected_path = repo_path if was_redirected # If we found a matching project, then the type was matched, no need to # continue looking. |