Change the target branch of an existing pull request to another fork - github

I forked a repository A.. say B
I created a pull request from branch B.branch1 TO B.master
The pull request got some review comments.. I resolve them and so on..
I now want to change the base from B.master to A.master(parent repo)
How can I do this in case of an existing PR?
Since I am not seeing the option to change the base branch to another repo..
I know I can create a new pull request but that would lose all the review conversation.

A pull request is an entity that is tied to the repository it was created in. Other repositories (even if forked from the original repository) may have other rules regarding pull requests, code reviews or repository access in general. The developers giving you a code review in fork A might even not be able to do so in fork B.
Therefore you can not move your pull request to another repository.
I suggest you close your current pull request and open a new one. You can link to the old PR and explain the situation so people can still see the code review conversation that was going on in the original PR.

Related

Why does GitHub API commit object point to a pull request that does not contain the commit?

I created a script that, from a commit in a repository, tries to figure if it belongs to a pull request and, in that case, will return all commits in that pull request. Debugging the output, I found that some commit objects refer to a pull request, but the pull request object does not contain such commits.
Let me do a practical example:
In the GitHub Repo
https://github.com/DemocracyClub/yournextrepresentative
there is the commit
0722309a9c242aac28d2cb33798abbd18b233aa0
that belongs to the pull request
https://github.com/DemocracyClub/yournextrepresentative/pull/55
So, in the GitHub website seems to be all good. No reverts, no amends, no weird git functions that would create a mess in the git history.
So, GitHub API correctly identifies the pull request with the URL
https://api.github.com/repos/DemocracyClub/yournextrepresentative/commits/0722309a9c242aac28d2cb33798abbd18b233aa0/pulls
and gives me as link of PR's commits the following one:
https://api.github.com/repos/DemocracyClub/yournextrepresentative/pulls/55/commits
BUT if you look in that link, there is no reference to the commit
0722309a9c242aac28d2cb33798abbd18b233aa0
Any idea of why is this happening?

How to permanently delete an abandoned pull request in Azure DevOps?

We have an abandoned pull request which we would like to permanently remove. How can this be done? There doesn't seem to be a 'delete' or 'remove' option. Thanks.
How to permanently delete an abandoned pull request in Azure DevOps?
Sorry for any inconvenience.
I'm afraid there is no such way to permanently delete an abandoned pull request in Azure DevOps at this moment.
Microsoft thinks that data retention and traceability is important to a lot of our customers - it's not as simple as always providing CRUD operations for every artifact. But more and more customers are requesting delete pull requests, or at least the ability to delete abandoned pull requests.
Just like Spevacus comment, this feature is under Review, and Microsoft replied:
Your suggestion has been queued up for prioritization. Feature
suggestions are prioritized based on the value to our broader
developer community and the product roadmap. We may not be able to
pursue this one immediately, but we will continue to monitor it up to
90 days for community input
You could vote and add your comments for this feedback. When there are enough community votes and comments with reliable feedback, the product team members will take this feature request seriously.
Hope this helps.
While an abandoned pull request cannot currently be permanently deleted in Azure DevOps, it can be closed. The comment/update history will remain, but the pull request will not show up in the "Abandoned" list.
Delete the pull request's source branch if it still exists.
Create a new branch based on the main branch with the same name as the original source branch.
Reactivate the pull request
Close the pull request
The new status will be "Completed"
I also wanted to do this so that I wouldn't have an open pull request showing in open pull requests forever. So you can't delete the pull request, but at least you can get it marked as closed/completed. As a workaround until the delete feature is added you can do the following:
Create a temporary branch, let's say we call it "DeleteMe"
In your pull request, change the destination branch to DeleteMe
Complete the pull request.
In DeleteMe branch, if you want this updated with any new changes then you can make it updated to current. Otherwise just make any change to a file. You can add in a space on a comment for instance.
Create a new pull request to merge DeleteMe back into the original branch.
Complete the pull request and delete the DeleteMe branch.
Now the pull request will be closed/completed.
My priority was to prevent an inadvertent merge to Prod.
Hence you can:
add yourself as reviewer, then Reject; Save
as above, change the target branch to a dummy branch; Save
place [DELETED} at start of the title; Save
set the PR to Draft - that resets your rejected review
https://learn.microsoft.com/en-us/azure/devops/release-notes/2018/sprint-143-update#draft-pull-requests
or "Abandon" the PR

