From c78d06c5ac05f0b1940c92521e905f4d17bb0eb0 Mon Sep 17 00:00:00 2001 From: Eric Amodio Date: Tue, 14 Nov 2017 09:43:54 -0500 Subject: [PATCH] Fixes #200 adds repo path to terminal commands --- CHANGELOG.md | 1 + src/views/explorerCommands.ts | 30 +++++++++++++----------------- 2 files changed, 14 insertions(+), 17 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a74bd11..2984138 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,7 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/) and this p ## [Unreleased] ### Fixed - Fixes [#201](https://github.com/eamodio/vscode-gitlens/issues/201) - "Open in Remote" commands should check for branch upstream tracking +- Fixes [#200](https://github.com/eamodio/vscode-gitlens/issues/200) - Submodule using terminal command, root directory is incorrect ## [6.1.0] - 2017-11-13 ### Added diff --git a/src/views/explorerCommands.ts b/src/views/explorerCommands.ts index 3a55d6f..f49b779 100644 --- a/src/views/explorerCommands.ts +++ b/src/views/explorerCommands.ts @@ -143,7 +143,7 @@ export class ExplorerCommands extends Disposable { if (!(node instanceof BranchHistoryNode)) return; const command = `checkout ${node.branch.name}`; - this.sendTerminalCommand(command); + this.sendTerminalCommand(command, node.branch.repoPath); } async terminalCreateBranch(node: ExplorerNode) { @@ -157,7 +157,7 @@ export class ExplorerCommands extends Disposable { if (name === undefined || name === '') return; const command = `branch ${node.branch.remote ? '-t ' : ''}${name} ${node.branch.name}`; - this.sendTerminalCommand(command); + this.sendTerminalCommand(command, node.branch.repoPath); } terminalDeleteBranch(node: ExplorerNode) { @@ -166,52 +166,48 @@ export class ExplorerCommands extends Disposable { const command = node.branch.remote ? `push ${node.branch.remote} :${node.branch.name}` : `branch -d ${node.branch.name}`; - this.sendTerminalCommand(command); + this.sendTerminalCommand(command, node.branch.repoPath); } terminalRebaseBranchToRemote(node: ExplorerNode) { - let command: string; if (node instanceof BranchHistoryNode) { if (!node.branch.current || !node.branch.tracking) return; - command = `rebase -i ${node.branch.tracking}`; + const command = `rebase -i ${node.branch.tracking}`; + this.sendTerminalCommand(command, node.branch.repoPath); } else if (node instanceof StatusUpstreamNode) { - command = `rebase -i ${node.status.upstream}`; + const command = `rebase -i ${node.status.upstream}`; + this.sendTerminalCommand(command, node.status.repoPath); } - else { - return; - } - - this.sendTerminalCommand(command); } terminalSquashBranchIntoCommit(node: ExplorerNode) { if (!(node instanceof BranchHistoryNode)) return; const command = `merge --squash ${node.branch.name}`; - this.sendTerminalCommand(command); + this.sendTerminalCommand(command, node.branch.repoPath); } terminalRebaseCommit(node: ExplorerNode) { if (!(node instanceof CommitNode)) return; const command = `rebase -i ${node.commit.sha}^`; - this.sendTerminalCommand(command); + this.sendTerminalCommand(command, node.commit.repoPath); } terminalResetCommit(node: ExplorerNode) { if (!(node instanceof CommitNode)) return; const command = `reset --soft ${node.commit.sha}^`; - this.sendTerminalCommand(command); + this.sendTerminalCommand(command, node.commit.repoPath); } terminalRemoveRemote(node: ExplorerNode) { if (!(node instanceof RemoteNode)) return; const command = `remote remove ${node.remote.name}`; - this.sendTerminalCommand(command); + this.sendTerminalCommand(command, node.remote.repoPath); } private ensureTerminal(): Terminal { @@ -231,7 +227,7 @@ export class ExplorerCommands extends Disposable { return this._terminal; } - private sendTerminalCommand(command: string) { + private sendTerminalCommand(command: string, cwd: string) { // let git = GitService.getGitPath(); // if (git.includes(' ')) { // git = `"${git}"`; @@ -239,6 +235,6 @@ export class ExplorerCommands extends Disposable { const terminal = this.ensureTerminal(); terminal.show(false); - terminal.sendText(`git ${command}`, false); + terminal.sendText(`git -C ${cwd} ${command}`, false); } } \ No newline at end of file