Commit 1165a725 authored by Lin Jen-Shin's avatar Lin Jen-Shin

Resolve conflicts in CreatePipelineService and alike

parent c285f350
...@@ -17,47 +17,31 @@ module Ci ...@@ -17,47 +17,31 @@ module Ci
result = validate(current_user || trigger_request.trigger.owner, result = validate(current_user || trigger_request.trigger.owner,
ignore_skip_ci: ignore_skip_ci, ignore_skip_ci: ignore_skip_ci,
save_on_errors: save_on_errors) save_on_errors: save_on_errors,
mirror_update: mirror_update)
return result if result return result if result
Ci::Pipeline.transaction do _create_pipeline(source, &block)
update_merge_requests_head_pipeline if pipeline.save
Ci::CreatePipelineStagesService
.new(project, current_user)
.execute(pipeline)
end
cancel_pending_pipelines if project.auto_cancel_pending_pipelines?
pipeline_created_counter.increment(source: source)
pipeline.tap(&:process!)
end end
private private
def validate(triggering_user, ignore_skip_ci:, save_on_errors:) def validate(triggering_user, ignore_skip_ci:, save_on_errors:, mirror_update:)
unless project.builds_enabled? unless project.builds_enabled?
return error('Pipeline is disabled') return error('Pipeline is disabled')
end end
<<<<<<< HEAD
unless project.mirror_trigger_builds? unless project.mirror_trigger_builds?
return error('Pipeline is disabled for mirror updates') if mirror_update return error('Pipeline is disabled for mirror updates') if mirror_update
end end
unless trigger_request || can?(current_user, :create_pipeline, project)
return error('Insufficient permissions to create a new pipeline')
=======
unless allowed_to_trigger_pipeline?(triggering_user) unless allowed_to_trigger_pipeline?(triggering_user)
if can?(triggering_user, :create_pipeline, project) if can?(triggering_user, :create_pipeline, project)
return error("Insufficient permissions for protected ref '#{ref}'") return error("Insufficient permissions for protected ref '#{ref}'")
else else
return error('Insufficient permissions to create a new pipeline') return error('Insufficient permissions to create a new pipeline')
end end
>>>>>>> upstream/master
end end
unless branch? || tag? unless branch? || tag?
...@@ -85,12 +69,6 @@ module Ci ...@@ -85,12 +69,6 @@ module Ci
end end
end end
<<<<<<< HEAD
_create_pipeline(source, &block)
end
private
def _create_pipeline(source) def _create_pipeline(source)
Ci::Pipeline.transaction do Ci::Pipeline.transaction do
update_merge_requests_head_pipeline if pipeline.save update_merge_requests_head_pipeline if pipeline.save
...@@ -100,13 +78,20 @@ module Ci ...@@ -100,13 +78,20 @@ module Ci
Ci::CreatePipelineStagesService Ci::CreatePipelineStagesService
.new(project, current_user) .new(project, current_user)
.execute(pipeline) .execute(pipeline)
======= end
cancel_pending_pipelines if project.auto_cancel_pending_pipelines?
pipeline_created_counter.increment(source: source)
pipeline.tap(&:process!)
end
def allowed_to_trigger_pipeline?(triggering_user) def allowed_to_trigger_pipeline?(triggering_user)
if triggering_user if triggering_user
allowed_to_create?(triggering_user) allowed_to_create?(triggering_user)
else # legacy triggers don't have a corresponding user else # legacy triggers don't have a corresponding user
!project.protected_for?(ref) !project.protected_for?(ref)
>>>>>>> upstream/master
end end
end end
......
...@@ -108,16 +108,10 @@ describe PipelineSerializer do ...@@ -108,16 +108,10 @@ describe PipelineSerializer do
end end
end end
<<<<<<< HEAD
it 'verifies number of queries', :request_store do
recorded = ActiveRecord::QueryRecorder.new { subject }
expect(recorded.count).to be_within(1).of(61)
expect(recorded.cached_count).to eq(0)
=======
shared_examples 'no N+1 queries' do shared_examples 'no N+1 queries' do
it 'verifies number of queries', :request_store do it 'verifies number of queries', :request_store do
recorded = ActiveRecord::QueryRecorder.new { subject } recorded = ActiveRecord::QueryRecorder.new { subject }
expect(recorded.count).to be_within(1).of(59) expect(recorded.count).to be_within(1).of(61)
expect(recorded.cached_count).to eq(0) expect(recorded.cached_count).to eq(0)
end end
end end
...@@ -136,7 +130,6 @@ describe PipelineSerializer do ...@@ -136,7 +130,6 @@ describe PipelineSerializer do
end end
it_behaves_like 'no N+1 queries' it_behaves_like 'no N+1 queries'
>>>>>>> upstream/master
end end
def create_pipeline(status) def create_pipeline(status)
......
...@@ -9,7 +9,6 @@ module StubConfiguration ...@@ -9,7 +9,6 @@ module StubConfiguration
.to receive_messages(messages) .to receive_messages(messages)
end end
<<<<<<< HEAD
def stub_application_setting_on_object(object, messages) def stub_application_setting_on_object(object, messages)
add_predicates(messages) add_predicates(messages)
...@@ -18,11 +17,11 @@ module StubConfiguration ...@@ -18,11 +17,11 @@ module StubConfiguration
messages.each do |setting, value| messages.each do |setting, value|
allow(object).to receive_message_chain(:current_application_settings, setting) { value } allow(object).to receive_message_chain(:current_application_settings, setting) { value }
end end
======= end
def stub_not_protect_default_branch def stub_not_protect_default_branch
stub_application_setting( stub_application_setting(
default_branch_protection: Gitlab::Access::PROTECTION_NONE) default_branch_protection: Gitlab::Access::PROTECTION_NONE)
>>>>>>> upstream/master
end end
def stub_config_setting(messages) def stub_config_setting(messages)
......
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