Skip to content

avoid a fetch when checkout a pull request - #4240

Merged
shiftkey merged 17 commits into
desktop:masterfrom
agisilaos:agis/avoid-a-fetch-is-cool
Apr 15, 2018
Merged

shiftkey merged 17 commits into
desktop:masterfrom
agisilaos:agis/avoid-a-fetch-is-cool

Conversation

@agisilaos

@agisilaos agisilaos commented Mar 14, 2018 •

Copy link
Copy Markdown
Member

Fixes: #4068

My only improvement to this PR would be to make the lines of the variables I added reusable but I'm not sure how I can do this. We can leave it as it is as well. What's your thinking on that?

@agisilaos

Copy link
Copy Markdown
Member Author

🔢

@nerdneha nerdneha self-assigned this Mar 14, 2018
@nerdneha nerdneha added the ready-for-review Pull Requests that are ready to be reviewed by the maintainers label Mar 14, 2018
@agisilaos agisilaos changed the title avoid a fetch when checkout out a pull request avoid a fetch when checkout a pull request Mar 14, 2018

@Justingoodin Justingoodin 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.

Great job on this change it really goes.

Comment thread app/src/lib/stores/app-store.ts Outdated
@@ -3279,7 +3279,13 @@ export class AppStore extends TypedBaseStore<IAppState> {
const defaultRemote = await getDefaultRemote(repository)
// TODO: I think we could skip this fetch if we know that we have the branch locally

This comment was marked as spam.

@nerdneha

Copy link
Copy Markdown
Contributor

@agisilaos it looks like we have some repeated logic:
lines 3282-3286
seem to match
lines 3322-3327

specifically these lines:

      const gitStore = this.getGitStore(repository)

      const localBranchName = `pr/${pullRequest.number}`
      const doesBranchExist =
        gitStore.allBranches.find(branch => branch.name === localBranchName) !=
        null

Maybe we could pull some of that logic up since we have it repeated? It doesn't look like it's extractable into a private method since one of the condition cases uses localBranchName so maybe pulling it up is better
(could i get a second pair of 👀 on this?)

Comment thread app/src/lib/stores/app-store.ts Outdated
// already. That way we'd match the behavior of checking out a branch.
if (defaultRemote) {
const gitStore = this.getGitStore(repository)
const localBranchName = `pr/${pullRequest.number}`

This comment was marked as spam.

This comment was marked as spam.

This comment was marked as spam.

@shiftkey shiftkey self-assigned this Mar 15, 2018
@agisilaos

Copy link
Copy Markdown
Member Author

Will look into that today and follow up with questions etc, thank you for the detailed comments @shiftkey, @nerdneha! 💯

@nerdneha nerdneha removed their assignment Mar 17, 2018
@shiftkey shiftkey removed the ready-for-review Pull Requests that are ready to be reviewed by the maintainers label Mar 21, 2018
@shiftkey

Copy link
Copy Markdown
Member

Dropping ready-for-review because we're still confirming this is the right approach...

@shiftkey shiftkey removed their assignment Mar 25, 2018
@shiftkey

Copy link
Copy Markdown
Member

@agisilaos given we've figured out the approach but this has sat for a while without any follow up, could we close this out and update the issue to reference this discussion? You're more than welcome to come back to it when you've got time with a fresh PR, I'm just trying to get on top of our outstanding PRs...

@agisilaos

Copy link
Copy Markdown
Member Author

No need to do that @shiftkey! Will update the PR tonight. Didn't had time before because of exams and stuff

@agisilaos

Copy link
Copy Markdown
Member Author

Apologies for the delay on this PR @shiftkey! This PR is ready for review again and I'm back on track. 🦃

@shiftkey shiftkey self-assigned this Apr 8, 2018

@shiftkey shiftkey 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.

This is looking good @agisilaos. A couple of minor things and I think this is good to go.

gitStore.allBranches.find(branch => branch.name === remoteRef) != null

// only try a fetch here if we can't find the ref
if (!remoteRefExists) {

This comment was marked as spam.

This comment was marked as spam.

Comment thread app/src/lib/stores/app-store.ts Outdated
// already. That way we'd match the behavior of checking out a branch.
// if we don't have a default remote here, it's probably going
// to just crash and burn on checkout, but that's okay
if (defaultRemote) {

This comment was marked as spam.

@agisilaos

Copy link
Copy Markdown
Member Author

🥖

@shiftkey
shiftkey merged commit dfdde32 into desktop:master Apr 15, 2018
@agisilaos
agisilaos deleted the agis/avoid-a-fetch-is-cool branch April 16, 2018 13:12
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.

4 participants