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
-
Changelog entry for user-facing changes, or community contribution. Check the link for other scenarios. - [-] Documentation created/updated or follow-up review issue created
-
Code review guidelines - [-] Merge request performance guidelines
-
Style guides - [-] Database guides
- [-] Separation of EE specific content
Performance and Testing
Edited by drew stachon