Skip to content

Commit 03c16c9

Browse files
authored
Git - The git.sync command should use the git.rebaseWhenSync setting (microsoft#155511)
The git.sync command should use the git.rebaseWhenSync setting
1 parent e28a92f commit 03c16c9

File tree

4 files changed

+13
-22
lines changed

4 files changed

+13
-22
lines changed

extensions/git/src/actionButton.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -213,11 +213,9 @@ export class ActionButtonCommand {
213213
const behind = this.state.HEAD.behind ? ` ${this.state.HEAD.behind}$(arrow-down)` : '';
214214
const icon = this.state.isSyncInProgress ? '$(sync~spin)' : '$(sync)';
215215

216-
const rebaseWhenSync = config.get<string>('rebaseWhenSync');
217-
218216
return {
219217
command: {
220-
command: rebaseWhenSync ? 'git.syncRebase' : 'git.sync',
218+
command: 'git.sync',
221219
title: `${icon}${behind}${ahead}`,
222220
tooltip: this.state.isSyncInProgress ?
223221
localize('syncing changes', "Synchronizing Changes...")

extensions/git/src/commands.ts

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2575,17 +2575,16 @@ export class CommandCenter {
25752575
}
25762576
}
25772577

2578-
if (rebase) {
2579-
await repository.syncRebase(HEAD);
2580-
} else {
2581-
await repository.sync(HEAD);
2582-
}
2578+
await repository.sync(HEAD, rebase);
25832579
}
25842580

25852581
@command('git.sync', { repository: true })
25862582
async sync(repository: Repository): Promise<void> {
2583+
const config = workspace.getConfiguration('git', Uri.file(repository.root));
2584+
const rebase = config.get<boolean>('rebaseWhenSync', false) === true;
2585+
25872586
try {
2588-
await this._sync(repository, false);
2587+
await this._sync(repository, rebase);
25892588
} catch (err) {
25902589
if (/Cancelled/i.test(err && (err.message || err.stderr || ''))) {
25912590
return;
@@ -2598,13 +2597,16 @@ export class CommandCenter {
25982597
@command('git._syncAll')
25992598
async syncAll(): Promise<void> {
26002599
await Promise.all(this.model.repositories.map(async repository => {
2600+
const config = workspace.getConfiguration('git', Uri.file(repository.root));
2601+
const rebase = config.get<boolean>('rebaseWhenSync', false) === true;
2602+
26012603
const HEAD = repository.HEAD;
26022604

26032605
if (!HEAD || !HEAD.upstream) {
26042606
return;
26052607
}
26062608

2607-
await repository.sync(HEAD);
2609+
await repository.sync(HEAD, rebase);
26082610
}));
26092611
}
26102612

extensions/git/src/repository.ts

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -948,7 +948,6 @@ export class Repository implements Disposable {
948948
|| e.affectsConfiguration('git.untrackedChanges', root)
949949
|| e.affectsConfiguration('git.ignoreSubmodules', root)
950950
|| e.affectsConfiguration('git.openDiffOnClick', root)
951-
|| e.affectsConfiguration('git.rebaseWhenSync', root)
952951
|| e.affectsConfiguration('git.showActionButton', root)
953952
)(this.updateModelState, this, this.disposables);
954953

@@ -1510,13 +1509,8 @@ export class Repository implements Disposable {
15101509
}
15111510

15121511
@throttle
1513-
sync(head: Branch): Promise<void> {
1514-
return this._sync(head, false);
1515-
}
1516-
1517-
@throttle
1518-
async syncRebase(head: Branch): Promise<void> {
1519-
return this._sync(head, true);
1512+
sync(head: Branch, rebase: boolean): Promise<void> {
1513+
return this._sync(head, rebase);
15201514
}
15211515

15221516
private async _sync(head: Branch, rebase: boolean): Promise<void> {

extensions/git/src/statusbar.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -145,10 +145,7 @@ class SyncStatusBar {
145145
text += this.repository.syncLabel;
146146
}
147147

148-
const config = workspace.getConfiguration('git', Uri.file(this.repository.root));
149-
const rebaseWhenSync = config.get<string>('rebaseWhenSync');
150-
151-
command = rebaseWhenSync ? 'git.syncRebase' : 'git.sync';
148+
command = 'git.sync';
152149
tooltip = this.repository.syncTooltip;
153150
} else {
154151
icon = '$(cloud-upload)';

0 commit comments

Comments
 (0)