Auto-squash commits when merging merge request
- For all merge request methods (
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.
|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
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
Working issue: #896 (closed)