Skip to content

Code owners

Use code owners to define individuals or teams that are responsible for code in your monorepo and integrate with your git hosting provider’s CODEOWNERS implementation.

Set your codeowners provider in your root configuration file:

./onerepo.config.ts
export default {
core: {
codeowners: {
provider: 'github',
},
},
};

Add codeowners to any Workspace or root configuration:

"./modules/workspace/onerepo.config.ts
export default {
codeowners: {
'*': ['@my-team', '@person'],
scripts: ['@infra-team'],
},
};

Run the sync command to update any time you make changes to code owners:

Terminal window
one codeowners sync

The following providers are currently enabled:

Aliases: one owners

Manage codeowners

Terminal window
one codeowners <command>

Show the code owners for files and Workspaces.

Terminal window
one codeowners show [options]
OptionTypeDescription
--affectedbooleanSelect all affected Workspaces. If no other inputs are chosen, this will default to true.
--all, -abooleanRun across all Workspaces
--files, -farrayDetermine Workspaces from specific files
--format"plain", "json", default: "plain"Choose how the results will be returned.
--listbooleanJust list the owners without the files
--stagedbooleanUse files on the git stage to calculate affected files or Workspaces. When unset or --no-staged, changes will be calculated from the entire branch, since its fork point.
--workspaces, -warrayList of Workspace names to run against
Advanced options
OptionTypeDescriptionRequired
--from-refstringGit ref to start looking for affected files or Workspaces
--provider"github", "gitlab", "gitea", "bitbucket"Codeowner provider determines where the CODEOWNERS file(s) will be written.âś…
--through-refstringGit ref to start looking for affected files or Workspaces

Show the codeowners for currently modified files.

Terminal window
one codeowners show

List the unique set of codeowners given an input workspace-name.

Terminal window
one codeowners show --list -w <workspace-name>

Sync code owners from Workspace configurations to the repository’s CODEOWNERS file.

Terminal window
one codeowners sync

This command will sync each Workspace’s codeowners to the repository’s configured vcs.provider compatible code owners file.

  • github: .github/CODEOWNERS
  • gitlab: .gitlab/CODEOWNERS
  • gitea: .gitea/CODEOWNERS
  • bitbucket: CODEOWNERS
OptionTypeDescription
--addbooleanAdd the updated CODEOWNERS file to the git stage.
Advanced options
OptionTypeDescriptionRequired
--provider"github", "gitlab", "gitea", "bitbucket"Codeowner provider determines where the CODEOWNERS file(s) will be written.âś…

Verify the CODEOWNERS file is up to date and unmodified.

Terminal window
one codeowners verify
Advanced options
OptionTypeDescriptionRequired
--provider"github", "gitlab", "gitea", "bitbucket"Codeowner provider determines where the CODEOWNERS file(s) will be written.âś…