Skip to content

Open a pull request from a GitHub.com PR page in your fork in Desktop - #9138

Merged
outofambit merged 39 commits into
developmentfrom
ku-open-pr-in-fork
Mar 4, 2020
Merged

outofambit merged 39 commits into
developmentfrom
ku-open-pr-in-fork

Conversation

@kuychaco

@kuychaco kuychaco commented Feb 19, 2020 •

Copy link
Copy Markdown
Contributor

Closes #9012

Description

This PR introduces behavior supportive of workflows where contributions are made from forks.

Previously, clicking the "open this in GitHub Desktop" link for a PR made from a fork on github.com would open the upstream repo, cloning if necessary. In order to make contributions locally from your fork, you would have to open your fork of the repo manually in the app.

With the changes introduced here, Desktop opens a user's fork repo when it makes sense to. We check the source of the PR, and if it is in Desktop (either as a fork or upstream) then we open the source repo and checkout the branch corresponding to the PR. If the source is not in Desktop, but the user has a fork in Desktop (ex: the source is another fork that doesn't belong to the user), we open the user's fork and checkout a branch corresponding to the PR. And in cases other than this we fallback to the current behavior of opening the upstream repo, cloning if needed.

/ cc @outofambit @billygriffin @tierninho

Behavior and test cases

Clone the following repos and open them in Desktop accordingly based on the setup instructions for each scenario:
Fork: https://github.com/kuychaco/urban-potato
Upstream: https://github.com/not-kuychaco/urban-potato

Note: start out each scenario with a repo focused in Desktop that has nothing to do with the fork or upstream being tested (to test that Desktop correctly switches to the correct repo).

