Repository navigation
avoid a fetch when checkout a pull request - #4240
Conversation
Co-Authored-By: niik <[email protected]>
|
🔢 |
Justingoodin
left a comment
There was a problem hiding this comment.
Great job on this change it really goes.
| @@ -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.
This comment was marked as spam.
Sorry, something went wrong.
|
@agisilaos it looks like we have some repeated logic: specifically these lines: const gitStore = this.getGitStore(repository)
const localBranchName = `pr/${pullRequest.number}`
const doesBranchExist =
gitStore.allBranches.find(branch => branch.name === localBranchName) !=
nullMaybe 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 |
| // 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.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
|
Dropping |
|
@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... |
|
No need to do that @shiftkey! Will update the PR tonight. Didn't had time before because of exams and stuff |
|
Apologies for the delay on this PR @shiftkey! This PR is ready for review again and I'm back on track. 🦃 |
shiftkey
left a comment
There was a problem hiding this comment.
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.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
| // 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.
This comment was marked as spam.
Sorry, something went wrong.
|
🥖 |
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?