Description:
This check verifies that a GitLab project is configured to automatically remove existing merge request approvals whenever new commits are pushed to the source branch. Without this setting, an approval given on an earlier version of the code could remain valid even after the code has changed, meaning a reviewer's approval might no longer reflect what is actually about to be merged.
Note: This check requires a GitLab Premium or Ultimate plan. The setting it evaluates depends on a paid feature that isn’t available on the Free plan.On the Free plan, the setting doesn’t appear in the GitLab UI or API, so it can’t be configured. The check will show as Failed or Not applicable, regardless of how the rest of the group or project is set up.
Rationale:
Approvals are meant to certify that a specific version of the code has been reviewed and deemed acceptable. If new commits can be pushed after approval without resetting that approval, the merge request could be merged with unreviewed changes under the cover of an approval that applied to a different, earlier version of the code. Automatically dismissing stale approvals ensures that every review reflects the actual code being merged.
Impact:
Require reviewers to re-approve a merge request after any new commit is pushed to the source branch.
Increase the number of review cycles for merge requests that receive late changes.
Improve the accuracy and trustworthiness of merge request approvals.
Reduce the risk of unreviewed changes being merged under a previously granted approval.
Default Value:
Disabled By default, GitLab projects do not automatically reset approvals when new commits are pushed to a merge request's source branch. Default setting: reset_approvals_on_push: false
Pre-Requisites:
Maintainer or Owner access to the project
An existing GitLab project
Test Plan:
Sign in to GitLab at https://gitlab.com.
Navigate to the target project.
Select Settings → Merge requests.
Locate the Approval settings section.
Verify that "Remove all approvals when commits are added to the source branch" is enabled.
Implementation Steps:
Sign in to GitLab at https://gitlab.com.
Navigate to the target project.
Select Settings → Merge requests.
Locate the Approval settings section.
Check "Remove all approvals when commits are added to the source branch".
Click Save changes.
Backout Plan:
Sign in to GitLab at https://gitlab.com.
Navigate to Settings → Merge requests.
Locate the Approval settings section.
Uncheck "Remove all approvals when commits are added to the source branch".
Click Save changes.
Confirm that project operations function as expected after the rollback.
Reference: