Auto-squash commits when merging merge request
Resources
PM @victorwu | BE @smcgivern | UX @pedroms | FE @mikegreiling
Problem
Similar to #895 and explained in #411 (closed), we would like to reduce the friction in getting code merged into a master / main development branch for typical development scenarios.
Solution
- For all merge request methods (
merge commit
,merge commit with semi-linear history
,fast-forward merge
), allow the user to squash all the commits and merge in one action. - Squash is a checkbox, like the remove source branch checkbox, that is available on MR creation/edition, or when the accept button is visible, and it can be changed by anyone who can accept the MR or the MR author.
- This checkbox is always shown on create and edit.
- This checkbox is only shown when accepting if there is more than one commit in the MR - otherwise, there's nothing to squash.
- We will never update the source branch with the squash result, just the target branch.
- For the different merge methods:
- Merge commit - we squash the commits in the MR based on the base SHA (the common ancestor between source and target), then merge that commit into the target branch as normal.
- Merge commit with semi-linear history - we do the same, but the rebase start point is the start SHA (the current target branch HEAD).
- Fast-forward merge - we also rebase to the start SHA, but then we just fast-forward that commit onto the target branch.
- We should always squash before rebasing, because then we know that the resultant squashed commit can be either merged or rebased cleanly based on our existing checks.
- This applies to automatic merges as well. When a user sets a merge to be automatically attempted after the pipeline succeeds, it is as if they execute this one action of rebase+merge.
Designs
New/edit MR | View MR (desktop) | View MR (tablet) | View MR (mobile) |
---|---|---|---|
In the New/edit MR screen, the “Learn more” links to the documentation.
In the View MR screen, the “Learn more” tooltip and link to the documentation. It's default color is $gl-gray-light
and on hover changes to the link hover color. The "Learn more" should be "About this feature", as per https://gitlab.com/gitlab-org/gitlab-ee/merge_requests/1024#note_21099369
Original issue
https://gitlab.com/gitlab-org/gitlab-ce/issues/4106
Provide a "Squash into one commit upon merge" checkbox.
See @dzaporozhets comment for details: https://gitlab.com/gitlab-org/gitlab-ce/issues/4106#note_3036031
cc @sytses
Working issue: #896 (closed)