Skip to content

Commit

Permalink
Respect git's pullBeforeCheckout setting for checking out default bra…
Browse files Browse the repository at this point in the history
…nch (#4744)

Fixes #4450
  • Loading branch information
alexr00 authored Apr 19, 2023
1 parent ba0bac0 commit a34f440
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
1 change: 1 addition & 0 deletions src/common/settingKeys.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,5 @@ export const SHOW_PULL_REQUEST_NUMBER_IN_TREE = 'showPullRequestNumberInTree';

// git
export const GIT = 'git';
export const PULL_BEFORE_CHECKOUT = 'pullBeforeCheckout';
export const OPEN_DIFF_ON_CLICK = 'openDiffOnClick';
7 changes: 6 additions & 1 deletion src/github/folderRepositoryManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import { commands, contexts } from '../common/executeCommands';
import Logger from '../common/logger';
import { Protocol, ProtocolType } from '../common/protocol';
import { GitHubRemote, parseRepositoryRemotes, Remote } from '../common/remote';
import { PULL_BRANCH } from '../common/settingKeys';
import { GIT, PULL_BEFORE_CHECKOUT, PULL_BRANCH } from '../common/settingKeys';
import { ITelemetry } from '../common/telemetry';
import { EventType, TimelineEvent } from '../common/timelineEvent';
import { fromPRUri, Schemes } from '../common/uri';
Expand Down Expand Up @@ -2167,6 +2167,11 @@ export class FolderRepositoryManager implements vscode.Disposable {
return;
}

// respect the git setting to fetch before checkout
if (vscode.workspace.getConfiguration(GIT).get<boolean>(PULL_BEFORE_CHECKOUT, false) && branchObj.upstream) {
await this.repository.fetch({ remote: branchObj.upstream.remote, ref: `${branchObj.upstream.name}:${branchObj.name}` });
}

if (branchObj.upstream && branch === branchObj.upstream.name) {
await this.repository.checkout(branch);
} else {
Expand Down

0 comments on commit a34f440

Please sign in to comment.