Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Change author of Pull Request in GitHub / Create PR in someone's stead

tl;dr I created a PR in someone's stead. Now I can't submit a review. Is there a way around?

The other developer messed up and merged a feature to the target branch, so I reverted their changes, fixed the issues, squashed and rebased their work while still keeping their authorship on the commit and I created a new pull request. Now, when I want to submit a review, it prevents me to Request changes, because now I am the author of the PR. How can I change it so that the other developer is responsible and receives the review?

enter image description here

like image 442
Qwerty Avatar asked May 26 '21 11:05

Qwerty


2 Answers

You cannot change the author of a pull request or create one in somebody else's name. GitHub doesn't allow this because it would permit people to forge pull requests and let another person receive negative feedback. For example, if I opened a PR in your name containing something wildly inappropriate (say, a racist slur), you'd be blamed for it unfairly. Moreover, in some regulated environments, keeping an accurate record of who contributed code is very important for legal reasons, which is another reason why this isn't permitted.

In most cases, if a commit gets reverted, then just have the original author open a new PR. Clearly they'd wanted to submit the code in the first place. You can even create the branch for them with their commit squashed and prepared, as long as they open the PR. This is a case where a helpful conversation with another contributor goes a long way, and presumably you'd want to let them know in a kind way that they made a mistake and that you reverted it anyway. Since there's no way to create a repository on behalf of another user, you should close your PR and ask them original submitter to open it instead.

I think it's obvious why you can't approve your own PRs. I can see that this is a situation where requesting changes might be useful, but I suppose the rationale is that you wouldn't have opened the PR if you thought it needed improvements, and if you later learned that, you certainly would revise it instead of merging it.

like image 128
bk2204 Avatar answered Sep 20 '22 18:09

bk2204


Although bk2204's answer is correct and explains why there isn't a one-button solution, it doesn't address the actual question of:

How can I change it so that the other developer is responsible and receives the review?

The only way to that is to close out the PR you opened and have them open it instead.

like image 32
Foghorn Avatar answered Sep 18 '22 18:09

Foghorn