Define code owners

Create a codeowners file to identify users who have expert knowledge of your product's codebase and can be trusted to review and make code changes.

Guidelines for adding code owners

Using a codeowners file, you can define users who are responsible for parts of your product's codebase.

Rules and behaviors:

  • In Git repositories, PulseUno uses the codeowners file to automatically assign reviewers to pull requests. The rest of the review process is performed based on review rules. For details, see Review rules.

  • The Dimensions CM, StarTeam, and AccuRev products rely on review rules and do not use the codeowners file to assign reviewers.

  • PulseUno displays code owners for files but not for directories.

  • PulseUno includes the Code Owners section on the review pages.

Guidelines for creating and adding a codeowners file:

  • A codeowners file is a text file with no extension.

  • You can add one codeowners file per product.

  • Using the options in the codeowners file, you can hide the Code Owners section and disable the automatic assigning of reviewers. For details, see Codeowners file syntax.

  • Place the codeowners file in the root of your product, or create a .pulseuno subdirectory at the root and push the file there.

    If you have one file in the root directory and another one in the .pulseuno subdirectory, PulseUno uses the file at the root.

  • When you push the codeowners file to a product, PulseUno parses the file and generates findings for detected errors. To view the findings, open the file in the code browser. For details, see Browse files in branches.

  • Make sure to update your codeowners file to reflect any changes in usernames, emails, or paths.

Back to top

Codeowners file syntax

This section describes the syntax of the codeowners file.

Syntax elements

The following table explains the syntax elements:

Element Description
# <text string>

Add a comment. Start each comment line with the hash sign (#).

PulseUno skips the lines with comments.

showinreview

Use this option to control whether the Code Owners section is displayed on the review pages. Accepted values are true or false.

By default, the Code Owners section is displayed:

showinreview=true

assign

Use this option to control whether the reviewers are automatically assigned to pull requests. Accepted values are true or false.

By default, code owners are automatically assigned as reviewers:

assign=true

#?option

To set the showinreview or assign options, start the line with the #?option comment.

You can enter multiple options on a single line. For example:

#?option showinreview=false assign=true

If you add multiple #?option lines, the options from each line are combined into a single set, with each line added to the previous lines.

If the same option is included multiple times, PulseUno uses the last value for the option.

@username

username@domain.com

Reference users by their email address, or their PulseUno username prepended with the at sign (@username).

If multiple users are code owners, enter usernames as a list separated by spaces. The order of usernames is not important.

For example, to set username01 and username02 as the code owners for all readme.md files in the product, enter:

readme.md @username01 @username02

[Section]

Add a section. Use sections to add required code owners for files in specific areas. Each section must have at least one code owner.

For example, to define the required owners for the server-side code, add the [Backend] section:

[Backend] @username01 @username02

Required code owners can be automatically assigned as lead reviewers on the relevant pull requests.

^[Section-Optional]

Add an optional section to define optional code owners. Each optional section must have at least one code owner.

For example, to define the optional owners of the server-side code in your product, add the ^[Backend-Optional] section:

^[Backend-Optional] @username03

Optional code owners can be automatically assigned as optional reviewers on the relevant pull requests.

Wildcards and patterns

Match code owners to specific relative paths, files, or file patterns. Define paths using the following wildcards and patterns:

Pattern Description

**

*

/**/*

/**/

Matches all files in a product or Git repository.
/* Matches all files in the product's root directory.

/*/*

/*/

Matches all files in the root directory and its first-level subdirectories.

Note: If a path starts with a slash (/), it matches the root of the product. If a path ends with a slash (/), it matches any file in the directory.

/dir/*

/dir/

Matches all files and subdirectories in the dir directory at the root of the product.

/my\ dir/*

/my\ dir/

Matches all files in the my dir directory at the root of the product.

Note: If a path contains spaces, use a backslash (\) to escape spaces.

dir/*

/**/dir/*

/**/dir/

Matches all files and subdirectories in any dir directory in the product, for example:

/backend/dir/

/frontend/source/dir/

Note: If a path doesn't start with a slash (/), the path is treated as matching the following pattern: /**/

readme.md

/**/readme.md

Matches all readme.md files in the product.
/*/readme.md

Matches all readme.md files in the product's root directory and any first-level subdirectory, for example:

/readme.md

/dir/readme.md

*.xml Matches all XML files.
settings.*

Matches all the files named settings regardless of the file extension, for example:

settings.xml, settings.zip, settings.json

Codeowners file examples

Here is an example of a codeowners file:

Copy code
# To add a section, enclose its name in brackets.
# For example, the [CODEOWNERS] section defines the default owners 
# of all the files in the product.
# Section code owners override default code owners for the paths specified in sections. 
# Any entries without a section are assigned to the [CODEOWNERS] section.

[CODEOWNERS] username01 username02 username03
*

[Agent] @username01
/agent/*
/agent/settings.xml @username02

^[Agent-Optional] @username04
/agent/*

[Backend] @username01 @username02
/backend/*

^[Backend-Optional] @username03
/backend/*

[Frontend] @username01 @username04
/frontend/*
/frontend/assets/* @username04
*.css @username04

^[Frontend-Optional] @username05 @username06
/frontend/*

In sections, the last matching pattern takes precedence over earlier patterns.

Example 1: The [Agent] section

Copy code
[Agent] @username01
/agent/*
/agent/settings.xml @username02

In this example, username01 owns all the files and subdirectories in the /agent directory, except the settings.xml file owned by username02.

Example 2: The [Frontend] section

Copy code
[Frontend] @username01 @username04
/frontend/*
/frontend/assets/* @username04
*.css @username04

In this example, username01 and username04 are the code owners of the /frontend directory, but only username04 owns the /frontend/assets subdirectory and any .css files in the product.

Back to top

See also: