Skip to content

Update BranchRules::UpdateService to accept branch protection changes

Joe Woodward requested to merge feat/441471-edit-branch-rule into master

What does this MR do and why?

Update BranchRules::UpdateService to accept branch protection changes

This change allows the BranchRules::UpdateService to accept new params for the branch_protection configuration.

In CE this includes:

  branch_protection: [
    :allow_force_push,
    {
      push_access_levels: %i[access_level deploy_key_id],
      merge_access_levels: %i[access_level]
    }
  ]

In EE this includes:

  branch_protection: [
    :allow_force_push,
    :code_owner_approval_required,
    {
      push_access_levels: %i[access_level deploy_key_id user_id group_id],
      merge_access_levels: %i[access_level user_id group_id]
    }
  ]

NOTE: This behaves slightly differently to the REST API. In the REST API to delete an access level users must pass the id of the access level and _destroy: true. In the graph endpoint we treat the params as a definitive list of access levels so any existing access levels that are not present in the params will be destroyed.

Part of #441471 (closed)

MR acceptance checklist

Please evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.

Screenshots or screen recordings

Screenshots are required for UI changes, and strongly recommended for all other merge requests.

Before After

How to set up and validate locally

Numbered steps to set up and validate the change are strongly suggested.

Merge request reports