Commit bc409759 authored by Achilleas Pipinellis's avatar Achilleas Pipinellis

Refactor approvals docs

parent 4d20bf40
......@@ -11,95 +11,174 @@ Merge request approvals enable enforced code review by requiring specified peopl
1. Enforcing review of all code that gets merged into a repository.
2. Specifying code maintainers for an entire repository.
3. Specifying reviewers for a given proposed code change.
4. Specifying categories of reviewers, such as BE, FE, QA, DB, etc. for all proposed code changes.
4. Specifying categories of reviewers, such as BE, FE, QA, DB, etc., for all proposed code changes.
## Approve and remove approval
## Activating approvals
If approvals are activated for the given project, when a user visits an open merge request, depending on their eligiblity, one of the following is possible:
To activate the merge request approvals:
- They are not an eligible approver. (See below for eligibility conditions.) They cannot do anything with repsect to approving this merge request.
- They have already approved this merge request. They can remove their approval.
- They have not approved this merge request.
- The required number of approvals has not been yet met. They can approve it by clicking the displayed `Approve` button.
- The required number of approvals has already been met. They can still approve it by clicking the displayed `Approve additionally` button.
1. Navigate to your project's **Settings > General** and expand the
**Merge requests settings**
1. Tick the "Merge requests approvals" checkbox
1. Search for users or groups that will be [eligible to approve](#eligible-approvers)
merge requests and click the **Add** button to add them as approvers
1. Set the minimum number of required approvals under the "Approvals required"
box
1. Click **Save changes**
![Remove approval](img/remove_approval.png)
![Approvals config project](img/approvals_config_project.png)
![Approve](img/approve.png)
The steps above are the minimum required to get approvals working in your
merge requests, but there are a couple more options available that might be
suitable to your workflow:
![Approve additionally](img/approve_additionally.png)
- Choose whether the default settings can be
[overridden per merge request](#overriding-the-merge-request-approvals-default-settings)
- Choose whether [approvals will be reset with new pushed commits](#resetting-approvals-on-push)
## Unblocked merge request
NOTE: **Note:**
If the approvers are changed via the project's settings after a merge request
is created, the merge request retains the previous approvers, but you can always
change them by [editing the merge request](#overriding-the-merge-request-approvals-default-settings).
Suppose approvals are activated for the given project. For the given merge request, if the required number of approvals has been met (i.e. the number of approvals given to the merge request is greater or equal than the required number), then the merge request is unblocked for merging. Meeting the required number of approvals is a necessary but not sufficient condition for unblocking a merge request from being merged. There are other conditions that may block it.
## Eligible approvers
## Project-level configuration
Eligible approvers can be individual users or groups that are project members,
members of the project's immediate parent group, and members of a group who
have access to the project via a
[share](../members/share_project_with_groups.md).
![Approvals config project](img/approvals_config_project.png)
If a user is added as an individual approver and is also part of a group approver,
then that user is just counted once. The merge request author does not count as
an eligible approver.
### Activate
Let's say that `m` is the number of required approvals, and `Ω` is the set of
explicit approvers. Depending on their number, there are different cases:
Actiate approvals by checking the checkbox.
- If `m <= Ω`, then only those explicit approvers can approve the merge request.
- If `m > Ω` , then all the explicit approvers _and_ the members of the given
project with Developer role or higher are eligible approvers of the merge
request.
### Required number of approvals
NOTE: **Note:**
If the approvals settings are [overridden](#overriding-the-merge-request-approvals-default-settings)
for the particular merge request, then the set of explicit approvers is the
union of the default approvers and the extra approvers set in the merge request.
Enter the required number of approvals to unblock the merge request from being merged. Call this number `m`.
## Adding or removing an approval
### Configure individual approvers
If approvals are activated for the given project, when a user visits an open
merge request, depending on their [eligibility](#eligible-approvers), one of
the following is possible:
Select individual users who are eligible approvers for merge requests in this project. You can only select project members, members of the project's immediate parent group, and members of a group who have access to the project via a [share](../../../workflow/share_projects_with_other_groups.md).
- **They are not an eligible approver**: They cannot do anything with respect
to approving this merge request.
- **They have not approved this merge request**:
- If the required number of approvals has _not_ been yet met, they can approve
it by clicking the displayed **Approve** button.
![Approve](img/approve.png)
### Configure group approvers
- If the required number of approvals has already been met, they can still
approve it by clicking the displayed **Approve additionally** button.
![Approve additionally](img/approve_additionally.png)
Select groups who are eligible approvers. Members of these groups will be eligible approvers for merge requests in this project.
---
### Eligible approvers
- **They have already approved this merge request**: They can remove their approval.
For a given merge request in the given project, suppose there are no additional approvals configuration in the merge request itself (below). Then for that merge request, the set of explicit approvers is the `union` of the following two
![Remove approval](img/remove_approval.png)
- The individual approvers
- The members of the group approvers
NOTE: **Note:**
The merge request author is not allowed to approve their own merge request.
minus the merge request author. (We don't allow the merge request author to approve their own merge request.) Call this set `Ω`. Note that the `union` operator unravels groups and eliminates duplicates. So if the same user is configured as an individual approver and also part of a group approver, then that user is just counted once in `Ω`.
For the given merge request, if the required number of approvals has been met
(i.e., the number of approvals given to the merge request is greater or equal
than the required number), then the merge request is unblocked and can be merged.
Note, that meeting the required number of approvals is a necessary, but not
sufficient condition for unblocking a merge request from being merged. There
are other conditions that may block it, such as merge conflicts,
[pending discussions](../../discussions/index.md#l#only-allow-merge-requests-to-be-merged-if-all-discussions-are-resolved)
or a [failed CI/CD pipeline](merge_when_pipeline_succeeds.md).
If `m <= count(Ω)`, then only users in `Ω` are eligible appovers of the merge request.
## Overriding the merge request approvals default settings
If `m > count(Ω)`, then users in `Ω` _and_ members of the given project with Developer role or higher (minus the merge request author) are eligible approvers of the merge request.
> Introduced in GitLab Enterprise Edition 9.4.
## Merge request-level configuration
If approvals are [activated at the project level](#activating-approvals), the
default configuration (number of required approvals and approvers) can be
overridden for each merge request in that project.
If approvers are activated at the project level, configuration can be overriden for each merge request in that project, provided that the associated configuration is checked.
One possible scenario would be to to assign a group of approvers at the project
level and change them later when creating or editing the merge request.
![Approvals can override](img/approvals_can_override.png)
First, you have to enable this option in the project's settings:
### Required number of approvals
1. Navigate to your project's **Settings > General** and expand the
**Merge requests settings**
1. Tick the "Can override approvers and approvals required per merge request"
checkbox
Enter the required number of approvals to unblock the merge request from being merged. Call this number `m'`, which must be greater than or equal to `m`.
![Approvals can override](img/approvals_can_override.png)
### Configure individual approvers
1. Click **Save changes**
Select individual users who are eligible approvers for this merge request. You can only select project members, members of the project's immediate parent group, and members of a group who have access to the project via a [share](../../../workflow/share_projects_with_other_groups.md).
---
### Configure group approvers
The default approval settings can now be overridden when creating a
[merge request](index.md) or by editing it after it's been created:
Select groups who are eligible approvers for this merge request. Members of these groups will be eligible approvers for this merge request.
1. Search for users or groups that will be [eligible to approve](#eligible-approvers)
merge requests and click the **Add** button to add them as approvers or
remove existing approvers that were set in the project's settings
1. If you want to change the number of required approvals, set a new number
in the "Approvals required" box
1. Click **Save changes**
### Eligible approvers
There are however some restrictions:
For this merge request, the set of explicit approvers is the `union` of the following three:
- The amount of required approvals, if changed, must be greater than the default
set at the project level. This ensures that you're not forced to adjust settings
when someone is unavailable for approval, yet the process is still enforced.
- The number of Approvers must be greater or equal to the as the minimum required
approvals as set in the default settings.
- `Ω`
- The individual approvers at the merge request
- The members of the group approvers at the merge request
NOTE: **Note:**
If you are contributing to a forked project, things are a little different.
Read what happens when the
[source and target branches are not the same](#merge-requests-with-different-source-branch-and-target-branch-projects).
minus the merge request author. (We don't allow the merge request author to approve their own merge request.) Call this set `Ω'`. Note that the `union` operator unravels groups and eliminates duplicates. So if the same user is configured as an individual approver and also part of a group approver, then that user is just counted once in `Ω'`.
## Resetting approvals on push
If `m' <= count(Ω')`, then only users in `Ω'` are eligible appovers of the merge request.
If approvals are [activated at the project level](#activating-approvals),
you can choose whether all approvals on a merge request are removed when
new commits are pushed to the source branch of the merge request:
If `m' > count(Ω')`, then users in `Ω'` _and_ members of the given project with Developer role or higher (minus the merge request author) are eligible approvers of the merge request.
1. Navigate to your project's **Settings > General** and expand the
**Merge requests settings**
1. Tick the "Can override approvers and approvals required per merge request"
checkbox
## Remove approvals when new commits are pushed
![Approvals remove on push](img/approvals_remove_on_push.png)
If this project configuration is checked, all approvals on a merge request are removed when new commits are pushed to the source branch of the merge request; except for when you rebase the merge request directly from the merge request UI by clicking the `Rebase` button.
1. Click **Save changes**
![Approvals remove on push](img/approvals_remove_on_push.png)
NOTE: **Note:**
Approvals do not get reset when [rebasing a merge request](fast_forward_merge.md)
from the UI.
If you want approvals to persist, independent of changes to the merge request,
turn this setting to off by unchecking the box and saving the changes.
If one of the approvers pushes a commit to the branch that is tied to the merge
request, they automatically get excluded from the approvers list.
## Merge requests with different source branch and target branch projects
If the merge request source branch and target branch belong to different
projects (which happens in merge requests in forked projects), everything is
with respect to the target branch's project (typically the original project).
In particular, since the merge request in this case is part of the target
branch's project, the relevant settings are the target project's. The source
branch's project settings are not applicable. Even if you start the merge
request from the source branch's project UI, pay attention to the created merge
request itself. It belongs to the target branch's project.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment