mohitmayank
mohitmayank

Reputation: 661

CODEOWNERS in Github doesn't work as expected

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

Upvotes: 4

Views: 3886

Answers (1)

mohitmayank
mohitmayank

Reputation: 661

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.

Upvotes: 3

Related Questions