Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions cspell-allow-list.txt
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ Awais
awscli
awsrepos
azuredevops
azuremonitor
backfiller
baseai
batchchange
Expand Down Expand Up @@ -292,8 +293,10 @@ keymappings
keypair
killall
Kitts
klog
kubeconfig
kubelet
kuberuntime
kustomization
Langbase
languagemodels
Expand Down Expand Up @@ -599,6 +602,7 @@ urlencode
urlsafe
userprincipalname
USERTRUST
utilruntime
Valsorda
vegeta
vercel
Expand Down
8 changes: 3 additions & 5 deletions docs/code-ownership/codeowners-format.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -44,13 +44,9 @@ The rules are considered independently and in order. Rules farther down the file
- GitLab allows sections in `CODEOWNERS` files, these are not yet supported and section markers are ignored
- [Code Owners for Bitbucket](https://marketplace.atlassian.com/apps/1218598/code-owners-for-bitbucket?tab=overview&hosting=cloud) inline defined groups are not yet supported

To configure ownership in Sourcegraph, you have two options:

## Committing a `CODEOWNERS` file to your repositories

> Use this approach if you prefer versioned ownership data.

You can simply commit a `CODEOWNERS` file at any of the following locations for it to be picked up automatically by code ownership:
Sourcegraph reads ownership only from `CODEOWNERS` files committed to your repositories. Commit a `CODEOWNERS` file at any of the following locations for it to be picked up automatically by code ownership:

```
CODEOWNERS
Expand All @@ -59,4 +55,6 @@ CODEOWNERS
docs/CODEOWNERS
```

If a repository has `CODEOWNERS` files at more than one of these locations, Sourcegraph uses the first one in this list.

Searches at specific commits will return any `CODEOWNERS` data that exists at that specific commit.
24 changes: 13 additions & 11 deletions docs/code-ownership/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ Code ownership is set via [the `CODEOWNERS` format](/code-ownership/codeowners-f

The ownership information is available for browsing once ownership data is available through [a `CODEOWNERS` file](#code-ownership).

When displaying a source file, there is an "Ownership" button at the bottom. Clicking it will open the "Ownership" panel.
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.

![File view with the ownership tab selected in the bottom panel](https://storage.googleapis.com/sourcegraph-assets/docs/own/blob-view-panel-v2.png)

Expand All @@ -33,22 +33,24 @@ When displaying a source file, there is an "Ownership" button at the bottom. Cli

Code ownership is a first-class citizen in search. Ownership can be either a query input or a search result:

- `file:has.owner(user@example.com)` keeps only the search results associated with given user (here referred to by e-mail).
- `-file:has.owner(@username)` removes all results owned by specific user (here referred to by name).
- Results owned by the given owner:\
[`repo:^github\.com/grafana/grafana$ file:has.owner(grafana/data-sources-plugins) azure count:10`](https://sourcegraph.com/search?q=repo:%5Egithub%5C.com/grafana/grafana%24+file:has.owner%28grafana/data-sources-plugins%29+azure+count:10&patternType=keyword)
- Files that have an owner:\
[`repo:^github\.com/grafana/grafana$ file:has.owner() azure count:10`](https://sourcegraph.com/search?q=repo:%5Egithub%5C.com/grafana/grafana%24+file:has.owner%28%29+azure+count:10&patternType=keyword)
- Files without an owner:\
[`repo:^github\.com/grafana/grafana$ -file:has.owner() azure count:10`](https://sourcegraph.com/search?q=repo:%5Egithub%5C.com/grafana/grafana%24+-file:has.owner%28%29+azure+count:10&patternType=keyword)

Ownership predicate can also be used without parameters:
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(...)`.

-`file:has.owner()` will only include files with an owner assigned to them. -`-file:has.owner()` will only include files without an 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:

When performing a search the `select:file.owners` predicate will return the owners for the result of that search.
[`repo:^github\.com/grafana/grafana$ file:^pkg/tsdb/azuremonitor/ lang:go select:file.owners count:50`](https://sourcegraph.com/search?q=repo:%5Egithub%5C.com/grafana/grafana%24+file:%5Epkg/tsdb/azuremonitor/+lang:go+select:file.owners+count:50&patternType=keyword)

For instance one can find all the owners of TypeScript files in a given repository by using `repo:^github\.com/sourcegraph/sourcegraph$ lang:TypeScript select:file.owners`.
### Find commits in a release for a given owner

### Find commits in given release for 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:

To find all commits between versions `5.0` and `5.1` made by `sourcegraph/own` team, the following query could be used:

`repo:^github\.com/sourcegraph/sourcegraph$@5.1:^5.0 type:commit file:has.owner(sourcegraph/own)`
[`repo:^github\.com/grafana/grafana$@v12.4.14:^v12.4.13 type:commit file:has.owner(grafana/grafana-frontend-platform)`](https://sourcegraph.com/search?q=repo:%5Egithub%5C.com/grafana/grafana%24@v12.4.14:%5Ev12.4.13+type:commit+file:has.owner%28grafana/grafana-frontend-platform%29&patternType=keyword)

## Further reading

Expand Down
Loading
Loading