diff options
author | Shinya Maeda <shinya@gitlab.com> | 2019-03-21 16:08:32 +0300 |
---|---|---|
committer | Shinya Maeda <shinya@gitlab.com> | 2019-03-29 09:58:45 +0300 |
commit | bf639fd504c84929ff8542eef81578a6745bf428 (patch) | |
tree | b7eb20a2ef25de759ed3d8a2ef9a063c77564c03 /app/models | |
parent | 3a477fec8f1fe6cf1da70a8ae0a8473ab26235bc (diff) |
Create detached merge request pipelines
By using `refs/merge-requests/:iid/head`
ok
ok
Improve naming nicely
Add nice tests
add nice tests
fix some more
revert
Diffstat (limited to 'app/models')
-rw-r--r-- | app/models/ci/build.rb | 6 | ||||
-rw-r--r-- | app/models/ci/pipeline.rb | 8 | ||||
-rw-r--r-- | app/models/merge_request.rb | 4 |
3 files changed, 16 insertions, 2 deletions
diff --git a/app/models/ci/build.rb b/app/models/ci/build.rb index 59f47effff7..1bd517641ac 100644 --- a/app/models/ci/build.rb +++ b/app/models/ci/build.rb @@ -26,7 +26,8 @@ module Ci belongs_to :erased_by, class_name: 'User' RUNNER_FEATURES = { - upload_multiple_artifacts: -> (build) { build.publishes_artifacts_reports? } + upload_multiple_artifacts: -> (build) { build.publishes_artifacts_reports? }, + refspecs: -> (build) { build.merge_request_ref? } }.freeze has_one :deployment, as: :deployable, class_name: 'Deployment' @@ -47,7 +48,8 @@ module Ci delegate :terminal_specification, to: :runner_session, allow_nil: true delegate :gitlab_deploy_token, to: :project delegate :trigger_short_token, to: :trigger_request, allow_nil: true - delegate :merge_request_event?, to: :pipeline + delegate :merge_request_event?, :merge_request_ref?, + :legacy_detached_merge_request_pipeline?, to: :pipeline ## # Since Gitlab 11.5, deployments records started being created right after diff --git a/app/models/ci/pipeline.rb b/app/models/ci/pipeline.rb index 826b3f82bbf..e6da0a58dce 100644 --- a/app/models/ci/pipeline.rb +++ b/app/models/ci/pipeline.rb @@ -738,6 +738,10 @@ module Ci triggered_by_merge_request? && target_sha.nil? end + def legacy_detached_merge_request_pipeline? + detached_merge_request_pipeline? && !merge_request_ref? + end + def merge_request_pipeline? triggered_by_merge_request? && target_sha.present? end @@ -746,6 +750,10 @@ module Ci triggered_by_merge_request? && target_sha == merge_request.target_branch_sha end + def merge_request_ref? + MergeRequest.merge_request_ref?(ref) + end + def matches_sha_or_source_sha?(sha) self.sha == sha || self.source_sha == sha end diff --git a/app/models/merge_request.rb b/app/models/merge_request.rb index 19557fd476e..7135cf58e33 100644 --- a/app/models/merge_request.rb +++ b/app/models/merge_request.rb @@ -1129,6 +1129,10 @@ class MergeRequest < ActiveRecord::Base "refs/#{Repository::REF_MERGE_REQUEST}/#{iid}/merge" end + def self.merge_request_ref?(ref) + ref.start_with?("refs/#{Repository::REF_MERGE_REQUEST}/") + end + def in_locked_state begin lock_mr |