diff --git a/doc/api/protected_branches.md b/doc/api/protected_branches.md index 0b308a6c68e98064cf91552279e5e61f04ed99b8..fc66a75860ab5d6e89a7f8d31ad76abfc555d9b6 100644 --- a/doc/api/protected_branches.md +++ b/doc/api/protected_branches.md @@ -318,6 +318,18 @@ Supported attributes: | `push_access_level` | integer | No | Access levels allowed to push. Default is `40` (Maintainer role). | | `unprotect_access_level` | integer | No | Access levels allowed to unprotect. Default is `40` (Maintainer role). | +When you configure access levels: + +- You can set multiple access levels simultaneously for `allowed_to_push` and `allowed_to_merge`. +- The highest access level determines who can perform the action. +- If you set access level `0` (no one) and other access levels for the same branch, the most permissive access level applies. + +This behavior differs from the UI, which automatically clears other role selections +when you select **No one**. + +For example, if you set both `access_level: 0` (No access) and `access_level: 40` (Maintainer role) +for `allowed_to_push`, users with at least the Maintainer role can push to the branch. + If successful, returns [`201 Created`](rest/troubleshooting.md#status-codes) and the following response attributes: @@ -759,6 +771,9 @@ Supported attributes: | `allowed_to_unprotect` | array | No | Array of unprotect access levels, with each described by a hash of the form `{user_id: integer}`, `{group_id: integer}`, `{access_level: integer}`, or `{id: integer, _destroy: true}` to destroy an existing access level. Access level `No access` is not available for this field. Premium and Ultimate only. | | `code_owner_approval_required` | boolean | No | If `true`, prevents pushes to this branch if it matches an item in the [`CODEOWNERS` file](../user/project/codeowners/_index.md). Premium and Ultimate only. | +For information about how access levels interact when you set multiple values, +see [Protect repository branches](#protect-repository-branches). + If successful, returns [`200 OK`](rest/troubleshooting.md#status-codes) and the following response attributes: diff --git a/doc/user/project/repository/branches/protected.md b/doc/user/project/repository/branches/protected.md index f6bf4fab2908ee581cf17527a1e0942166b88677..644d6f4a5c57ce4a8f83cf7b9d56264e12a59018 100644 --- a/doc/user/project/repository/branches/protected.md +++ b/doc/user/project/repository/branches/protected.md @@ -131,6 +131,12 @@ Users with this permission can merge through merge requests even without {{< /alert >}} +When you select **No one** for either **Allowed to merge** or **Allowed to push and merge**, the UI +clears other role selections. +This behavior differs from the API, where you can set multiple access levels simultaneously. +For more information about API behavior, see the +[Protected branches API](../../../../api/protected_branches.md). + ### Protection strategies by branch types Different branch types require different protection levels based on their purpose and