Select upstream project by default when creating MR from fork
What does this MR do and why?
This improves consistency in what target project is selected by default on the "Create new merge request" pages that are accessible from a few places:
- "Recent push" widget (project homepage, branch page)
- Branches page (e.g. https://gitlab.com/gitlab-org/gitlab/-/branches)
- Branch's commits page (e.g. https://gitlab.com/gitlab-org/gitlab/-/commits/fix-clause-changes/)
This also fixes the default target project on the compare page (e.g. https://gitlab.com/gitlab-org/gitlab/-/compare/master...fix-clause-changes), in a specific commit since it involves frontend changes.
The case this MR fixes is the case where the default "target project" of a project is set to its upstream project (default in the case of a fork).
This can be seen in a project's general settings (e.g. https://gitlab.com/gitlab-org/gitlab/edit), under the "Merge request" section:
It should resolve #327470 (closed).
Screenshots or screen recordings
New merge request form
New MR page from | master |
This branch |
---|---|---|
"Recent push" widget | Already good | ![]() |
Branches page | ![]() |
![]() |
Branch's commits page | ![]() |
![]() |
From compare page | ![]() |
![]() |
Compare page
master |
This branch |
---|---|
![]() |
![]() |
I also recorded before/after videos to show the problem and fix in action.
Compare to upstream
master |
This branch |
---|---|
compare-to-upstream-master | compare-to-upstream-fixed |
Open MR from compare page with a different target project
master |
This branch |
---|---|
open-mr-from-compare-page-master | open-mr-from-compare-page-fixed |
How to set up and validate locally
Prerequisites
- Fork a project
- Ensure the target project is the upstream project (i.e. the one from which you forked)
- Make a random change in a new branch in your fork
"Recent push" widget (project homepage)
- Click the "Create merge request" from the "You recently pushed" widget
- The MR form page should target the upstream project's default branch
"Recent push" widget (branch page)
- Visit the Branches page in your fork
- Click on the name of the branch created in the prerequisites steps
- Click the "Create merge request" from the "You recently pushed" widget
- The MR form page should target the upstream project's default branch
https://gitlab.com/gitlab-org/gitlab/-/branches)
Branches page (e.g.- Visit the Branches page in your fork
- Click the "Merge request" button on the branch created in the prerequisites steps
- The MR form page should target the upstream project's default branch
https://gitlab.com/gitlab-org/gitlab/-/commits/fix-clause-changes/)
Branch's commits page (e.g.- Visit the Branches page in your fork
- Click on the name of the branch created in the prerequisites steps
- Click on the "History" button
- Click the "Merge request" button at the top of the page
- The MR form page should target the upstream project's default branch
Compare page
- Visit the "Compare" page
- The selected project in the "Target" part should be the upstream project
- Select another upstream project from the "Target" dropdown
- The selected project in the "Target" part should be the project you just selected
- Click the "Create merge request" button
- The MR form page should target the selected project's default branch
MR acceptance checklist
This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.
-
I have evaluated the MR acceptance checklist for this MR.