BigW Consortium Gitlab

Remove unnecessary fork ci logic

parent 5de0b078
......@@ -72,21 +72,6 @@ class GitlabCiService < CiService
:error
end
def fork_registration(new_project, current_user)
params = OpenStruct.new({
id: new_project.id,
default_branch: new_project.default_branch
})
ci_project = Ci::Project.find_by!(gitlab_id: project.id)
Ci::CreateProjectService.new.execute(
current_user,
params,
ci_project
)
end
def commit_coverage(sha, ref)
get_ci_commit(sha, ref).coverage
rescue ActiveRecord::RecordNotFound
......
module Ci
class CreateProjectService
include Gitlab::Application.routes.url_helpers
def execute(current_user, params, forked_project = nil)
@project = Ci::Project.parse(params)
Ci::Project.transaction do
@project.save!
gl_project = ::Project.find(@project.gitlab_id)
gl_project.build_missing_services
gl_project.gitlab_ci_service.update_attributes(active: true)
end
if forked_project
# Copy settings
settings = forked_project.attributes.select do |attr_name, value|
["public", "shared_runners_enabled", "allow_git_fetch"].include? attr_name
end
@project.update(settings)
end
Ci::EventService.new.create_project(current_user, @project)
@project
end
end
end
......@@ -18,7 +18,13 @@ module Projects
if new_project.persisted?
if @project.gitlab_ci?
@project.gitlab_ci_service.fork_registration(new_project, @current_user)
new_project.enable_ci
settings = @project.gitlab_ci_project.attributes.select do |attr_name, value|
["public", "shared_runners_enabled", "allow_git_fetch"].include? attr_name
end
new_project.gitlab_ci_project.update(settings)
end
end
......
require 'spec_helper'
describe Ci::CreateProjectService do
let(:service) { Ci::CreateProjectService.new }
let(:current_user) { double.as_null_object }
let(:project) { FactoryGirl.create :project }
describe :execute do
context 'valid params' do
subject { service.execute(current_user, project) }
it { is_expected.to be_kind_of(Ci::Project) }
it { is_expected.to be_persisted }
end
context 'without project dump' do
it 'should raise exception' do
expect { service.execute(current_user, '', '') }.
to raise_error(NoMethodError)
end
end
context "forking" do
let(:ci_origin_project) do
FactoryGirl.create(:ci_project, shared_runners_enabled: true, public: true, allow_git_fetch: true)
end
subject { service.execute(current_user, project, ci_origin_project) }
it "uses project as a template for settings and jobs" do
expect(subject.shared_runners_enabled).to be_truthy
expect(subject.public).to be_truthy
expect(subject.allow_git_fetch).to be_truthy
end
end
end
end
......@@ -48,7 +48,7 @@ describe Projects::ForkService do
@from_project.build_missing_services
@from_project.gitlab_ci_service.update_attributes(active: true)
expect_any_instance_of(Ci::CreateProjectService).to receive(:execute)
expect_any_instance_of(Project).to receive(:enable_ci)
fork_project(@from_project, @to_user)
end
......
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