Is it possible to change other people's code in pull requests (Github)?
Asked Answered
C

2

10

On a Github project, I see a guy made a pull request in Pull Requests section, but I find he made many mistakes so his code need to be corrected. Instead of asking him to change his code, is it possible to do it by myself (that is, I want to correct his code by myself)? and how?

I'm also a member of that project, and I'm new :)

Cellulous answered 21/8, 2016 at 5:43 Comment(5)
Why are you asking us and not the other members of that project?Aisha
Why not get him to change the code - so at least he learns. Also you want to make changes in another persons name - this seems rather oddPapaveraceous
Strictly speaking, I'm not changing his programming code, I'm changing his language (Japanese) in his code. It's much simpler to change by myself because it's a little hard to communicate with him, in Japanese, or in English (Neither is his native language).Cellulous
@KenWhite he question is correct. The question "is it possible to change?" not "should I do that?" I'm also very interesting, since got a lot of PR's from contributors in my projects, and I don't want to wait for minor fixes. Still, I can't simply push to their PR.Abrahan
@skywinder: No, is it possible is not a question, because that's too vague and broad in scope.. Of course it's possible. The question is whether it's appropriate, and that would depend on the project's guidelines about how it is used and whether they accept commits from new members of the project without review, neither of which is answerable by SO members. (And you are aware that you're posting your comment to a 3 1/2 year old comment of mine, right?)Aisha
A
6

Enabling repository maintainer permissions on existing pull requests

Pull request creators can give these permissions on each of their pull requests when they initially create a pull request from a fork or after they have created the pull request.

  • On GitHub, navigate to the main page of the upstream repository of your pull request.
  • In the list of pull requests, navigate to the pull request that you'd like to allow commits on.
  • In the right sidebar of your pull request, select Allow edits from maintainers. You can change these permissions at any time by unselecting this option.

More details on github help page: Allowing changes to a pull request branch created from a fork


TL;DR

Author of PR can modify an existing pull request to let repository maintainers make commits to your branch.

In order to allow you to make commits to others PR - the author has to set checkbox from the left: enter image description here

Abrahan answered 24/12, 2019 at 5:44 Comment(1)
How do I see if pull requester has enabled the checkbox? I want to edit his patch.Guimond
H
4

Assuming the original author is responsive enough, it’s always better to ask them to fix it (unless the change is an obvious typo fix, maybe). They might have a reason for writing it the way they did.

If the author isn’t responsive and you’re deciding whether to fix it in place or with a new commit, ask yourself which way the history reads more clearly. If the commit would introduce a regression, you should probably fix it in place (to avoid breaking bisectability). If it handles some cases and you just want to add more cases without significantly changing the existing code, it might be better to add a new commit.

If you do amend the existing commit in any way, make sure to leave a note in the commit message explaining what you changed. One typical style is to leave a note in square brackets, grouped with any Signed-off-by: lines (if applicable): [[email protected]: Refactor new cases into a function for clarity] For example: linux.git commit b44129b3.

via https://www.quora.com/GitHub-Is-it-bad-etiquette-to-change-someones-pull-request-before-committing

Hypothec answered 21/8, 2016 at 5:53 Comment(1)
your answer should say : only if you can push to the branch the PR is for! :)Wear

© 2022 - 2024 — McMap. All rights reserved.