Only fork in Desktop, no upstream:
Note: The fork opened in Desktop should be the PR source (ex: for not-kuychaco/urban-potato#2, https://github.com/kuychaco/urban-potato is the PR source so clone and open that fork in Desktop).
Before testing each of the following scenarios, make sure master branch is checked out in fork repo, and non-fork repo is the focused repo in Desktop (this tests that Desktop correctly switches to the fork repo, and correctly switches from the default branch to the source branch)

Fork AND upstream in Desktop:
Note: before testing each of the following scenarios, make sure master branch is checked out in fork and upstream repos, and non-fork and non-upstream repo is the focused repo in Desktop (this tests that Desktop correctly switches to the fork repo, and correctly switches from the default branch to the source branch)

Only upstream in Desktop, no forks:
Note: before testing each of the following scenarios, make sure master branch is checked out in upstream repo, and non-upstream repo is the focused repo in Desktop (this tests that Desktop correctly switches to the upstream repo, and correctly switches from the default branch to the source branch)

No fork or upstream in Desktop:

Release notes

Notes: [Added] Open a pull request from a GitHub.com PR page in your fork in Desktop

@kuychaco
kuychaco marked this pull request as ready for review February 24, 2020 21:44
@outofambit
outofambit self-requested a review February 25, 2020 19:32

@outofambit outofambit left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

left some initial thoughts. thanks @kuychaco!

Comment thread app/src/lib/stores/app-store.ts Resolved
Comment thread app/src/ui/dispatcher/dispatcher.ts Resolved
Comment thread app/src/ui/dispatcher/dispatcher.ts Outdated

await Promise.all(
repositories.map(async repo => {
if (repo instanceof Repository) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this check necessary? i think the types should already be guaranteed to be Repository

Comment thread app/src/ui/dispatcher/dispatcher.ts Resolved
@kuychaco
kuychaco requested a review from outofambit February 28, 2020 00:06
@billygriffin

Copy link
Copy Markdown
Contributor

I can't comment on the code specifically here, but I wanted to share a few thoughts on this.

First, since this is triggered from the current link "open this in GitHub Desktop" on dotcom pull request pages, I think it's reasonably likely that it isn't currently used a ton since that link is in a weird place and not super discoverable or well understood.

So while we're planning to ship this soon and it isn't likely to be used a ton right off the bat, we should think about it as something that we could hold up to people as something that will make it dramatically simpler to check out a PR locally from a PR page on dotcom, and it'll "just work" even if as many as 50% of GitHub users are using it every day.

Also, I think given the aspiration to make this workflow much more seamless and widely available to GitHub users, we should ensure our implementation of this works well and is performant on macOS and Windows, and still works really well even if people use large repos and/or have a bunch of repos in Desktop (say, 100 or so).

Hope that's helpful in thinking through it and testing, and obviously happy to chat if y'all have any questions or points of clarification.

@tierninho

tierninho commented Feb 28, 2020 •

Copy link
Copy Markdown
Contributor

Thanks for all the great steps! Here are my test results:

Only fork

Fork and upstream

Only upstream

No fork or upstream

  • open PR from upstream —> clone repository dialogue opens with upstream url preloaded
  • open PR from fork —> clone repository dialogue opens with fork url preloaded

Other

  • Added a test to see what happens when Desktop is closed, and the clone repository dialogue opens with respective url preloaded
  • Windows and OSX verified
  • initial tests for a large repo complete (Note: limited testing as I cannot use a real repo without creating fake PRs and disrupting users' work. Also, I cannot test of most large repos as I need write access.)

Notes

  • On Windows, it takes a long time to load the branch. The UI does not make it clear the operation is still in progress.

To Do:

  • Test using ~60 repos on Windows
  • Test using ~60 repos on OSX

@tierninho
tierninho self-requested a review February 28, 2020 20:36
tierninho
tierninho previously approved these changes Feb 28, 2020
@outofambit

Copy link
Copy Markdown
Contributor

thanks for the additional context @billygriffin!

@kuychaco i think we need to revisit our conversation last week about performance, specifically around

and still works really well even if people use large repos and/or have a bunch of repos in Desktop (say, 100 or so).

at that scale, running a git command in almost all of the user's repos isn't tenable, even if done serially. unfortunately the caching we have for remotes in gitstore currently won't help either since i think the user is unlikely to have opened more than a handful of their repos. let's talk through alternative approaches more (whether we use the GitHubRepository database or find something else).

@kuychaco

kuychaco commented Mar 3, 2020

Copy link
Copy Markdown
Contributor Author

Regarding #9138 (comment), @outofambit and I synced today and reworked the implementation so that instead of shelling out to git in order to get information for the remotes for each repository we are looking up remote information from the GitHubRepository database.

The performance gains were massive! Looking up remote information with over 100 repos on my Windows VM consistently took less than 200 ms, whereas looking up information for just 5 repos via shelling out to git took around 3 seconds.

A tradeoff we're making is the possibility of the remote info in the GitHubRepository database drifting out of sync with what's stored in Git and using stale info to determine which repository to open in Desktop. I'm investigating what situations this might be relevant in, and trying to understand just how/when the database gets populated and updated. Seeing as how remote information gets changed infrequently and that the consequences aren't super dire (the upstream repo might open in Desktop rather than a fork), I'm hoping that this tradeoff is easily worth making.

/cc @billygriffin

@kuychaco

kuychaco commented Mar 3, 2020

Copy link
Copy Markdown
Contributor Author

A tradeoff we're making is the possibility of the remote info in the GitHubRepository database drifting out of sync with what's stored in Git and using stale info to determine which repository to open in Desktop.

@billygriffin made the point that Desktop is already compromised in terms of remote urls drifting out of sync (see #3855). So we're not making things worse with this PR and feel good about shipping this implementation

@outofambit outofambit left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hey @kuychaco this is looking good. great work on the performance for this, too.

would it be possible to pull the git-store remotes type change into a separate pull request? i don't think it relates to this new implementation and i'd like to review it a little more carefully outside of this. after that, i think we're ready to merge! 🚀

@outofambit outofambit self-assigned this Mar 3, 2020

@outofambit outofambit left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks @kuychaco

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Cannot open a pull request from a GitHub.com PR page in your fork in Desktop

4 participants