diff options
Diffstat (limited to 'app/models/ci/bridge.rb')
-rw-r--r-- | app/models/ci/bridge.rb | 19 |
1 files changed, 17 insertions, 2 deletions
diff --git a/app/models/ci/bridge.rb b/app/models/ci/bridge.rb index d6051d70503..662fb3cffa8 100644 --- a/app/models/ci/bridge.rb +++ b/app/models/ci/bridge.rb @@ -18,8 +18,11 @@ module Ci belongs_to :project belongs_to :trigger_request + + # To be removed upon :ci_bridge_remove_sourced_pipelines feature flag removal has_many :sourced_pipelines, class_name: "::Ci::Sources::Pipeline", - foreign_key: :source_job_id + foreign_key: :source_job_id, + inverse_of: :source_bridge has_one :downstream_pipeline, through: :sourced_pipeline, source: :pipeline @@ -86,8 +89,20 @@ module Ci end end + def sourced_pipelines + if Feature.enabled?(:ci_bridge_remove_sourced_pipelines, project) + raise 'Ci::Bridge does not have sourced_pipelines association' + end + + super + end + def has_downstream_pipeline? - sourced_pipelines.exists? + if Feature.enabled?(:ci_bridge_remove_sourced_pipelines, project) + sourced_pipeline.present? + else + sourced_pipelines.exists? + end end def downstream_pipeline_params |