Help
cancel
Showing results for 
Search instead for 
Did you mean: 
Copilot Lvl 3
Message 1 of 24

Do not require owner approval if the pull request is from an owner?

I just set up CODEOWNERS for a github repository. Let's say we have such a line:

 

foobar/   @alice @bob

 

Also, in the repository setting, I required every pull request to get approvals from code owners. Therefore, if a pull request comes from another person, their pull request has to get approvals from either alice or bob before it is able to be merged.

 

So far so good. However, I found that even if alice makes a pull request, her pull request also needs to get approval from bob before it can be merged.

 

Is it possible to configure the repostiory so that a pull request from owner does not need owner approval? I understand that there are some scenarios in which it's better for an owner to wait for another owner's approval, so it would be great if this behavior could be configured. Thanks!

23 Replies
Moderator
Message 2 of 24

Re: Do not require owner approval if the pull request is from an owner?

To my understanding, in your example if alice makes a matching pull request, she can still approve her own PR. Is that not what you're seeing?

Copilot Lvl 3
Message 3 of 24

Re: Do not require owner approval if the pull request is from an owner?

Github doesn't allow pull request authors to add themselves as reviewers, so Alice is not able to approve her own PR.

Ironically, we have already been hit by this issue. We have required owner approval in one of our repos. In that repo, I'm the sole owner of one directory. I made one pull request that makes change in that directory. After I got an approval from a reviewer, I was told that my pull request is ready to merge. However, after I clicked the merge button, an error box appeared, saying that I have to wait for my own approval. Of course I then tried adding myself as a reviewer, but with no luck...
Moderator
Message 4 of 24

Re: Do not require owner approval if the pull request is from an owner?

Ok, I think I understand what's going on. In this instance, while alice and bob are owners of the specified code, they are not administrators on the repository? Or they are administrators and you have "Include administrators" selected on the protections for the protected brach? If alice is an administrator of the repository and "Include administrators" is unchecked then alice should be able to merge her own PR without requiring review or approval. Otherwise, yes, you are correct that currently bob would have to review and approve the PR.

 

I'm not sure if using a team (if this is a repo that belongs to an organization) instead of individuals would make this work differently. If this is a repo that belongs to an organization, let me know and I can dig further.

Copilot Lvl 3
Message 5 of 24

Re: Do not require owner approval if the pull request is from an owner?

(Not sure why github.community removes formatting in my last post. Reposting)

 

Thanks lee-dohm! This is a private repo that belongs to our company. In our company, we chose not to designate everybody as admin. Instead, every directory has one or more designated owners, and the directory owners take responsibility for the code quality and code review for that directory.

 

The feature we expect is that if Alice is an owner of the directory, when she makes changes on that directory, she should still get a general code review approval from another reviewer, but she does not need to get an owner approval to merge her PR.

 

However, github requires owners to also get owner approval, so we have found the following funny and painful cases:

 

* For some directories, there is just one go-to person, so he/she is the only owner. Then we found that he/she could not merge a pull request that makes changes on the directory he/she owns.. But ironically, he/she could tell somebody else to submit a PR, and he/she approves it, then that PR could be merged :-|

 

* For some directories, there are two go-to persons. But often, one is in Asia, while the other is in the US. Each owner has to wait until the owner approval from the other owner (in another continent). The time cost is painful..

 

Thanks!

Moderator
Message 6 of 24

Re: Do not require owner approval if the pull request is from an owner?

Thank you for the extra detail @yiming9.

 

This is currently a known issue that our engineering team is working on—though I can't promise an ETA of when this behaviour will change.

 

In the meantime, our suggestion is to either:

 

  1. Disable the option for requiring reviews from code owners in the protected branch settings
  2. Elevate yourself to admin access to allow you to override this branch protection

 

We'll let you know when we have any updates on this.

Ground Controller Lvl 1
Message 7 of 24

Re: Do not require owner approval if the pull request is from an owner?

 Do users still have this problem if they use a group/team alias instead of specific people? For example, you create a group alias in github that Alice and Bob are both members of, foo@bar.com. Then when Alice opens up the PR, will she be able to approve her own PR as being part of the group alias, not the individual person?

 

I am going to end up having this same issue with our org is why I ask.

Moderator
Message 8 of 24

Re: Do not require owner approval if the pull request is from an owner?

To my understanding, it doesn't matter whether they are listed individually or as members of a team. But I would recommend trying it out, just make a test repo in your organization and a test team with yourself as the only member. You can see how I tested the non-team version in a personal repo of mine.

Ground Controller Lvl 1
Message 9 of 24

Re: Do not require owner approval if the pull request is from an owner?

We have github enterprise and did run into the same problem already.

Ground Controller Lvl 1
Message 10 of 24

Re: Do not require owner approval if the pull request is from an owner?

Experiencing the same issue here. I end up disabling code owners every time i want to merge my own PR (i am the code owner)