From 8978d17b4e444582318a4f29d6b08192718963d9 Mon Sep 17 00:00:00 2001 From: Eric Amodio Date: Sun, 22 Nov 2020 14:53:33 -0500 Subject: [PATCH] Fixes #1163 - forces rebase ui when cmd invoked --- src/commands/git/rebase.ts | 37 ++++++++++++++++++++++++++++++++++--- src/git/models/repository.ts | 7 +++++-- 2 files changed, 39 insertions(+), 5 deletions(-) diff --git a/src/commands/git/rebase.ts b/src/commands/git/rebase.ts index 73109ac..a54060e 100644 --- a/src/commands/git/rebase.ts +++ b/src/commands/git/rebase.ts @@ -1,4 +1,5 @@ 'use strict'; +import { env } from 'vscode'; import { Container } from '../../container'; import { GitBranch, GitLog, GitReference, GitRevision, Repository } from '../../git/git'; import { @@ -71,8 +72,38 @@ export class RebaseGitCommand extends QuickCommand { return false; } - execute(state: RebaseStepState) { - return state.repo.rebase(...state.flags, state.reference.ref); + async execute(state: RebaseStepState) { + let configs: string[] | undefined; + if (state.flags.includes('--interactive')) { + await Container.rebaseEditor.enableForNextUse(); + + let editor; + if (env.remoteName) { + switch (env.appName) { + case 'Visual Studio Code - Insiders': + editor = 'code-insiders --wait --reuse-window'; + break; + case 'Visual Studio Code - Exploration': + editor = 'code-exploration --wait --reuse-window'; + break; + default: + editor = 'code --wait --reuse-window'; + break; + } + } else { + let execPath = process.execPath.replace(/\\/g, '/'); + if (process.platform === 'darwin') { + const index = execPath.indexOf('.app/Contents/'); + if (index !== -1) { + execPath = `${execPath.substring(0, index)}.app/Contents/MacOS/Electron`; + } + } + editor = `'${execPath}' --wait --reuse-window`; + } + + configs = ['-c', `sequence.editor="${editor}"`]; + } + return state.repo.rebase(configs, ...state.flags, state.reference.ref); } protected async *steps(state: PartialStepState): StepGenerator { @@ -189,7 +220,7 @@ export class RebaseGitCommand extends QuickCommand { state.flags = result; QuickCommand.endSteps(state); - this.execute(state as RebaseStepState); + void this.execute(state as RebaseStepState); } return state.counter < 0 ? StepResult.Break : undefined; diff --git a/src/git/models/repository.ts b/src/git/models/repository.ts index ed91f00..610ac0e 100644 --- a/src/git/models/repository.ts +++ b/src/git/models/repository.ts @@ -607,8 +607,11 @@ export class Repository implements Disposable { @gate(() => '') @log() - rebase(...args: string[]) { - this.runTerminalCommand('rebase', ...args); + rebase(configs: string[] | undefined, ...args: string[]) { + this.runTerminalCommand( + configs != null && configs.length !== 0 ? `${configs.join(' ')} rebase` : 'rebase', + ...args, + ); } @gate(() => '')