summaryrefslogtreecommitdiff
path: root/app/models/concerns/ci/pipeline_delegator.rb
diff options
context:
space:
mode:
authorShinya Maeda <shinya@gitlab.com>2019-04-25 15:23:39 +0700
committerShinya Maeda <shinya@gitlab.com>2019-04-29 18:52:51 +0700
commited3a2fc8d7fef157706859dd009e1662fdc3d4b5 (patch)
tree6468ddc17f339ce41b7c00648020b75a615f9bef /app/models/concerns/ci/pipeline_delegator.rb
parentddee4426c4bd3df8bde7936a6ffb0a1973a4d5a1 (diff)
downloadgitlab-ce-ed3a2fc8d7fef157706859dd009e1662fdc3d4b5.tar.gz
Fix CI_COMMIT_REF_NAME and SLUG variable
With Pipelines for Merge Requests feature, users cannout keep using $CI_COMMIT_REF_NAME and _SLUG predefined variables for dynamic environments. We fix this problem by explicitly looking at the source ref.
Diffstat (limited to 'app/models/concerns/ci/pipeline_delegator.rb')
-rw-r--r--app/models/concerns/ci/pipeline_delegator.rb21
1 files changed, 21 insertions, 0 deletions
diff --git a/app/models/concerns/ci/pipeline_delegator.rb b/app/models/concerns/ci/pipeline_delegator.rb
new file mode 100644
index 00000000000..dbc5ed1bc9a
--- /dev/null
+++ b/app/models/concerns/ci/pipeline_delegator.rb
@@ -0,0 +1,21 @@
+# frozen_string_literal: true
+
+##
+# This module is mainly used by child associations of `Ci::Pipeline` that needs to look up
+# single source of truth. For example, `Ci::Build` has `git_ref` method, which behaves
+# slightly different from `Ci::Pipeline`'s `git_ref`. This is very confusing as
+# the system could behave differently time to time.
+# We should have a single interface in `Ci::Pipeline` and access the method always.
+module Ci
+ module PipelineDelegator
+ extend ActiveSupport::Concern
+
+ included do
+ delegate :merge_request_event?,
+ :merge_request_ref?,
+ :source_ref,
+ :source_ref_slug,
+ :legacy_detached_merge_request_pipeline?, to: :pipeline
+ end
+ end
+end