Skip to content

Make CODEOWNERS file name configurable #25

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
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
10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,13 @@ The first code owners for an open file will be displayed in the right side of th
![](./img/command.gif)

Use the command palette to run the `CODEOWNERS: Show owners of current file` command, which will display all code owners for the current file.


## Modify CODEOWNERS file name

You can modify the default CODEOWNERS file name to any custom name which your project uses:
```json
{
"codeowners.fileName": "MY_CUSTOM_CODEOWNERS"
}
```
11 changes: 9 additions & 2 deletions extension.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,12 @@ const path = require('path');
const COMMAND_ID = 'vscode-codeowners.show-owners';
const STATUS_BAR_PRIORITY = 100;

// Function to get the custom CODEOWNERS file name or default to "CODEOWNERS"
const getCodeownersFileName = () => {
const config = vscode.workspace.getConfiguration('codeowners');
return config.fileName || 'CODEOWNERS';
};

const getOwners = () => {
if (!vscode.window.activeTextEditor) {
return [];
Expand All @@ -18,7 +24,8 @@ const getOwners = () => {

let folder;
try {
folder = new Codeowners(workspacePath);
const codeownersFileName = getCodeownersFileName(); // Use the custom or default file name
folder = new Codeowners(path.join(workspacePath, '.github'), codeownersFileName); // Assuming CODEOWNERS is in the .github folder
} catch {
// no CODEOWNERS file
return null;
Expand Down Expand Up @@ -70,5 +77,5 @@ const activate = context => {

exports.activate = activate;

const deactivate = () => {};
const deactivate = () => { };
exports.deactivate = deactivate;