What is the purpose of GitHub's 'mandatory code review dismissal' feature in branch protection?
Select an answer to reveal the explanation.
Short Explanation and Infographic
Dismiss stale reviews is your quality assurance net. If a PR gets approved and then someone pushes more changes after approval, those approvals automatically get invalidated. Reviewers must sign off on the final version, not a previous one.
Full explanation below image
Full Explanation
The 'Dismiss stale pull request approvals when new commits are pushed' (also called 'Require review from Code Owners' combined with stale review dismissal) is a branch protection setting that automatically dismisses existing PR approvals when new commits are added to the pull request after those approvals were given. Without this setting, a PR could be approved, additional (unreviewed) code pushed, and then merged with approvals that don't reflect the final state. With dismissal enabled, each new commit resets the approval count to zero, requiring reviewers to re-approve the final version of the code. This ensures that approvals are always based on the most current state of the pull request.