I do pull requests in a repo where it's always the same person reviewing. I would like to set him as the default reviewer so that I don't always have to choose him at each pull request, it'd be automatic. How to do that ?
3 Answers
GitHub has the ability to set the default reviewer using a CODEOWNERS
file.
Code owners are automatically requested for review when someone opens a pull request that modifies code that they own. When someone with admin permissions has enabled required reviews, they can optionally require approval from a code owner.
To use a CODEOWNERS file, create a new file called CODEOWNERS in the root,
docs/
, or.github/
directory of the repository, in the branch where you'd like to add the code owners.
-
I tried this on GitHub Enterprise Server 2.18.4 and it didn't seem to work. Commented Oct 21, 2019 at 22:13
-
It looks like it should be supported- help.github.com/en/enterprise/2.18/user/…. Their support should be able to help– osowskitCommented Oct 22, 2019 at 2:33
-
-
And why I set, when I can't a code owner, but um default, with on all time need review, type a new dev on the team, I'd like if here review for understand more, but on all time I need set with is review. Commented Jul 18, 2023 at 13:49
You should add .github/CODEOWNERS
file with users to send PR to.
Example to send PR for any change on codebase represented by *
:
## code changes will send PR to following users
* @option1-user1 @option1-user2 @option2-your-org/team-name
Note: .github/CODEOWNERS
should be in main
branch to be effective.
-
-
20@Cjmarkham True, but this answer offers better details and is more to the point. The current accepted answer is just a huge block quote. Commented Jan 10, 2022 at 15:50
-
Worked for me. However, not on intermediate branches such as
develop
,uat
Commented Jan 18 at 20:50
When initiating a new pull request, Bitbucket automatically scans for the presence of a CODEOWNERS file in the .github directory of the repository.
You can specify the number of reviewers to select and define the selection criteria. Here are some examples of how this syntax can be used.
.github/CODEOWNERS
# .bitbucket/CODEOWNERS
# Default reviewers for files not matching patterns below
* [email protected] [email protected]
# Choose all members of a workspace group
*.js @workspace-idk/frontenders:all
# Choose group members tagged on the fewest open PRs
*.py @workspace-be/backenders:least_busy(2)
# Choose randomly from a custom team (defined in teams.yaml)
*.tf @teams/sre-leads:random(2)