[go: up one dir, main page]

Skip to content

Merge Request Squash Settings per protected branch (non-wildcard only)

Release notes

Override a project's squash commits when merging setting for a protected branch.

Problem to solve

We would like to be able to set the squash behavior to Encourage for the develop branch while it should be Do not allow on the main branch.

  • I need to be able to "require squash" on protected branches
    • because otherwise high-volume branches become a horrible mess - when you have hundreds of devs active daily on a single project, a clean trunk/protected-branch history is critical and "oh, just teach them to rebase and squash themselves" is nonsense
    • note that this is also a motivation for related high-popularity issue #1822, which looked like it was finally getting some attention in 16.10, but then... didn't.
  • I need to be able to not require squash on non-protected branches (even though I do on protected branches)
    • because using MRs to "merge down" from protected to team feature branches can be helpful for teams (and squashing such "merge down" MRs completely breaks merge history / makes no sense), and also because doing regular merges from user/story branches to shared feature/wip branches can also be helpful for teams

This is no longer in scope, moved to Override squash settings with option to specify... (#504399):

  • I need to be able to merge between protected branches (even though I require squash from non-protected to protected branches) - which is a possibly-separate requirement captured in #24452
    • because squashing between protected branches almost never makes sense (and merges between protected branches are a common thing in eg gitflow). the only time we should require squashing, is when merging from a non-protected branch to a protected branch

Intended users

Project owners and maintainers

User experience goal

The user should be able to override the squash behavior on a protected branch.

Proposal

Branch specific squash rules should be added so that you can specify the rules for the branches the merge requests are merged into

  1. Introduce squash behaviour overrides
    • Add opens a drawer
      • Select target protected branch
      • Selection of squashing behaviour similar to existing default behaviour selection
        • Do not allow
        • Allow
        • Encourage
        • Require
Scenario Design
Default image
With protected branch override image
Add target branch - drawer image

Note this mockup is out of date. These will now be added to Branch Rules. The prevent squashing commits from protected branches checkbox is not within the scope of this issue and will be tracked through Prevent squashing commits from protected branches (#24452)

The scope is limited to non-wildcard protected branches only. We may iterate on this in the future to allow wildcard branch rules to specify these overrides, currently we have no mechanism to resolve conflicts so this is not possible. For now All branches and All protected branches branch rules are also not eligible.

Further details

Benefits: Enforcing this will reduce risk of people not following the team internal squash policy

Permissions and Security

Project maintainers and owners can view/create/edit branch rules.

Documentation

Availability & Testing

What does success look like, and how can we measure that?

What is the type of buyer?

Is this a cross-stage feature?

Links / references

SPIKE: explore options for setting squash rules... (#500458 - closed)

Edited by Joe Woodward