Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign upGitHub is where the world builds software
Millions of developers and companies build, ship, and maintain their software on GitHub — the largest and most advanced development platform in the world.
Find merge base when external PR branch has been deleted #1212
Conversation
Deleted branches can only be fetched by owner of repo. Fetch via special `refs/pull/<PR>/head` refspec to avoid this issue.
This avoids two fetches in the simple case where head is downstream of base.
|
I tested this with some PR's that I previously wasn't able to view, and they appear to load now with your fix. |
That is good news. I think this is by far the most common scenario. Someone submits a PR from and fork and deletes the branch once the PR has been accepted. I'm trying to think what other possible edge cases there might be. In the above case I was able to take advantage of the special I'm wondering what would happen if the PR base branch has been deleted (there isn't an equivalent Could you try the following:
|
The new version of this method takes a PR number.
I've done some further testing with this. If the PR base branch has been deleted, we can's simply do a fetch using the base branch name (or SHA). This seems to be the case whether or not the user has permissions to undelete the branch. As a workaround for this, I'm fetching the head branch using The problematic case would be if commits have been added to the base branch of the PR, before the PR is closed and the base branch deleted (not just the head branch, which would be the usual case). |
I've so far failed to produce this problematic case. Maybe it isn't an issue after all? |
The PR base branch might no longer exist, so we fetch using `refs/pull/<PR>/head` first. This will often fetch the base commits, even when the base branch no longer exists.
|
LGTM! Not done any extensive testing because @meaghanlewis appears to have done that, but the code changes look like they make sense. |
There was an issue when a PR has been submitted from a fork, the PR had been accepted and the owner deleted the PR branch. GitHub for Visual Studio was unable to find the original (now deleted) branch to show the PR details. This should allow those old PRs to still be displayed.
There are likely other edge cases that I need to think about (hence WIP for the moment).
Fixes #1190