diff --git a/CHANGELOG.md b/CHANGELOG.md index 676c98e..0c4db9a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -35,6 +35,7 @@ ATTENTION! To support multi-root workspaces some underlying fundamentals had to - Adds `Squash Branch into Commit (via Terminal)` command (`gitlens.terminalSquashBranchIntoCommit`) to branch node(s) of the `GitLens` custom view - Adds `Rebase Commit (via Terminal)` command (`gitlens.terminalRebaseCommit`) to commit node(s) of the `GitLens` custom view - Adds `Reset Commit (via Terminal)` command (`gitlens.terminalResetCommit`) to commit node(s) of the `GitLens` custom view + - Adds `Remove Remote (via Terminal)` command (`gitlens.terminalRemoveRemote`) to remote node(s) of the `GitLens` custom view - Adds ability to specify the url protocol used with user-defined remote services via `gitlens.remotes` setting -- thanks to [PR #192](https://github.com/eamodio/vscode-gitlens/pull/192) by Helmut Januschka ([@hjanuschka](https://github.com/hjanuschka))! ### Changed diff --git a/README.md b/README.md index bce6ef2..0060499 100644 --- a/README.md +++ b/README.md @@ -180,7 +180,7 @@ GitLens provides an unobtrusive blame annotation at the end of the current line, - Provides a context menu on each revision (commit) with `Open Commit in Remote`, `Open All Changes`, `Open All Changes with Working Tree`, `Open Files`, `Open Revisions`, `Copy Commit ID to Clipboard`, `Copy Commit Message to Clipboard`,`Show Commit Details`, and `Refresh` commands - Provides a context menu on each changed file with `Open Changes`, `Open Changes with Working Tree`, `Open File`, `Open Revision`, `Open File in Remote`, `Open Revision in Remote`, `Apply Changes`, `Show File History`, and `Show Commit File Details` commands - Provides a context menu on each remote branch with `Open Branch in Remote`, `Checkout Branch (via Terminal)`, `Create Branch (via Terminal)...`, `Delete Branch (via Terminal)`, `Squash Branch into Commit (via Terminal)`, and `Refresh` commands - - Provides a context menu on each remote with `Open Branches in Remote`, `Open Repository in Remote`, and `Refresh` commands + - Provides a context menu on each remote with `Open Branches in Remote`, `Open Repository in Remote`, `Remove Remote (via Terminal)`, and `Refresh` commands - Provides a context menu with a `Refresh` command - `Stashes` node — provides a list of stashed changes diff --git a/package.json b/package.json index 2546467..da4c444 100644 --- a/package.json +++ b/package.json @@ -1359,6 +1359,11 @@ "command": "gitlens.gitExplorer.terminalResetCommit", "title": "Reset Commit (via Terminal)", "category": "GitLens" + }, + { + "command": "gitlens.gitExplorer.terminalRemoveRemote", + "title": "Remove Remote (via Terminal)", + "category": "GitLens" } ], "menus": { @@ -1618,6 +1623,10 @@ { "command": "gitlens.gitExplorer.terminalResetCommit", "when": "false" + }, + { + "command": "gitlens.gitExplorer.terminalRemoveRemote", + "when": "false" } ], "editor/context": [ @@ -2123,15 +2132,20 @@ }, { "command": "gitlens.openBranchesInRemote", - "when": "gitlens:hasRemotes && view == gitlens.gitExplorer && viewItem == gitlens:remote", + "when": "view == gitlens.gitExplorer && viewItem == gitlens:remote", "group": "1_gitlens@1" }, { "command": "gitlens.openRepoInRemote", - "when": "gitlens:hasRemotes && view == gitlens.gitExplorer && viewItem == gitlens:remote", + "when": "view == gitlens.gitExplorer && viewItem == gitlens:remote", "group": "1_gitlens@2" }, { + "command": "gitlens.gitExplorer.terminalRemoveRemote", + "when": "view == gitlens.gitExplorer && viewItem == gitlens:remote", + "group": "8_gitlens@1" + }, + { "command": "gitlens.openRepoInRemote", "when": "gitlens:hasRemotes && view == gitlens.gitExplorer && viewItem == gitlens:repository", "group": "1_gitlens@1" diff --git a/src/views/explorerCommands.ts b/src/views/explorerCommands.ts index 151dfb6..c9a46f8 100644 --- a/src/views/explorerCommands.ts +++ b/src/views/explorerCommands.ts @@ -3,7 +3,7 @@ import { commands, Disposable, InputBoxOptions, Terminal, TextDocumentShowOption import { ExtensionKey, ExtensionTerminalName } from '../constants'; import { BranchHistoryNode, ExplorerNode, GitExplorer, GitExplorerView } from '../views/gitExplorer'; import { configuration, GitExplorerFilesLayout } from '../configuration'; -import { CommitFileNode, CommitNode, StashNode, StatusUpstreamNode } from './explorerNodes'; +import { CommitFileNode, CommitNode, RemoteNode, StashNode, StatusUpstreamNode } from './explorerNodes'; import { Commands, DiffWithCommandArgs, DiffWithCommandArgsRevision, DiffWithPreviousCommandArgs, DiffWithWorkingCommandArgs, openEditor, OpenFileInRemoteCommandArgs, OpenFileRevisionCommandArgs } from '../commands'; import { GitService, GitUri } from '../gitService'; @@ -43,6 +43,7 @@ export class ExplorerCommands extends Disposable { commands.registerCommand('gitlens.gitExplorer.terminalSquashBranchIntoCommit', this.terminalSquashBranchIntoCommit, this); commands.registerCommand('gitlens.gitExplorer.terminalRebaseCommit', this.terminalRebaseCommit, this); commands.registerCommand('gitlens.gitExplorer.terminalResetCommit', this.terminalResetCommit, this); + commands.registerCommand('gitlens.gitExplorer.terminalRemoveRemote', this.terminalRemoveRemote, this); } dispose() { @@ -206,6 +207,13 @@ export class ExplorerCommands extends Disposable { this.sendTerminalCommand(command); } + terminalRemoveRemote(node: ExplorerNode) { + if (!(node instanceof RemoteNode)) return; + + const command = `remote remove ${node.remote.name}`; + this.sendTerminalCommand(command); + } + private ensureTerminal(): Terminal { if (this._terminal === undefined) { this._terminal = window.createTerminal(ExtensionTerminalName);