Commit 27d0c429 authored by Douwe Maan's avatar Douwe Maan

Merge branch 'zj-remove-repo-path-strip-storage-path' into 'master'

Remove Gitlab::RepoPath.strip_storage_path

See merge request gitlab-org/gitlab-ce!18904
parents 8c2b73dc cc7931cc
...@@ -4,7 +4,8 @@ module Gitlab ...@@ -4,7 +4,8 @@ module Gitlab
def self.parse(repo_path) def self.parse(repo_path)
wiki = false wiki = false
project_path = strip_storage_path(repo_path.sub(/\.git\z/, ''), fail_on_not_found: false) project_path = repo_path.sub(/\.git\z/, '').sub(%r{\A/}, '')
project, was_redirected = find_project(project_path) project, was_redirected = find_project(project_path)
if project_path.end_with?('.wiki') && project.nil? if project_path.end_with?('.wiki') && project.nil?
...@@ -17,22 +18,6 @@ module Gitlab ...@@ -17,22 +18,6 @@ module Gitlab
[project, wiki, redirected_path] [project, wiki, redirected_path]
end end
def self.strip_storage_path(repo_path, fail_on_not_found: true)
result = repo_path
storage = Gitlab.config.repositories.storages.values.find do |params|
repo_path.start_with?(params.legacy_disk_path)
end
if storage
result = result.sub(storage.legacy_disk_path, '')
elsif fail_on_not_found
raise NotFoundError.new("No known storage path matches #{repo_path.inspect}")
end
result.sub(%r{\A/*}, '')
end
def self.find_project(project_path) def self.find_project(project_path)
project = Project.find_by_full_path(project_path, follow_redirects: true) project = Project.find_by_full_path(project_path, follow_redirects: true)
was_redirected = project && project.full_path.casecmp(project_path) != 0 was_redirected = project && project.full_path.casecmp(project_path) != 0
......
...@@ -45,25 +45,6 @@ describe ::Gitlab::RepoPath do ...@@ -45,25 +45,6 @@ describe ::Gitlab::RepoPath do
end end
end end
describe '.strip_storage_path' do
before do
allow(Gitlab.config.repositories).to receive(:storages).and_return({
'storage1' => Gitlab::GitalyClient::StorageSettings.new('path' => '/foo'),
'storage2' => Gitlab::GitalyClient::StorageSettings.new('path' => '/bar')
})
end
it 'strips the storage path' do
expect(described_class.strip_storage_path('/bar/foo/qux/baz.git')).to eq('foo/qux/baz.git')
end
it 'raises NotFoundError if no storage matches the path' do
expect { described_class.strip_storage_path('/doesnotexist/foo.git') }.to raise_error(
described_class::NotFoundError
)
end
end
describe '.find_project' do describe '.find_project' do
let(:project) { create(:project) } let(:project) { create(:project) }
let(:redirect) { project.route.create_redirect('foo/bar/baz') } let(:redirect) { project.route.create_redirect('foo/bar/baz') }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment