Merge branch 'fix/gb/container-registry-repository-paths' into 'master'
Fix duplicated container repository names Closes #31117 See merge request !10771
This commit is contained in:
commit
8d0cae3f0a
2 changed files with 33 additions and 9 deletions
|
@ -48,7 +48,7 @@ module ContainerRegistry
|
|||
end
|
||||
|
||||
def root_repository?
|
||||
@path == repository_project.full_path
|
||||
@path == project_path
|
||||
end
|
||||
|
||||
def repository_project
|
||||
|
@ -60,7 +60,13 @@ module ContainerRegistry
|
|||
def repository_name
|
||||
return unless has_project?
|
||||
|
||||
@path.remove(%r(^#{Regexp.escape(repository_project.full_path)}/?))
|
||||
@path.remove(%r(^#{Regexp.escape(project_path)}/?))
|
||||
end
|
||||
|
||||
def project_path
|
||||
return unless has_project?
|
||||
|
||||
repository_project.full_path.downcase
|
||||
end
|
||||
|
||||
def to_s
|
||||
|
|
|
@ -189,15 +189,10 @@ describe ContainerRegistry::Path do
|
|||
end
|
||||
|
||||
context 'when project exists' do
|
||||
let(:group) { create(:group, path: 'some_group') }
|
||||
|
||||
let(:project) do
|
||||
create(:empty_project, group: group, name: 'some_project')
|
||||
end
|
||||
let(:group) { create(:group, path: 'Some_Group') }
|
||||
|
||||
before do
|
||||
allow(path).to receive(:repository_project)
|
||||
.and_return(project)
|
||||
create(:empty_project, group: group, name: 'some_project')
|
||||
end
|
||||
|
||||
context 'when project path equal repository path' do
|
||||
|
@ -225,4 +220,27 @@ describe ContainerRegistry::Path do
|
|||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe '#project_path' do
|
||||
context 'when project does not exist' do
|
||||
let(:path) { 'some/name' }
|
||||
|
||||
it 'returns nil' do
|
||||
expect(subject.project_path).to be_nil
|
||||
end
|
||||
end
|
||||
|
||||
context 'when project with uppercase characters in path exists' do
|
||||
let(:path) { 'somegroup/myproject/my/image' }
|
||||
let(:group) { create(:group, path: 'SomeGroup') }
|
||||
|
||||
before do
|
||||
create(:empty_project, group: group, name: 'MyProject')
|
||||
end
|
||||
|
||||
it 'returns downcased project path' do
|
||||
expect(subject.project_path).to eq 'somegroup/myproject'
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue