Skip to content

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:

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:

Screen_Shot_2022-07-06_at_19.24.57

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 new-mr-from-last-push-fixed
Branches page new-mr-from-branches-page-master new-mr-from-branches-page-fixed
Branch's commits page new-mr-from-branch-commits-page-master new-mr-from-branch-commits-page-fixed
From compare page new-mr-from-compare-page-master new-mr-from-compare-page-fixed

Compare page

master This branch
compare-page-master compare-page-fixed

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

  1. Fork a project
  2. Ensure the target project is the upstream project (i.e. the one from which you forked)
  3. Make a random change in a new branch in your fork

"Recent push" widget (project homepage)

  1. Click the "Create merge request" from the "You recently pushed" widget
  2. The MR form page should target the upstream project's default branch

"Recent push" widget (branch page)

  1. Visit the Branches page in your fork
  2. Click on the name of the branch created in the prerequisites steps
  3. Click the "Create merge request" from the "You recently pushed" widget
  4. The MR form page should target the upstream project's default branch

Branches page (e.g. https://gitlab.com/gitlab-org/gitlab/-/branches)

  1. Visit the Branches page in your fork
  2. Click the "Merge request" button on the branch created in the prerequisites steps
  3. The MR form page should target the upstream project's default branch

Branch's commits page (e.g. https://gitlab.com/gitlab-org/gitlab/-/commits/fix-clause-changes/)

  1. Visit the Branches page in your fork
  2. Click on the name of the branch created in the prerequisites steps
  3. Click on the "History" button
  4. Click the "Merge request" button at the top of the page
  5. The MR form page should target the upstream project's default branch

Compare page

  1. Visit the "Compare" page
  2. The selected project in the "Target" part should be the upstream project
  3. Select another upstream project from the "Target" dropdown
  4. The selected project in the "Target" part should be the project you just selected
  5. Click the "Create merge request" button
  6. 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.

Edited by Rémy Coutable

Merge request reports

Loading