# Check who can merge a code change

[Read this guide on KeySigner](https://keysigner.io/integrations/guides/check-code-merge-approvals/)

Find the review decision for a specific revision and check what allows it to land in Bitbucket Cloud, Azure Repos, Gerrit or SourceHut.

## Before you start

- Use a harmless change in a test repository. Ask someone who can inspect the target branch rules and arrange for a reviewer and a contributor without bypass permissions.
- Record the repository, destination branch and revision you intend to review.
- [Check Bitbucket availability](https://keysigner.io/integrations/setup-requirements/#provider-availability-bitbucket)

## Data and access

- **Shared or checked**. The code host records the reviewer and revision. A branch rule or maintainer workflow determines whether that review is enough to land the change.
- **Check separately**. A review does not grant repository access or release permission. Check any new revision and its required checks.

## Compare approval rules

- [Bitbucket](https://keysigner.io/integrations/guides/check-code-merge-approvals/#step-1). The author’s approval does not count toward the minimum. On Premium, you can enforce that minimum and clear approvals on a new push. Check whether approvals carry forward when the diff stays the same.
- [Azure DevOps](https://keysigner.io/integrations/guides/check-code-merge-approvals/#step-2). The minimum-reviewer policy is off by default. When you enable it, check whether the requester’s or latest pusher’s votes count and whether a new push clears votes or requires a fresh approval.
- [Gerrit](https://keysigner.io/integrations/guides/check-code-merge-approvals/#step-3). Check which label scores satisfy the submit requirement and who can cast them. The label’s copy condition decides whether a vote carries forward to a new patch set.
- [SourceHut](https://keysigner.io/integrations/guides/check-code-merge-approvals/#step-4). Check whether a maintainer marked the latest patch set accepted. Confirm the destination commit separately. The patch status records a review decision, while the commit shows what landed.

## 1. Bitbucket Cloud

Open Branch restrictions and check the rules that match the destination branch. Look for the required approval count and successful builds on the latest commit. The Premium setting Prevent a merge with unresolved merge checks enforces those checks. Without it, Bitbucket warns about unresolved checks and can still allow the merge.

**Check.** On the current pull request, record the destination rule, the revision the builds cover, and whether the checks block a merge.

## 2. Azure Repos

Open Branch policies for the target branch. Check the minimum number of reviewers and whether Build validation is Required. Review the branch's permissions for bypassing policies when completing pull requests and when pushing. On the test pull request, inspect the approval and build results for the current revision.

**Check.** The current revision shows the required reviewers and build result. Record any bypass permission separately.

## 3. Gerrit

Open the change and select its current patch set. In Submit Requirements, inspect the rules and the votes that satisfy them. Check who has Submit access and whether any requirement was overridden. A new patch set may affect votes, depending on the project's label rules.

**Check.** Review the current patch set’s Submit Requirements and the votes that satisfy them. Record an override if one is present.

## 4. SourceHut

On a test project's mailing list, open the latest revision of the patch series and read the review thread. If the project records a patch status, check it alongside the discussion. Compare the reviewed patch with the commit on the destination branch after the maintainer applies it.

**Check.** The mailing-list review identifies the patch revision the maintainer applied. Compare its changes with the destination commit.

## 5. Check the result

For an enforced merge rule, check that the test change is blocked before the requirement is met, then record the authorized review and merge. If you submit a new revision, repeat the check on that revision. For a mailing-list workflow, record the reviewed patch and the resulting branch commit separately.

**Check.** Keep the links to the blocked and later allowed results for the same test revision. For SourceHut, keep the reviewed patch and destination commit.

## Check your result

Keep the link to the exact review and record the destination commit. For enforced rules, keep both the blocked and allowed results for the test branch.

[How to verify your setup](https://keysigner.io/integrations/verify-a-setup/)

## If you get stuck

### The change landed before review

Check which rule matched the branch, whether the check was enforced and whether the acting account had a bypass. On SourceHut, check who can write to the destination branch and how the project records maintainer decisions.

## Tools in this guide

- [Bitbucket](https://keysigner.io/integrations/bitbucket/)
  - [Check requirements for signed commits](https://support.atlassian.com/bitbucket-cloud/docs/require-signed-commits)
- [Azure DevOps](https://keysigner.io/integrations/azure-devops/)
  - [Set deployment approvals and checks](https://learn.microsoft.com/en-us/azure/devops/pipelines/process/approvals?view=azure-devops)
- [Gerrit](https://keysigner.io/integrations/gerrit/)
  - [Review repository access and submit permissions](https://gerrit-review.googlesource.com/Documentation/access-control.html)
- [SourceHut](https://keysigner.io/integrations/sourcehut/)
  - [Review which operations need repository access](https://docs.sourcehut.org/git.sr.ht/#type-AccessMode)

## Setup instructions

- [Configure Bitbucket Cloud merge checks](https://support.atlassian.com/bitbucket-cloud/docs/suggest-or-require-checks-before-a-merge/)
- [Review Azure Repos branch policies and permissions](https://learn.microsoft.com/en-us/azure/devops/repos/git/repository-settings?view=azure-devops)
- [Set Azure Repos reviewer counts and vote resets](https://learn.microsoft.com/en-us/azure/devops/repos/git/branch-policies?view=azure-devops#set-a-minimum-reviewer-policy)
- [Read Gerrit submit requirements on a change](https://gerrit-review.googlesource.com/Documentation/user-review-ui.html#submit-requirements)
- [Check which Gerrit votes carry forward](https://gerrit-review.googlesource.com/Documentation/config-labels.html#sticky_votes)
- [Review patches in SourceHut](https://sourcehut.org/blog/2019-05-15-whats-cooking-on-sourcehut-may-2019/)
- [Read how SourceHut tracks patch status](https://sourcehut.org/blog/2020-12-15-whats-cooking-december-2020/)
- [Test an approval gate before a release](https://keysigner.io/integrations/guides/test-a-release-approval-gate/#compare-approval-rules)
- [Compare approval history and provider outcomes](https://keysigner.io/integrations/approval-history/)
- [Set up a sign-in code for Bitbucket Cloud or SourceHut](https://keysigner.io/integrations/guides/set-up-developer-account-sign-in-codes/)
- [Replace a retired Bitbucket app password](https://keysigner.io/integrations/guides/replace-retired-developer-credentials/)
- [Test an Azure DevOps sign-in code](https://keysigner.io/integrations/guides/test-an-azure-devops-sign-in-code/)
- [Test a Gerrit sign-in code](https://keysigner.io/integrations/guides/test-a-gerrit-sign-in-code/)
- [Test a Debian Salsa sign-in code](https://keysigner.io/integrations/guides/test-a-debian-salsa-sign-in-code/)

[More guides for this task](https://keysigner.io/integrations/tasks/review-code-and-releases/)
