Repository navigation
Display PRs from upstream repository in forks - #9340
Conversation
|
@ampinsk any feedback on the sizing of the PR list header? A couple of considerations:
Things I think we could do:
|
tierninho
left a comment
There was a problem hiding this comment.
The functionality works well, but I spotted a bug. Anytime you create/close a PR from the forked repo, the PR list in Desktop toggles between these two views:
Reproduce:
- View all PRs in a forked repo on Desktop (first pic)
- Create/close a PR from on the forked repo on Github.com
- Click the PR load button in the PR list in Desktop
- PR list shows no pull requests (second pic)
While doing above, I noticed some weird submodule and object errors, which I suspect has to do with a PR that shouldn't be there. PR #4is missing from Github.com but is present in the list :



Also, just to be clear, for any forked repo on Desktop, we are only going to surface PRs from the upstream repo? No PRs will be shown in only on the forked repo on Github.com?
Thanks for reporting!! I've been able to reproduce and looking into it!
Exactly. This makes me think about what happens when the user doesn't have the parent repo as an |
After some investigation, it looks like this was an existing issue, which before this PR used to happen in the opposite way: when a PR was created/closed/updated on the upstream repository, the list of PRs went blank. I'm looking into the logic that updates the list of PRs to find where the issue comes from. |
567cc82 to
f8f54b5
Compare
|
@tierninho I've fixed the issue that you found in 32a4222 ! That was a really good catch!! |
f8f54b5 to
32a4222
Compare
|
In 6760ddc I've changed a bit the logic to fetch PRs to only fetch the pull requests from the upstream repository when working on a fork. I found that by fetching both the upstream and origin PRs but only showing the upstream ones some issues caused some issues on the logic that tries to find the correspondant PR of a branch (if for some reason the same branch was used for both a PR on the upstream and on the fork repo the Ui went a bit nuts). Also, with this change we're fetching a bit less data. |
outofambit
left a comment
There was a problem hiding this comment.
overall, this looks great! @rafeca and i are going to talk through the implications of the refactor in pull-request-coordinator tomorrow to make sure we don't regress anything tangentially related elsewhere in the app, but i think it is likely a great solution.
Bug fix looks good ✅
Let me know if there are any vulnerable areas that may need testing post the meeting, as I'd be happy to explore more. |
Good point! gonna check how do we do it in other places and follow the same pattern |
I've synced with @outofambit and she mentioned two areas of potential issues:
I've been able to find one issue (actually it's a discrepancy) between the behaviour of "open this in GitHub Desktop" button and clicking on a PR from the PRs list in desktop: When opening a PR created to the upstream repository from a branch that also lives on the upstream repository, the behaviour is different between the two:
So after using the "open this in GitHub Desktop" button and clicking on the same PR from the PRs list on Desktop, we end up with the following local branches on $ git branch -vv
pr/1 774a131 [github-desktop-rafeca/rafeca-patch-1] assaas
rafeca-patch-1 774a131 [upstream/rafeca-patch-1] assaas$ git remote -v
github-desktop-rafeca https://github.com/rafeca/test-forks.git (fetch)
github-desktop-rafeca https://github.com/rafeca/test-forks.git (push)
origin https://github.com/rafeca-fork/test-forks.git (fetch)
origin https://github.com/rafeca-fork/test-forks.git (push)
upstream https://github.com/rafeca/test-forks.git (fetch)
upstream https://github.com/rafeca/test-forks.git (push)Based on this, I think that the behaviour of the "open this in GitHub Desktop" integration is the correct one (we don't need to duplicate the upstream remote), so I'm going to try to change the logic of the PRs list to match it. |
|
I've been able to fix the issue described in #9340 (comment) via 0a33f90 Now the behaviour between the dotcom integration and the PRs list is consistent. Before: After: |
|
@rafeca For above, possible to share the reproduction steps? I ran into a fast-forward error (I think its an existing issue) and I wanted to make sure I was testing the steps in the right way. Note there was some recent PR work done in this area, see here: #9138 I do not believe we have released it yet. |
I've used the following setup with a repository and two forks, where there are 3 PRs, each of these based on a branch from each of the repositories: Then I add one of the forked repositories to GitHub Desktop and do the following actions for each of the PRs:
I expect both actions to do exactly the same, no matter which of these gets done first. The expected result is to checkout the branch from either the origin or upstream repository (in the case of
Do you remember under which conditions this happened? I haven't run into this yet |
Yes, this occurred when I clicked the Based on the steps you outlined above, I will recreate the entire setup from scratch and retest. |
Confirming the steps you outlined above result in the expected actions. The "open this in GitHub Desktop" link and the clicking on the PR from inside GitHub Desktop led to the same result. ✅ |
I think I know what happened here: local branches for PRs that are started on forks are named This happens with kuychaco/urban-potato#3 and not-kuychaco/urban-potato#3 . If you try to checkout both of these PRs from dotcom you'll probably get an error for the second one (I guess this even happens in production). Right now this kind of problems are a little bit hard to fix, since the logic to checkout a PR is duplicated (the logic for checking out a PR internally is not the same as the one used by the interceptor in dotcom). I can try to unify this logic so it's going to be easier to make fixes (plus the functionality will be uniform between both). |
outofambit
left a comment
There was a problem hiding this comment.
this is great @rafeca! left a couple notes and questions inline but i don't think any of them are too major.
| const matches = new Array<RepositoryWithGitHubRepository>(), | ||
| forks = new Array<RepositoryWithGitHubRepository>() | ||
| const matches = new Array<RepositoryWithGitHubRepository>() | ||
|
|
||
| for (const r of repositories) { | ||
| if (r.gitHubRepository.dbID === dbID) { | ||
| matches.push(r) | ||
| } else if ( | ||
| r.gitHubRepository.parent !== null && | ||
| r.gitHubRepository.parent.dbID === dbID | ||
| ) { | ||
| forks.push(r) | ||
| matches.push(r) | ||
| } | ||
| } | ||
|
|
||
| return { matches, forks } | ||
| return matches |
There was a problem hiding this comment.
i think this can compacted down now to
return repositories.filter(r => r.gitHubRepository.dbID === dbID)since we are using getNonForkGitHubRepository(), i think we no longer want to match the GitHubRepository and its parent, which could introduce strange behavior if a fork of a fork (a grand-fork, if you will) ends up in this code path. does that sound right? i think getNonForkGitHubRepository() means we don't have to worry about multiple GitHubRepositories here anymore.
There was a problem hiding this comment.
I've thought a bit about this and indeed I think that the current code will cause issues with grandforks, but I think that it should be changed to:
return repositories.filter(
repository => getNonForkGitHubRepository(repository).dbID === dbID
)The reasoning is that this method is used to map GitHubRepository object to any Repository
used to calculate which Repository objects need to be updated after receiving an updated list of PRs. Since we fetch the list of PRs of a Repository by getting its GitHubRepository via getNonForkGitHubRepository(), we need to use the same method when trying to map back a GitHubRepository to the potential list of Repository objects. Does this make sense?
However, this raises a different question about which PRs to show when opening a grandfork. Currently if we have a repo, a fork and a grandfork, when opening grandfork on Desktop the PRs from fork will be shown.
I feel that it would make more sense to show the PRs from repo, but I don't have strong opinions about it. @billygriffin do you have any thoughts about this? (if we decide to change this we can do it in a separate PR).
There was a problem hiding this comment.
used to calculate which
Repositoryobjects need to be updated after receiving an updated list of PRs. Since we fetch the list of PRs of aRepositoryby getting itsGitHubRepositoryviagetNonForkGitHubRepository(), we need to use the same method when trying to map back aGitHubRepositoryto the potential list ofRepositoryobjects. Does this make sense?
@rafeca oh yes, great point! i agree that this is the right solution for this method
return repositories.filter( repository => getNonForkGitHubRepository(repository).dbID === dbID )
thus far, we've explicitly tried to avoid allowing any repo to cause parent traversals more than one level (ie no repo should never have info/data from a repo that is a grandparent or higher), but also i don't think grandforks are a common enough use case to worry about beyond "will the app crash?". this logic maintains that line which i think is enough for now, but happy to reconsider more if you or @billygriffin have more thoughts!
Co-Authored-By: evelyn masso <[email protected]>
Co-Authored-By: evelyn masso <[email protected]>
…t of a githubrepository
c04d94e to
b964a3b
Compare
|
Thanks for the questions @rafeca! I don't think my comment here changes anything on this PR, but I just wanted to summarize the conversation I had with @outofambit about this for posterity in case we're revisiting this in the future or trying to understand it better. Our assumption is that if you're on a fork, we only care about the parent of the fork - so we only go one level up, and never traverse through multiple forks. If your fork's parent repo also happens to be a fork, that's irrelevant to how things work for you in Desktop. |
|
Thanks everyone for your comments! Gonna merge this one! 😃 |











Closes #6383
Description
This PR changes the filtering logic of the PRs list to display the pull requests made on the upstream repository when the current repository is a fork.
As part of this PR, I've removed the logic that adds a link to the list of PRs on the upstream repository when there are no PRs (which was added in #8965). Now, the logic is not needed since the shown PRs are the ones in the upstream repository already.
Instead of removing that logic, we can also change it to show a link to the PRs page of the forked repository, but I feel that this would create more confusion than help users (since the most normal use case is to have PRs on the upstream repo).
Screenshots
Test plan
On a forked repository:
On a non-forked repository:
Release notes
Notes: [Improved] Show the list of pull requests from the upstream repository on forks