Code ownership allows you to surface ownership data using
This is done automatically if there is a committed
CODEOWNERS file in your repository at any of the following locations:
CODEOWNERS .github/CODEOWNERS .gitlab/CODEOWNERS docs/CODEOWNERS
However, it might be you do not want to have a
CODEOWNERS file committed to your repository (for example, to avoid automatic review requests), or you would like to overwrite the existing one.
Sourcegraph provides a UI and CLI to ingest a
CODEOWNERS file per-repository, that overrides any existing committed file.
You can ingest one
CODEOWNERS file per repository.
At this time the same ingested
CODEOWNERS file applies to all revisions.
Ingesting a file through the UI
Navigating to any repository page, clicking the Ownership button will surface information about any ingested
CODEOWNERS file, and will allow you to upload or update an existing one.
Ingesting a file with src-cli
There is the option to ingest data with the Sourcegraph src-cli.
The CLI provides
'src codeowners' is a tool that manages ingested code ownership data in a Sourcegraph instance. Usage: src codeowners command [command options] The commands are: get returns the codeowners file for a repository, if exists create create a codeowners file update update a codeowners file delete delete a codeowners file Use "src codeowners [command] -h" for more information about a command.
The input file can be written inline or passed in.
CODEOWNERSfiles must use either Sourcegraph usernames or email addresses for correct user matching to occur.
CODEOWNERSfiles committed to the repo should use either usernames of the codehost the repo is on (e.g. GitHub) or email addresses.
- The file should respect
CODEOWNERSformatting for code ownership to surface useful information. No formatting validation is done at upload time.
- Only site admins can add, update or delete a
CODEOWNERSfile through the ingestion API.
CODEOWNERSfiles are limited to a size of 10Mb if uploaded through the client.