Skip to content

Refactor Pipeline#merge_request_event_type for merge trains

What does this MR do?

This changes the order of the conditionals used in #merge_request_event_type to determine what kind of merge request is associated with the Pipeline. Because #merge_train_pipeline is a logical superset of #merge_request_pipeline?:

    def merge_request_pipeline?
      triggered_by_merge_request? && target_sha.present?
    end

    def merge_train_pipeline?
      merge_request_pipeline? && merge_train_ref?
    end

checking for #merge_request_pipeline? first makes :merge_train unreachable code.

I created a new merge request factory for a merge train pipeline and refactored the method specs to assert the correct behavior. If the order of checks in #merge_request_event_type is changed back, the :merge_train spec will fail.

Does this MR meet the acceptance criteria?

Conformity

Performance and Testing

Edited by drew stachon

Merge request reports