Code ownership
Code ownership is aimed at helping find the right person and team to contact, for any question, at any time.
Concepts
Owner: An owner is defined as a person in Sourcegraph.
A person can be:
- a Sourcegraph user which we were able to resolve from the
CODEOWNERShandle or email, in which case we link to their profile. - an unknown user for which we were unable to resolve a profile, in which case we will return the
CODEOWNERSdata we have.
Code ownership
Code ownership is set via the CODEOWNERS format.
Limitations
- The feature has not been fully validated to work well on large repositories or large
CODEOWNERSrulesets. This is a future area of improvement, but please contact us if you run into issues.
Browsing ownership
The ownership information is available for browsing once ownership data is available through a CODEOWNERS file.
When displaying a source file, there is an "Ownership" button at the bottom. Clicking it will open the "Ownership" panel. The button appears only in repositories that have a CODEOWNERS file.

Ownership search
Searching for files with owners
Code ownership is a first-class citizen in search. Ownership can be either a query input or a search result:
- Results owned by the given owner:
repo:^github\.com/grafana/grafana$ file:has.owner(grafana/data-sources-plugins) azure count:10 - Files that have an owner:
repo:^github\.com/grafana/grafana$ file:has.owner() azure count:10 - Files without an owner:
repo:^github\.com/grafana/grafana$ -file:has.owner() azure count:10
Write the owner as the complete username, team name, or email address from the CODEOWNERS file. The leading @ is optional. To exclude results owned by the given owner, use -file:has.owner(...).
When performing a search, the select:file.owners predicate returns the owners of the search results. For example, to find the owners of Go files in the pkg/tsdb/azuremonitor/ directory:
repo:^github\.com/grafana/grafana$ file:^pkg/tsdb/azuremonitor/ lang:go select:file.owners count:50
Find commits in a release for a given owner
With type:commit, file:has.owner(...) matches commits that changed files owned by the given owner. For example, to find the commits between versions v12.4.13 and v12.4.14 that changed files owned by the grafana/grafana-frontend-platform team:
Further reading
In order to learn more please check out our references:
- CODEOWNERS format - Guide to using the CODEOWNERS file format to define ownership