This document describes how to use the code owner mechanism.
The code owner mechanism must be used together with Branch Protection. Place the declaration file
CODEOWNERS in a code repository to declare the owner of the code files in this repository. Generally, the code owner is the project owner.
When the target branch of a merge request is a protected branch and the files changed in the request involve the paths or files set in the declaration file, the merge request details will list the corresponding owners and their review statuses.
In the figure above, the
CODEOWNER file declares that the owner of the files in the
charts/repos/** path is Sally. When a merge request is submitted for a protected branch and it involves changes to files in the
chars/repos/ path, Sally is automatically added as a reviewer for this request.
You can use the continuous integration plugin to automatically add reviewers. For details, see Automatically Add Merge Request Reviewers.
In the protected branch settings, toggle on Enable Review by Code Owner. Then, code owners must Allow Merge for every merge request that changes code under their jurisdictions.
CODEOWNERS files are searched for layer by layer from the following locations. The file name must be in uppercase, and the search will stop when one file is found.
The declaration file is a normal text file. Blank lines and lines starting with
# are ignored. Each line uses the following format:
# Declares all files with the extension .js
# Declares the files in the build/logs/ directory (including subdirectories) under the repository root directory
# Declares all files in docs/ folders (not including subdirectories)
# Declares all files in the docs/ folder (including subdirectories) under the root directory