Browse Source

Closes #1044 - adds Commit submenu to file history

main
Eric Amodio 4 years ago
parent
commit
91e90d3762
4 changed files with 81 additions and 24 deletions
  1. +1
    -0
      CHANGELOG.md
  2. +66
    -15
      package.json
  3. +1
    -1
      src/views/nodes/commitFileNode.ts
  4. +13
    -8
      src/views/viewCommands.ts

+ 1
- 0
CHANGELOG.md View File

@ -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 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 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 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 a welcome, i.e. richer empty state, to the _Search & Compare_ view
- Adds preview extensibility APIs - 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 - 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

+ 66
- 15
package.json View File

@ -6979,20 +6979,9 @@
"group": "2_gitlens_quickopen@6" "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", "command": "gitlens.views.applyChanges",
@ -7111,7 +7100,7 @@
}, },
{ {
"submenu": "gitlens/commit/browse", "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" "group": "3_gitlens_explore@1"
}, },
{ {
@ -7585,6 +7574,64 @@
"group": "2_gitlens_quickopen_1@2" "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": [ "gitlens/commit/file/openChanges": [
{ {
"command": "gitlens.externalDiff", "command": "gitlens.externalDiff",
@ -7820,6 +7867,10 @@
"label": "Copy as" "label": "Copy as"
}, },
{ {
"id": "gitlens/commit/file/commit",
"label": "Commit"
},
{
"id": "gitlens/commit/file/openChanges", "id": "gitlens/commit/file/openChanges",
"label": "Open Changes" "label": "Open Changes"
}, },

+ 1
- 1
src/views/nodes/commitFileNode.ts View File

@ -111,7 +111,7 @@ export class CommitFileNode extends ViewRefFileNode {
protected get contextValue(): string { protected get contextValue(): string {
if (!this.commit.isUncommitted) { 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.branch?.current && this._options.branch.sha === this.commit.ref ? '+HEAD' : ''
}${this._options.unpublished ? '+unpublished' : ''}`; }${this._options.unpublished ? '+unpublished' : ''}`;
} }

+ 13
- 8
src/views/viewCommands.ts View File

@ -441,8 +441,13 @@ export class ViewCommands {
} }
@debug() @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(); return Promise.resolve();
} }
@ -474,8 +479,8 @@ export class ViewCommands {
} }
@debug() @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( return GitActions.reset(
node.repoPath, node.repoPath,
@ -488,8 +493,8 @@ export class ViewCommands {
} }
@debug() @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); return GitActions.reset(node.repoPath, node.ref);
} }
@ -502,8 +507,8 @@ export class ViewCommands {
} }
@debug() @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); return GitActions.revert(node.repoPath, node.ref);
} }

Loading…
Cancel
Save