Adding default reviewers to Github repository

Viewed 13079

I followed the instructions here https://help.github.com/articles/about-codeowners/ but it doesn't seem to work. I even added the CODEOWNERS file at both the root and .github directory. The reviewers specified in the CODEOWNERS file are not selected automatically when a pull request is created. See screenshots below. Onyone who has set this up, could you point to where the problem is. Thank you.

enter image description here

enter image description here

enter image description here

enter image description here

2 Answers

You need to be sure that your base branch has:

  • the 'Protect this branch' flag activated
  • the 'Require pull request reviews before merging' flag activated
  • the 'Require review from Code Owners' flag activated

Then in the CODEOWNERS file, located either in the root of the repo or in the .github subfolder, you need to have either a user described with '@user', a user described with his email like 'user@domain.com', or a team described with '@org/teamname'.

You will need also to be sure that:

  • your contributors (users and teams) have for each of them the 'write' access to the repo
  • the team is not a 'secret' team, only the 'visible' teams would be taken into account

Double-check the CODEOWNERS file syntax

The pattern is followed by one or more GitHub usernames or team names using the standard @username or @org/team-name format.

(I don't see @ in your case)

You can also refer to a user by an email address that has been added to their GitHub account, for instance user@example.com.

If the syntax is correct, then you can contact GitHub support to have them investigate.


The OP Pratheep actually find this is working:

You need the @ and referring to my last screenshot above, you don't see the reviewers in the list when creating the PR.
But once the PR is created, then you will see the reviewers in the list.

I believe it was by design not to show. Because if you show the reviewers in that list before the PR is created, the names can be removed.
This way no one can create a PR without notifying the codeowners/default reviewers.

Related