diff --git a/app/workers/repository_fork_worker.rb b/app/workers/repository_fork_worker.rb index d1c57b82681..07584fab7c8 100644 --- a/app/workers/repository_fork_worker.rb +++ b/app/workers/repository_fork_worker.rb @@ -17,10 +17,7 @@ class RepositoryForkWorker project.repository_storage_path, project.disk_path) raise "Unable to fork project #{project_id} for repository #{source_disk_path} -> #{project.disk_path}" unless result - project.repository.after_import - raise "Project #{project_id} had an invalid repository after fork" unless project.valid_repo? - - project.import_finish + project.after_import end private diff --git a/changelogs/unreleased/19493-fork-does-not-protect-default-branch.yml b/changelogs/unreleased/19493-fork-does-not-protect-default-branch.yml new file mode 100644 index 00000000000..962f918e9db --- /dev/null +++ b/changelogs/unreleased/19493-fork-does-not-protect-default-branch.yml @@ -0,0 +1,5 @@ +--- +title: Makes forking protect default branch on completion +merge_request: +author: +type: fixed diff --git a/spec/workers/repository_fork_worker_spec.rb b/spec/workers/repository_fork_worker_spec.rb index 31598586f59..4912baa348c 100644 --- a/spec/workers/repository_fork_worker_spec.rb +++ b/spec/workers/repository_fork_worker_spec.rb @@ -47,6 +47,14 @@ describe RepositoryForkWorker do perform! end + it 'protects the default branch' do + expect_fork_repository.and_return(true) + + perform! + + expect(fork_project.protected_branches.first.name).to eq(fork_project.default_branch) + end + it 'flushes various caches' do expect_fork_repository.and_return(true)