Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

CODEOWNERS in Github doesn't work as expected

Tags:

github

Issue: CODEOWNERS need fully qualified path for rule against a directory/subdirectory.

I am writing a sample CODEOWNERS below to show the problem.

* @global-owner
foo/bar/ @octocat

I am expecting that whenever a PR is raised for any file (even recursively) inside directory foo/bar, user should be assigned a review. However, this always defaults to the * rule.

However, when I change the file to something like this:

* @global-owner
/app/src/main/java/com/cueo/foo/bar/ @octocat

This works like a charm. But the problem with this is that I need to repeat each directory twice to something like this:

/app/src/main/java/com/cueo/foo/bar/ @octocat
/app/src/test/java/com/cueo/foo/bar/ @octocat

According to the documentation:

# In this example, @octocat owns any file in an apps directory
# anywhere in your repository.
apps/ @octocat

I believe this should work for a nested directory structure also, like:

foo/bar/apps/ @octocat
like image 393
mohitmayank Avatar asked Sep 13 '25 05:09

mohitmayank


1 Answers

We need to prefix the paths with ** as well. This is not clear from the documentation.

So if we add a rule like:

* @global-owner
**/foo/bar/ @octocat

@octocat will be assigned for all foo/bar directories in the project.

like image 161
mohitmayank Avatar answered Sep 16 '25 07:09

mohitmayank