Auto-squash commits when merging merge request
### Resources PM @victorwu | BE @smcgivern | UX @pedroms | FE @mikegreiling --- ### Problem Similar to #895 and explained in #411, 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) | |---|---|---|---| |![new-edit](/uploads/c631daef4d8fe9927648b78b32239522/new-edit.png)| ![image](/uploads/2acc0fd42d256bd797275b92a5aef678/image.png) | ![image](/uploads/263d6989face63870672eec1ce3d6b9d/image.png) | ![image](/uploads/576a0570b7a6ecd63c6d808f8ecfcd35/image.png) | In the **New/edit MR** screen, the “Learn more” links to the documentation. In the **View MR** screen, the :grey_question: question icon should have a ~~“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 >>>
issue