---
metadata:
  - name: generator
    content: Diplodoc Platform v5.54.2
alternate:
  - https://sourcecraft.dev/portal/docs/en/sourcecraft/concepts/code-review.md
  - https://sourcecraft.dev/portal/docs/ru/sourcecraft/concepts/code-review.md
  - href: en/sourcecraft/concepts/code-review.md
    type: text/markdown
    title: Markdown version
  - href: ../../llms.txt
    type: text/markdown
    title: llms.txt
title: Approval rules in SourceCraft
description: How to set up mandatory approval rules in SourceCraft to control code quality before merging pull requests.
---
> **Documentation Index:** Fetch the complete configuration index at https://sourcecraft.dev/portal/docs/en/llms.txt


# Approval rules in SourceCraft

<!-- source: en/_includes/sourcecraft/code-review-intro.md -->
With SourceCraft, you can flexibly set up mandatory approval rules before any code can be added to the target branch of the repository.
<!-- endsource: en/_includes/sourcecraft/code-review-intro.md -->

If a repository has the approval rules enabled, SourceCraft analyzes approvals from reviewers for compliance with the specified rules. If there are not enough approvals, merging a pull request with the target branch will be blocked.

Once you get all the approvals specified in the rules, you can merge the changes.

<!-- source: en/_includes/sourcecraft/code-review-bypass.md -->
{% note warning %}

Only users with the [`Repository maintainer`](https://sourcecraft.dev/portal/docs/en/sourcecraft/security/index.md#src-repositories-maintainer) or [`Repository admin`](https://sourcecraft.dev/portal/docs/en/sourcecraft/security/index.md#src-repositories-admin) role can override the approval rules and perform a forced merge.

{% endnote %}
<!-- endsource: en/_includes/sourcecraft/code-review-bypass.md -->

<!-- source: en/_includes/sourcecraft/code-review-file.md -->
You specify the approval rule configuration for a particular repository and store it in the `.sourcecraft/review.yaml` file. You can also set the [configuration at the SourceCraft organization level](https://sourcecraft.dev/portal/docs/en/sourcecraft/concepts/org-config.md).
<!-- endsource: en/_includes/sourcecraft/code-review-file.md -->

For more information about working with rules, see [this article](https://sourcecraft.dev/portal/docs/en/sourcecraft/operations/code-review.md).

### Configuration example {#example}

<!-- source: en/_includes/sourcecraft/code-review-config.md -->
```yaml
codereview: 
  need_ships: 1 # Required number of approvals from reviewers
  ignore_self_ship: false # Ignore approvals from the pull request author
  ignore_non_reviewers_block: false # Ignore pull request blocking from non-reviewers
  auto_assign: true # Automatically assign reviewers
  rules:
    - patterns:
        - "**" # Repository path pattern
      reviewers:
        usernames: 
          - "<user_name>" # List of reviewers
        assign: 1 # Number of automatically assigned reviewers
        need_ships: 1 # Required number of approvals from reviewers
        ignore_self_ship: false # Ignore approvals from the pull request author
```
<!-- endsource: en/_includes/sourcecraft/code-review-config.md -->

<!-- source: en/_includes/sourcecraft/wildcard-pattern-tip.md -->
{% note tip %}

For group filtering, we recommend to use the `**` pattern because the simple `*` pattern will not give you a match in expressions with `/`.

{% endnote %}
<!-- endsource: en/_includes/sourcecraft/wildcard-pattern-tip.md -->

<!-- source: en/_includes/sourcecraft/configuration-tip.md -->
{% note tip %}

You can set up and view repository configurations in the SourceCraft interface under ![image](../../_assets/console-icons/gear.svg) **Repository settings** in the ![image](../../_assets/console-icons/nut-hex.svg) **Configurations** section. Learn more in [this article](https://sourcecraft.dev/portal/docs/en/sourcecraft/operations/configuration-edit.md).

{% endnote %}
<!-- endsource: en/_includes/sourcecraft/configuration-tip.md -->

#### Useful links {#see-also}

* [Setting up approval rules in a SourceCraft repository](https://sourcecraft.dev/portal/docs/en/sourcecraft/operations/code-review.md)
* [Continuous integration and continuous deployment in SourceCraft](https://sourcecraft.dev/portal/docs/en/sourcecraft/concepts/ci-cd.md)
* [Configuring CI/CD in a SourceCraft repository](https://sourcecraft.dev/portal/docs/en/sourcecraft/operations/ci-cd.md)