Repository navigation
Fetch default remote if it differs from the current - #4057
Merged
Merged
Conversation
We've got all the info, why not
shiftkey
reviewed
Feb 21, 2018
| // We need to fetch FIRST because someone may have created a PR since the last fetch | ||
| await this._fetch(repository, FetchType.UserInitiatedTask) | ||
| 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.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
shiftkey
approved these changes
Feb 22, 2018
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The global fetch method only fetches the 'current' (i.e. the remote derived from the tracking branch of the current branch). This changes it so that it fetches the distinct set of the default, current, and upstream remotes.
This also changes the behavior of
_checkoutPullRequestso that it always fetches the remote we're switching to first. As noted in the comments I think we can relax this a little going forward.There's one potential race condition in here that I don't plan on fixing now. The previous
_checkoutPullRequestimplementation did a fetch without wrapping it in thewithPushPulloperation that guarantees we only run one network operation at a time. So there's a potential risk here that we could silently skip the fetch if a background fetch happens to be running at the same time. That risk seems like an improvement over potentially running two fetches concurrently and risking two git processes fighting over resources.As an additional improvement this cuts down on the number of times we need to shell out to git to get all configured remotes by consolidating them all into one method.
Fixes #4056