Home > Mobile >  Adding codeowners for files in the root directory only
Adding codeowners for files in the root directory only

Time:07-26

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

CodePudding user response:

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

  • Related