Adding codeowners for files in the root directory only

2.9k Views Asked by At

If I have a project structured like this:

project
│   README.md
│   config.json
    package.json
│
└───folder1
│   │   fileA.js
│   │   fileB.html
│   
└───folder2
    │   fileC.js
    │   fileD.html

How can I add a rule to the CODEOWNERS file that gives a user ownership of only the files in the root folder, but not the files in any of the subdirectories?

I've tried the following but none of them seem to work the way I want:

# CODEOWNERS
/ @johnSmith

./ @johnSmith

/* @johnSmith
1

There are 1 best solutions below

1
David On BEST ANSWER

After some experimenting this seems to work:

#CODEOWNERS

/*.* @userName

/apps @differentUserName

That will give @userName ownership of root files. It also applies to files inside dot-prefix folders, like .github/ or .vscode/ but no other nested directories