OrganizationCodeowners

CODEOWNERS

Automatic review assignment based on file ownership patterns.

Drok supports the CODEOWNERS file format with identical syntax to GitHub. Define ownership rules for files and directories, and Drok automatically assigns reviewers to merge requests that modify owned files.

Configuration

Create a CODEOWNERS file in one of these locations (checked in order):

  1. .drok/CODEOWNERS
  2. CODEOWNERS
  3. docs/CODEOWNERS

Syntax

# Each line defines a pattern and one or more owners
# Owners can be usernames or team names
 
# Default owners for everything
*                    @your-org/engineering
 
# Backend code
/src/api/            @your-org/backend
/src/database/       @your-org/backend @alice
 
# Frontend code
/src/ui/             @your-org/frontend
/src/components/     @your-org/frontend
 
# Infrastructure
/infra/              @your-org/devops
Dockerfile           @your-org/devops
docker-compose.yml   @your-org/devops
 
# Documentation
/docs/               @your-org/docs-team
*.md                 @your-org/docs-team
 
# Security-sensitive files
/src/auth/           @your-org/security @your-org/backend
/src/crypto/         @your-org/security
 
# Build configuration
Cargo.toml           @bob
package.json         @your-org/frontend

Pattern Matching

PatternMatches
*All files
*.rsAll Rust files in any directory
/src/The src directory at the repository root
src/Any src directory at any depth
/docs/**/*.mdAll Markdown files under the root docs directory
DockerfileAny file named Dockerfile at any depth

Later rules override earlier rules. If a file matches multiple patterns, the last matching pattern determines the owners.

Behavior

When a merge request is created or updated:

  1. Drok computes the set of changed files
  2. Each changed file is matched against CODEOWNERS patterns
  3. The union of all matched owners is computed
  4. Those owners are automatically added as reviewers

Required Reviews

When combined with branch protection rules, CODEOWNERS reviews can be required:

drok branch-protection set main --require-review-from-codeowners

With this setting, a merge request cannot be merged until at least one owner from each matched CODEOWNERS pattern has approved.

Optional vs. Required Owners

By default, all CODEOWNERS are optional reviewers — they are notified and listed on the merge request, but their approval is not required unless branch protection mandates it.

To mark specific patterns as always requiring approval:

# Prefix with [required] to mandate approval
[required] /src/auth/     @your-org/security
[required] /src/crypto/   @your-org/security

Viewing Ownership

Check who owns a specific file:

drok codeowners my-org/my-repo src/api/handler.rs

Output:

src/api/handler.rs
  Owners: @your-org/backend
  Rule:   /src/api/  @your-org/backend (CODEOWNERS:8)

The web interface displays ownership information on every file page and in the merge request reviewer sidebar.

Validation

Drok validates the CODEOWNERS file on push:

  • Invalid usernames or team references produce a warning
  • Invalid patterns produce a warning
  • Syntax errors prevent the file from being used (falls back to previous valid version)

Validation warnings appear in the repository settings page under Code Owners.