Can I modify someone else's pull request and push it back in its branch?

GitHub explains you can fork, modify, commit, push and trigger a pull request. They also explain that you can still modify, commit, push and the request is updated on the website.
I would like to know if it is possible to do the exact same thing but not being the author of the fork? I am the owner of a repo with pull requests I would like to correct myself but still discuss afterwards... I was trying to push my changes into the author's repo (thinking some right access would be calculated) but the access is denied.
When creating a pull request (PR) on GitHub, you can select the option that maintainers are allowed to commit changes to your PR. You can also do this after the PR is already created: In the detail view of the PR, on the lower right, under "Unsubscribe", "participants". So if you want to commit to a PR of someone else on a GitHub repository you own: Ask them to give you this permission.
From the GitHub help pages: "Only pull request creators can give upstream repository maintainers, or those with push access to the upstream repository, permission to make commits to their pull request's compare branch." (Allowing changes to a pull request branch created from a fork)
Unfortunately, as far as I know, in order for someone to commit to the PR, you would have to give them write access to the repository and can't just selectively give them write access to the PR.
Official GitHub support answer at this date
It would be up to the owner of the forked repository to decide if they
want to pull your changes into their fork.
You would modify their Pull Request and merge it into your repository.
You could then request them to pull down the changes you have made
into his fork which would synch his fork with yours.

Suppress Github references from commit message to PR

I have a branch in which I (automatically) apply some patches from pull requests.
I do so by committing the PRs' diff and have a commit message like this one
PATCHED | Apply patch https://github.com/randombit/botan/pull/386
Now every time I do that in a commit that is hosted on Github, the PR gets referenced.
In my case this does not add any value to the PR itself, as it is referenced multiple times and not part of any discussion. Can I suppress this referencing from my commit message?
This is what happens when I create a bunch of different commits that have a PR url in the commit message:
Here you can verify that totally unrelated commits create references just by commit message parsing:
https://github.com/webmaster128/dummy-github-ref-test
https://github.com/randombit/botan/pull/386
One simple thing you could do is, not write the reference to the PR # in a way that github will parse it as such.
So, instead of
https://github.com/randombit/botan/pull/386
or
#386
you could try writing just
Pull request number 386
The fanciest thing that I could imagine doing is,
https://myserver.com/botan/pull/386
and then setup your server to redirect such queries to your github page... That way, you still get a clickable hyperlink in the commit messages, but you subvert github's referencing. It's a lot more effort than the alternatives though.
Edit: This is the most complete documentation I could find about github references in gfm. Here is some additional info about the parsing they do for 'closing issues via commit messages'. I couldn't find any more detailed documentation.
Now every time I do that in a commit that is hosted on Github, the PR gets referenced.
This is what pull request is all about, any change made to the given branch is added to the PR and any contributor is being notified about it.
You will keep getting notification until you will do one of the following
Close the pull request
Once the pull request is closed it will not track changes made to the given branch
Unsubscribe
Click on unsubscribe option in the pull request
Close the pull request
Close the pull request by accepting or declining it

On Github, how do I find what pull requests individual file commits belong to

On GitHub, I can see the history of commits of a file under .../commits/master/filename. What I want to know is, assuming these changes were merged into master via Pull Requests, what Pull Request did the change come from? Is there an easy way to do that?
Since Oct. 13, 2014, this should be easier:
Linking merged pull requests from commits
We've been including the containing branches and tags on commit pages to give you more context around changes. Now, commits in a repository's default branch will also show you the pull request that introduced them.
In the pull request, you can see the discussion around why the commit was introduced, and get a clearer picture of the reason for the change.
As always, if you know the commit SHA, you can skip the commit page and search for the pull request directly.
For instance:
You can see for the file hakimel/reveal.js/plugin/markdown/markdown.js, my contribution now comes with a reference to the PR #734 it originated.
Note however that:
neither GitHub Get single commit API, like https://api.github.com/repos/hakimel/reveal.js/commits/f2097417daca80b2caaed2661ee646e861d789c8
nor GitHub Get a commit API, like https://api.github.com/repos/hakimel/reveal.js/git/commits/f2097417daca80b2caaed2661ee646e861d789c8
will include the reference to the PR...