Commit c0a78957 authored by Tiago Botelho's avatar Tiago Botelho

Adds skip_branch method to remote mirror update service

parent cf6fbda0
......@@ -102,7 +102,7 @@ module Projects
end
def skip_branch?(name)
project.only_mirror_protected_branches && !ProtectedBranch.protected?(project,name)
project.only_mirror_protected_branches && !ProtectedBranch.protected?(project, name)
end
end
end
......@@ -31,9 +31,7 @@ module Projects
def local_branches
@local_branches ||= repository.local_branches.each_with_object({}) do |branch, branches|
next if mirror.only_protected_branches? && !protected_branch?(branch.name)
branches[branch.name] = branch
branches[branch.name] = branch unless skip_branch?(branch.name)
end
end
......@@ -115,7 +113,7 @@ module Projects
remote_refs.each_with_object([]) do |(name, remote_ref), refs_to_delete|
next if local_refs[name] # skip if branch or tag exist in local repo
next if type == :branches && mirror.only_protected_branches? && !protected_branch?(name)
next if type == :branches && skip_branch?(name)
remote_ref_id = remote_ref.dereferenced_target.try(:id)
......@@ -125,8 +123,8 @@ module Projects
end
end
def protected_branch?(name)
ProtectedBranch.protected?(project, name)
def skip_branch?(name)
mirror.only_protected_branches? && !ProtectedBranch.protected?(project, name)
end
end
end
......@@ -63,14 +63,9 @@ describe Gitlab::BackgroundMigration::PopulateForkNetworksRange, :migration, sch
expect(base2_membership).not_to be_nil
end
<<<<<<< HEAD
it 'creates a fork network for the fork of which the source was deleted' do
fork = create(:project)
fork = projects.create
forked_project_links.create(id: 6, forked_from_project_id: 99999, forked_to_project_id: fork.id)
=======
it 'skips links that had their source project deleted' do
forked_project_links.create(id: 6, forked_from_project_id: 99999, forked_to_project_id: projects.create.id)
>>>>>>> Create models directly in migration specs
migration.perform(5, 8)
......
......@@ -74,7 +74,7 @@ describe Projects::UpdateMirrorService do
expect(project.repository.branch_names).to include(new_protected_branch_name)
end
it 'does not create a unprotected branch' do
it 'does not create an unprotected branch' do
stub_fetch_mirror(project)
described_class.new(project, project.owner).execute
......
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