Skip to content

Unify logic to checkout a pull request - #9382

Merged
niik merged 21 commits into
developmentfrom
techdebt/unify-checkout-pr-logic
Sep 2, 2020
Merged

niik merged 21 commits into
developmentfrom
techdebt/unify-checkout-pr-logic

Conversation

@rafeca

@rafeca rafeca commented Mar 27, 2020 •

Copy link
Copy Markdown
Contributor

Closes #9439
Closes #9593

This PR is based off #9340

Description

This PR contains a small refactor to unify the logic to checkout a PR from GitHub.

Currently, there are two ways to checkout a PR:

  1. From the "Pull Requests" list tab that appears on the GitHub Desktop app.
    Screenshot 2020-03-27 at 15 42 47
  2. From github.com when navigating to a Pull Request page:
    Screenshot 2020-03-27 at 15 43 15

Each of these entry points has its own logic, which causes some inconsistencies between them (as we found in #9340 (comment)).

Test cases

I've tried to follow the test cases that were written in #9138, but couldn't check every single one of them.

Release notes

Notes: no-notes

@rafeca rafeca added the tech-debt Issues and pull requests related to addressing technical debt or improving the codebase label Mar 27, 2020
Comment thread app/src/lib/stores/app-store.ts Resolved
Comment on lines +1425 to +1486
for (const repository of repositories) {
if (this.doesRepositoryMatchUrl(repository, headUrl)) {
return repository
}
}

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I wanted to use repositories.find() here but TypeScript's Array.prototype.find is not capable to infer that the found element can only be of type Repository | null.

This comment was marked as spam.

@tierninho

Copy link
Copy Markdown
Contributor

Ran through almost all the tests here #9138 (comment) and only one stood out -- the rest passed.

PR in upstream with upstream as source —> opens fork in Desktop and source branch is checked out (not-kuychaco/urban-potato#3)

To set up:

Expected: branch opens in forked repo
Actual: the Clone Repository modal opens

@rafeca

rafeca commented Mar 30, 2020

Copy link
Copy Markdown
Contributor Author

Ran through almost all the tests here #9138 (comment) and only one stood out -- the rest passed.

Thanks! ✨✨

I fixed the issue in the last commit. This was caused because the URL that's opened in that case is x-github-client://openRepo/https://github.com/not-kuychaco/urban-potato?branch=kuychaco-patch-1, when it should be something like x-github-client://openRepo/https://github.com/not-kuychaco/urban-potato?pr=3. I fixed the issue in Desktop, but I'll try to change the logic in dotcom to make the URLs from all PRs consistent.

@tierninho
tierninho self-requested a review March 31, 2020 00:05
tierninho
tierninho previously approved these changes Mar 31, 2020
@rafeca
rafeca force-pushed the feature/show-prs-on-upstream branch from c04d94e to b964a3b Compare April 2, 2020 12:31
@rafeca
rafeca force-pushed the techdebt/unify-checkout-pr-logic branch from 8935495 to 88ac1b6 Compare April 2, 2020 12:32
@rafeca
rafeca requested a review from outofambit April 2, 2020 13:12
@rafeca
rafeca dismissed tierninho’s stale review April 3, 2020 08:55

The base branch was changed.

@rafeca
rafeca changed the base branch from feature/show-prs-on-upstream to development April 3, 2020 08:55
@rafeca
rafeca requested a review from niik May 20, 2020 17:28
@rafeca
rafeca force-pushed the techdebt/unify-checkout-pr-logic branch from 88ac1b6 to 1bb472c Compare May 25, 2020 16:43
amir4toshiba
amir4toshiba previously approved these changes Jun 6, 2020

@valhalla712 valhalla712 left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

!!!!!

@niik niik left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Noticed I had typed up some review notes weeks ago so I figured I might as well merge and drop these in. Note that this is a pretty superficial initial review

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 Resolved
Comment thread app/src/ui/dispatcher/dispatcher.ts Resolved
Comment thread app/src/ui/dispatcher/dispatcher.ts Resolved
Comment thread app/src/ui/dispatcher/dispatcher.ts Resolved
Comment thread app/src/ui/dispatcher/dispatcher.ts Resolved
rafeca and others added 3 commits August 21, 2020 16:23
Ass55tyee
Ass55tyee previously approved these changes Aug 21, 2020
@Ass55tyee

This comment has been minimized.

@desktop desktop temporarily blocked Ass55tyee Aug 21, 2020
@tierninho

tierninho commented Aug 21, 2020 •

Copy link
Copy Markdown
Contributor

Hey, I was looking to test some of the scenarios here, but is there a merge conflict that needs resolving?

Your branch [development]and 'origin/techdebt/unify-checkout-pr-logic' have diverged,
and have 12 and 1639 different commits each, respectively.
  (use "git pull" to merge the remote branch into yours)
fatal: Not possible to fast-forward, aborting.

@rafeca
rafeca requested a review from niik August 27, 2020 10:44
@niik

niik commented Aug 27, 2020

Copy link
Copy Markdown
Member

Hey, I was looking to test some of the scenarios here, but is there a merge conflict that needs resolving?

@tierninho I think this is because @rafeca force-pushed the branch at one point

image

Unfortunately for you it means it's gonna be a bit trickier to get up to date. Either you delete the branch locally and check it out again or you can run the following command in your terminal

git reset --hard origin/techdebt/unify-checkout-pr-logic

@rafeca

rafeca commented Aug 27, 2020

Copy link
Copy Markdown
Contributor Author

@tierninho I think this is because @rafeca force-pushed the branch at one point

Ups, sorry about that @tierninho ! and thanks @niik for figuring it out!

@niik niik left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Hey @rafeca, this is starting to look really good. Thanks so much for biting the bullet and cleaning this up. I've got a few purely stylistic suggestions below and then some changes that I've made as I've been reviewing that I intend to open as a separate PR once this has merged so that we can review them on their own.

Comment thread app/src/ui/dispatcher/dispatcher.ts Resolved
Comment thread app/src/ui/dispatcher/dispatcher.ts Resolved
Comment thread app/src/ui/dispatcher/dispatcher.ts Resolved
Comment thread app/src/ui/dispatcher/dispatcher.ts Resolved
Comment thread app/src/ui/dispatcher/dispatcher.ts Resolved
@rafeca
rafeca requested a review from niik August 31, 2020 12:14

@niik niik left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Great work cleaning this up @rafeca!

@niik
niik merged commit 506a2fa into development Sep 2, 2020
@niik
niik deleted the techdebt/unify-checkout-pr-logic branch September 2, 2020 12:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

tech-debt Issues and pull requests related to addressing technical debt or improving the codebase

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Possible error with remotes when you want to checkout upstream PRs on Desktop Unify logic to checkout PRs

6 participants