diff --git a/CHANGELOG.md b/CHANGELOG.md index 822a718..447a3f9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -27,6 +27,7 @@ ATTENTION! To support multi-root workspaces some underlying fundamentals had to - Adds `Create Branch (via Terminal)...` command (`gitlens.terminalCreateBranch`) to branch node(s) of the `GitLens` custom view - Adds `Delete Branch (via Terminal)` command (`gitlens.terminalDeleteBranch`) to branch node(s) of the `GitLens` custom view - Adds `Rebase Branch to Remote (via Terminal)` command (`gitlens.terminalRebaseBranchToRemote`) to branch node(s) of the `GitLens` custom view + - 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 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))! diff --git a/README.md b/README.md index 20a8f51..8032fd1 100644 --- a/README.md +++ b/README.md @@ -164,7 +164,7 @@ GitLens provides an unobtrusive blame annotation at the end of the current line, - Expand each revision (commit) to quickly see the set of files changed, complete with status indicators for adds, changes, renames, and deletes - 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`, `Rebase Commit (via Terminal)`, `Reset Commit (via Terminal)`, 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`, and `Show Commit File Details` commands - - Provides a context menu on each branch with `Open Branch in Remote`, `Checkout Branch (via Terminal)`, `Create Branch (via Terminal)...`, `Delete Branch (via Terminal)`, `Rebase Branch to Remote (via Terminal)`, and `Refresh` commands + - Provides a context menu on each branch with `Open Branch in Remote`, `Checkout Branch (via Terminal)`, `Create Branch (via Terminal)...`, `Delete Branch (via Terminal)`, `Rebase Branch to Remote (via Terminal)`, `Squash Branch into Commit (via Terminal)`, and `Refresh` commands - Provides a context menu with `Open Branches in Remote`, and `Refresh` commands - `Remotes` node — provides a list of remotes @@ -174,7 +174,7 @@ GitLens provides an unobtrusive blame annotation at the end of the current line, - Expand each revision (commit) to quickly see the set of files changed, complete with status indicators for adds, changes, renames, and deletes - 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)`, and `Refresh` 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 with a `Refresh` command diff --git a/package.json b/package.json index c045a43..2546467 100644 --- a/package.json +++ b/package.json @@ -1346,6 +1346,11 @@ "category": "GitLens" }, { + "command": "gitlens.gitExplorer.terminalSquashBranchIntoCommit", + "title": "Squash Branch into Commit (via Terminal)", + "category": "GitLens" + }, + { "command": "gitlens.gitExplorer.terminalRebaseCommit", "title": "Rebase Commit (via Terminal)", "category": "GitLens" @@ -1603,6 +1608,10 @@ "when": "false" }, { + "command": "gitlens.gitExplorer.terminalSquashBranchIntoCommit", + "when": "false" + }, + { "command": "gitlens.gitExplorer.terminalRebaseCommit", "when": "false" }, @@ -1893,6 +1902,11 @@ "group": "8_gitlens@3" }, { + "command": "gitlens.gitExplorer.terminalSquashBranchIntoCommit", + "when": "view == gitlens.gitExplorer && viewItem == gitlens:branch-history", + "group": "8_gitlens@4" + }, + { "command": "gitlens.openBranchInRemote", "when": "view == gitlens.gitExplorer && viewItem == gitlens:branch-history:tracking", "group": "1_gitlens@1" @@ -1913,6 +1927,11 @@ "group": "8_gitlens@3" }, { + "command": "gitlens.gitExplorer.terminalSquashBranchIntoCommit", + "when": "view == gitlens.gitExplorer && viewItem == gitlens:branch-history:tracking", + "group": "8_gitlens@4" + }, + { "command": "gitlens.gitExplorer.terminalCreateBranch", "when": "view == gitlens.gitExplorer && viewItem == gitlens:current-branch-history", "group": "8_gitlens@1" @@ -1953,6 +1972,11 @@ "group": "8_gitlens@3" }, { + "command": "gitlens.gitExplorer.terminalSquashBranchIntoCommit", + "when": "view == gitlens.gitExplorer && viewItem == gitlens:remote-branch-history", + "group": "8_gitlens@4" + }, + { "command": "gitlens.openCommitInRemote", "when": "gitlens:hasRemotes && view == gitlens.gitExplorer && viewItem == gitlens:commit", "group": "1_gitlens@1" diff --git a/src/views/explorerCommands.ts b/src/views/explorerCommands.ts index 268e7e1..151dfb6 100644 --- a/src/views/explorerCommands.ts +++ b/src/views/explorerCommands.ts @@ -40,6 +40,7 @@ export class ExplorerCommands extends Disposable { commands.registerCommand('gitlens.gitExplorer.terminalCreateBranch', this.terminalCreateBranch, this); commands.registerCommand('gitlens.gitExplorer.terminalDeleteBranch', this.terminalDeleteBranch, this); commands.registerCommand('gitlens.gitExplorer.terminalRebaseBranchToRemote', this.terminalRebaseBranchToRemote, this); + commands.registerCommand('gitlens.gitExplorer.terminalSquashBranchIntoCommit', this.terminalSquashBranchIntoCommit, this); commands.registerCommand('gitlens.gitExplorer.terminalRebaseCommit', this.terminalRebaseCommit, this); commands.registerCommand('gitlens.gitExplorer.terminalResetCommit', this.terminalResetCommit, this); } @@ -184,6 +185,13 @@ export class ExplorerCommands extends Disposable { this.sendTerminalCommand(command); } + terminalSquashBranchIntoCommit(node: ExplorerNode) { + if (!(node instanceof BranchHistoryNode)) return; + + const command = `merge --squash ${node.branch.name}`; + this.sendTerminalCommand(command); + } + terminalRebaseCommit(node: ExplorerNode) { if (!(node instanceof CommitNode)) return;