Introducing code owners
While effective code review is essential to every successful project, it’s not always clear who should review files—even with GitHub’s reviewer suggestions. Now repository maintainers can define exactly which people…
While effective code review is essential to every successful project, it’s not always clear who should review files—even with GitHub’s reviewer suggestions. Now repository maintainers can define exactly which people and teams need to review projects using code owners. This new feature automatically requests reviews from the code owners when a pull request changes any owned files.
How code owners work
To specify code owners, create a file named CODEOWNERS
in the repository’s root directory (or in .github/
if you prefer) with the following format:
# Lines starting with '#' are comments.
# Each line is a file pattern followed by one or more owners.
# These owners will be the default owners for everything in the repo.
* @defunkt
# Order is important. The last matching pattern has the most precedence.
# So if a pull request only touches javascript files, only these owners
# will be requested to review.
*.js @octocat @github/js
# You can also use email addresses if you prefer.
docs/* docs@example.com
This format may be familiar if you’ve used gitattributes
.
With that in place, code owners will automatically be requested for review whenever a pull request touches the files they own.
An extra layer of code security
For projects with more rigorous review processes, we’ve also added a new protected branch option to ensure the right people have a chance to review.
With protected branches enabled, a code owner for each owned file has to leave a review before anyone can merge a pull request to that branch.
We hope this helps make your review process even more effective. Let us know if you have any feedback on code owners using our help form.
The code owners feature was inspired by Chromium’s use of OWNERS
files.
Written by
Related posts
Announcing GitHub Secure Open Source Fund: Help secure the open source ecosystem for everyone
Applications for the new GitHub Secure Open Source Fund are now open! Applications will be reviewed on a rolling basis until they close on January 7 at 11:59 pm PT. Programming and funding will begin in early 2025.
Software is a team sport: Building the future of software development together
Microsoft and GitHub are committed to empowering developers around the world to innovate, collaborate, and create solutions that’ll shape the next generation of technology.
Does GitHub Copilot improve code quality? Here’s what the data says
Findings in our latest study show that the quality of code written with GitHub Copilot is significantly more functional, readable, reliable, maintainable, and concise.