gitlab-org--gitlab-foss/lib/gitlab/repo_path.rb
Zeger-Jan van de Weg cc7931cc9c
Remove Gitlab::RepoPath.strip_storage_path
This used to be executed because of the post receive worker, but this
uses Gitlab::GlRepository.parse now. So this removes dead code and
reduces the number of calls on `#legacy_storage_path`.
2018-05-11 13:57:43 +02:00

28 lines
773 B
Ruby

module Gitlab
module RepoPath
NotFoundError = Class.new(StandardError)
def self.parse(repo_path)
wiki = false
project_path = repo_path.sub(/\.git\z/, '').sub(%r{\A/}, '')
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
end
redirected_path = project_path if was_redirected
[project, wiki, redirected_path]
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