Fix the relationship between merge request and pipelines
What does this MR do?
This MR fixes the relationship between merge request and pipelines by explicitly defining association and scope names.
Today, there are many ambiguous relation names in Ci::Pipeline
and Ci::Build
. You would have no idea if you don't see the comments on each association.
Ci::Pipeline#merge_request ... Returns a merge request as the merge request pipeline
Ci::Pipeline#merge_requests ... Returns merge requests as the head pipeline
Ci::Pipeline#all_merge_requests ... Returns merge requests referred to the indeterministic pipeline
Ci::Pipeline.for_merge_request ... Returns pipelines for the merge request
Ci::Build#merge_request ... Returns a merge request referred to the indeterministic pipeline (Duplicated)
And, actually, some of them are misbehaving. For example, Ci::Pipeline#merge_request
and Ci::Build#merge_request
returns totally different thing.
This MR also lets the for_merge_request
scope to support merge request pipelines. Thus, https://gitlab.com/gitlab-org/gitlab-ee/merge_requests/9622 can simply focus on the pipeline creation without concerning these scopes and head pipeline update process.
What are the relevant issue numbers?
Related: https://gitlab.com/gitlab-org/gitlab-ee/issues/7380
Does this MR meet the acceptance criteria?
-
Changelog entry added, if necessary -
Documentation created/updated via this MR -
Documentation reviewed by technical writer or follow-up review issue created -
Tests added for this feature/bug -
Tested in all supported browsers -
Conforms to the code review guidelines -
Conforms to the merge request performance guidelines -
Conforms to the style guides -
Conforms to the database guides -
Link to e2e tests MR added if this MR has Requires e2e tests label. See the Test Planning Process. -
Security reports checked/validated by reviewer
Edited by Shinya Maeda