diff --git a/CHANGELOG.md b/CHANGELOG.md index 6d18127..dcffa83 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,6 +14,7 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/) and this p - Adds this new option to the _Menus & Toolbars_ section of the GitLens Interactive Settings - Adds an _Open File on Remote From..._ command (`gitlens.openFileOnRemoteFrom`) to open a file or revision on a specific branch or tag on the remote provider — closes [#1071](https://github.com/eamodio/vscode-gitlens/issues/1071) - Adds a _Copy Remote File Url From..._ command (`gitlens.copyRemoteFileUrlFrom`) to copy the url of a file or revision on a specific branch or tag the remote provider — closes [#1071](https://github.com/eamodio/vscode-gitlens/issues/1071) +- Adds _Commit_ submenu to files in the _File History_ and _Line History_ views — closes [#1044](https://github.com/eamodio/vscode-gitlens/issues/1044) - Adds a welcome, i.e. richer empty state, to the _Search & Compare_ view - Adds preview extensibility APIs - Adds a preview _action runner_ extensibility point to provide a runner (handler) for a new _createPullRequest_ and _openPullRequest_ actions — see `gitlens.d.ts` for API definitions diff --git a/package.json b/package.json index 29b7bb2..cba9404 100644 --- a/package.json +++ b/package.json @@ -6979,20 +6979,9 @@ "group": "2_gitlens_quickopen@6" }, { - "command": "gitlens.openCommitOnRemote", - "when": "viewItem =~ /gitlens:file\\b(?=.*?\\b\\+committed\\b)/ && gitlens:hasRemotes", - "group": "3_gitlens_explore@0", - "alt": "gitlens.copyRemoteCommitUrl" - }, - { - "command": "gitlens.showCommitInView", - "when": "viewItem =~ /gitlens:file\\b(?!.*?\\b(\\+stashed|:status)\\b)/", - "group": "3_gitlens_explore@3" - }, - { - "command": "gitlens.revealCommitInView", - "when": "viewItem =~ /gitlens:file\\b(?!.*?\\b(\\+stashed|:status)\\b)/", - "group": "3_gitlens_explore@4" + "submenu": "gitlens/commit/file/commit", + "when": "!gitlens:readonly && view =~ /^gitlens\\.views\\.(file|line)History/ && viewItem =~ /gitlens:file\\b(?=.*?\\b\\+committed\\b)/", + "group": "3_gitlens_explore@0" }, { "command": "gitlens.views.applyChanges", @@ -7111,7 +7100,7 @@ }, { "submenu": "gitlens/commit/browse", - "when": "viewItem =~ /gitlens:(branch|commit|file\\b((?=.*?\\b\\+committed\\b)|:results)|stash|tag)\\b/", + "when": "viewItem =~ /gitlens:(branch|commit|stash|tag)\\b/", "group": "3_gitlens_explore@1" }, { @@ -7585,6 +7574,64 @@ "group": "2_gitlens_quickopen_1@2" } ], + "gitlens/commit/file/commit": [ + { + "command": "gitlens.views.revert", + "when": "!gitlens:readonly && viewItem =~ /gitlens:file\\b(?=.*?\\b\\+committed\\b)(?=.*?\\b\\+current\\b)/", + "group": "1_gitlens_actions@3" + }, + { + "command": "gitlens.views.resetToCommit", + "when": "!gitlens:readonly && viewItem =~ /gitlens:file\\b(?=.*?\\b\\+committed\\b)(?=.*?\\b\\+current\\b)/", + "group": "1_gitlens_actions@4" + }, + { + "command": "gitlens.views.resetCommit", + "when": "!gitlens:readonly && viewItem =~ /gitlens:file\\b(?=.*?\\b\\+committed\\b)(?=.*?\\b\\+current\\b)/", + "group": "1_gitlens_actions@5" + }, + { + "command": "gitlens.views.rebaseOntoCommit", + "when": "!gitlens:readonly && viewItem =~ /gitlens:file\\b(?=.*?\\b\\+committed\\b)(?=.*?\\b\\+current\\b)/", + "group": "1_gitlens_actions@6" + }, + { + "command": "gitlens.views.switchToCommit", + "when": "!gitlens:readonly && viewItem =~ /gitlens:file\\b(?=.*?\\b\\+committed\\b)/", + "group": "1_gitlens_actions@7" + }, + { + "command": "gitlens.views.createBranch", + "when": "!gitlens:readonly && viewItem =~ /gitlens:file\\b(?=.*?\\b\\+committed\\b)/", + "group": "1_gitlens_actions_1@1" + }, + { + "command": "gitlens.views.createTag", + "when": "!gitlens:readonly && viewItem =~ /gitlens:file\\b(?=.*?\\b\\+committed\\b)/", + "group": "1_gitlens_actions_1@2" + }, + { + "command": "gitlens.openCommitOnRemote", + "when": "viewItem =~ /gitlens:file\\b(?=.*?\\b\\+committed\\b)/ && gitlens:hasRemotes", + "group": "3_gitlens_explore@0", + "alt": "gitlens.copyRemoteCommitUrl" + }, + { + "submenu": "gitlens/commit/browse", + "when": "viewItem =~ /gitlens:file\\b(?=.*?\\b\\+committed\\b)/", + "group": "3_gitlens_explore@1" + }, + { + "command": "gitlens.showCommitInView", + "when": "view =~ /gitlens\\.views\\.(fileHistory|lineHistory\\b)/ && viewItem =~ /gitlens:file\\b(?=.*?\\b\\+committed\\b)/", + "group": "3_gitlens_explore@3" + }, + { + "command": "gitlens.revealCommitInView", + "when": "view =~ /gitlens\\.views\\.(fileHistory|lineHistory\\b)/ && viewItem =~ /gitlens:file\\b(?=.*?\\b\\+committed\\b)/", + "group": "3_gitlens_explore@4" + } + ], "gitlens/commit/file/openChanges": [ { "command": "gitlens.externalDiff", @@ -7820,6 +7867,10 @@ "label": "Copy as" }, { + "id": "gitlens/commit/file/commit", + "label": "Commit" + }, + { "id": "gitlens/commit/file/openChanges", "label": "Open Changes" }, diff --git a/src/views/nodes/commitFileNode.ts b/src/views/nodes/commitFileNode.ts index 18e0514..5d697a6 100644 --- a/src/views/nodes/commitFileNode.ts +++ b/src/views/nodes/commitFileNode.ts @@ -111,7 +111,7 @@ export class CommitFileNode extends ViewRefFileNode { protected get contextValue(): string { if (!this.commit.isUncommitted) { - return `${ContextValues.File}+committed${ + return `${ContextValues.File}+committed${this._options.branch?.current ? '+current' : ''}${ this._options.branch?.current && this._options.branch.sha === this.commit.ref ? '+HEAD' : '' }${this._options.unpublished ? '+unpublished' : ''}`; } diff --git a/src/views/viewCommands.ts b/src/views/viewCommands.ts index 5301572..45a1ea6 100644 --- a/src/views/viewCommands.ts +++ b/src/views/viewCommands.ts @@ -441,8 +441,13 @@ export class ViewCommands { } @debug() - private rebase(node: BranchNode | CommitNode | TagNode) { - if (!(node instanceof BranchNode) && !(node instanceof CommitNode) && !(node instanceof TagNode)) { + private rebase(node: BranchNode | CommitNode | CommitFileNode | TagNode) { + if ( + !(node instanceof BranchNode) && + !(node instanceof CommitNode) && + !(node instanceof CommitFileNode) && + !(node instanceof TagNode) + ) { return Promise.resolve(); } @@ -474,8 +479,8 @@ export class ViewCommands { } @debug() - private resetCommit(node: CommitNode) { - if (!(node instanceof CommitNode)) return Promise.resolve(); + private resetCommit(node: CommitNode | CommitFileNode) { + if (!(node instanceof CommitNode) && !(node instanceof CommitFileNode)) return Promise.resolve(); return GitActions.reset( node.repoPath, @@ -488,8 +493,8 @@ export class ViewCommands { } @debug() - private resetToCommit(node: CommitNode) { - if (!(node instanceof CommitNode)) return Promise.resolve(); + private resetToCommit(node: CommitNode | CommitFileNode) { + if (!(node instanceof CommitNode) && !(node instanceof CommitFileNode)) return Promise.resolve(); return GitActions.reset(node.repoPath, node.ref); } @@ -502,8 +507,8 @@ export class ViewCommands { } @debug() - private revert(node: CommitNode) { - if (!(node instanceof CommitNode)) return Promise.resolve(); + private revert(node: CommitNode | CommitFileNode) { + if (!(node instanceof CommitNode) && !(node instanceof CommitFileNode)) return Promise.resolve(); return GitActions.revert(node.repoPath, node.ref); }