Skip to content

Commit 8978d17

Browse files
committed
Fixes #1163 - forces rebase ui when cmd invoked
1 parent 7364664 commit 8978d17

File tree

2 files changed

+39
-5
lines changed

2 files changed

+39
-5
lines changed

src/commands/git/rebase.ts

Lines changed: 34 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
'use strict';
2+
import { env } from 'vscode';
23
import { Container } from '../../container';
34
import { GitBranch, GitLog, GitReference, GitRevision, Repository } from '../../git/git';
45
import {
@@ -71,8 +72,38 @@ export class RebaseGitCommand extends QuickCommand<State> {
7172
return false;
7273
}
7374

74-
execute(state: RebaseStepState) {
75-
return state.repo.rebase(...state.flags, state.reference.ref);
75+
async execute(state: RebaseStepState) {
76+
let configs: string[] | undefined;
77+
if (state.flags.includes('--interactive')) {
78+
await Container.rebaseEditor.enableForNextUse();
79+
80+
let editor;
81+
if (env.remoteName) {
82+
switch (env.appName) {
83+
case 'Visual Studio Code - Insiders':
84+
editor = 'code-insiders --wait --reuse-window';
85+
break;
86+
case 'Visual Studio Code - Exploration':
87+
editor = 'code-exploration --wait --reuse-window';
88+
break;
89+
default:
90+
editor = 'code --wait --reuse-window';
91+
break;
92+
}
93+
} else {
94+
let execPath = process.execPath.replace(/\\/g, '/');
95+
if (process.platform === 'darwin') {
96+
const index = execPath.indexOf('.app/Contents/');
97+
if (index !== -1) {
98+
execPath = `${execPath.substring(0, index)}.app/Contents/MacOS/Electron`;
99+
}
100+
}
101+
editor = `'${execPath}' --wait --reuse-window`;
102+
}
103+
104+
configs = ['-c', `sequence.editor="${editor}"`];
105+
}
106+
return state.repo.rebase(configs, ...state.flags, state.reference.ref);
76107
}
77108

78109
protected async *steps(state: PartialStepState<State>): StepGenerator {
@@ -189,7 +220,7 @@ export class RebaseGitCommand extends QuickCommand<State> {
189220
state.flags = result;
190221

191222
QuickCommand.endSteps(state);
192-
this.execute(state as RebaseStepState);
223+
void this.execute(state as RebaseStepState);
193224
}
194225

195226
return state.counter < 0 ? StepResult.Break : undefined;

src/git/models/repository.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -607,8 +607,11 @@ export class Repository implements Disposable {
607607

608608
@gate(() => '')
609609
@log()
610-
rebase(...args: string[]) {
611-
this.runTerminalCommand('rebase', ...args);
610+
rebase(configs: string[] | undefined, ...args: string[]) {
611+
this.runTerminalCommand(
612+
configs != null && configs.length !== 0 ? `${configs.join(' ')} rebase` : 'rebase',
613+
...args,
614+
);
612615
}
613616

614617
@gate(() => '')

0 commit comments

Comments
 (0)