Merge branch 'bvl-fix-unlinking-with-lfs-objects' into 'master'
Don't link LFS-objects multiple times. Closes #41241 See merge request gitlab-org/gitlab-ce!16006
This commit is contained in:
commit
6e42fac3fb
3 changed files with 27 additions and 1 deletions
|
@ -5,7 +5,7 @@ module Projects
|
|||
|
||||
if fork_source = @project.fork_source
|
||||
fork_source.lfs_objects.find_each do |lfs_object|
|
||||
lfs_object.projects << @project
|
||||
lfs_object.projects << @project unless lfs_object.projects.include?(@project)
|
||||
end
|
||||
|
||||
refresh_forks_count(fork_source)
|
||||
|
|
|
@ -0,0 +1,6 @@
|
|||
---
|
||||
title: Don't link LFS objects to a project when unlinking forks when they were already
|
||||
linked
|
||||
merge_request: 16006
|
||||
author:
|
||||
type: fixed
|
|
@ -62,6 +62,26 @@ describe Projects::UnlinkForkService do
|
|||
expect(source.forks_count).to be_zero
|
||||
end
|
||||
|
||||
context 'when the source has LFS objects' do
|
||||
let(:lfs_object) { create(:lfs_object) }
|
||||
|
||||
before do
|
||||
lfs_object.projects << project
|
||||
end
|
||||
|
||||
it 'links the fork to the lfs object before unlinking' do
|
||||
subject.execute
|
||||
|
||||
expect(lfs_object.projects).to include(forked_project)
|
||||
end
|
||||
|
||||
it 'does not fail if the lfs objects were already linked' do
|
||||
lfs_object.projects << forked_project
|
||||
|
||||
expect { subject.execute }.not_to raise_error
|
||||
end
|
||||
end
|
||||
|
||||
context 'when the original project was deleted' do
|
||||
it 'does not fail when the original project is deleted' do
|
||||
source = forked_project.forked_from_project
|
||||
|
|
Loading…
Reference in a new issue