diff --git a/package.json b/package.json index 50fc0e6..5f6ef45 100644 --- a/package.json +++ b/package.json @@ -3235,7 +3235,7 @@ }, { "command": "gitlens.views.mergeBranchInto", - "title": "Merge Branch into Current...", + "title": "Merge Branch into Current Branch...", "category": "GitLens" }, { @@ -3245,22 +3245,27 @@ }, { "command": "gitlens.views.rebaseOntoBranch", - "title": "Rebase Current onto Branch...", + "title": "Rebase Current Branch onto Branch...", "category": "GitLens" }, { "command": "gitlens.views.rebaseOntoCommit", - "title": "Rebase Current onto Commit...", + "title": "Rebase Current Branch onto Commit...", "category": "GitLens" }, { "command": "gitlens.views.rebaseOntoUpstream", - "title": "Rebase Current onto Upstream...", + "title": "Rebase Current Branch onto Upstream...", "category": "GitLens" }, { - "command": "gitlens.views.reset", - "title": "Reset to Commit...", + "command": "gitlens.views.resetCommit", + "title": "Reset Commit...", + "category": "GitLens" + }, + { + "command": "gitlens.views.resetToCommit", + "title": "Reset Current Branch to Commit...", "category": "GitLens" }, { @@ -4517,7 +4522,11 @@ "when": "false" }, { - "command": "gitlens.views.reset", + "command": "gitlens.views.resetCommit", + "when": "false" + }, + { + "command": "gitlens.views.resetToCommit", "when": "false" }, { @@ -6051,24 +6060,29 @@ "group": "1_gitlens_actions@2" }, { - "command": "gitlens.views.reset", + "command": "gitlens.views.resetCommit", "when": "!gitlens:readonly && viewItem =~ /gitlens:commit\\b(?=.*?\\b\\+current\\b)/", "group": "1_gitlens_actions@3" }, { - "command": "gitlens.views.pushToCommit", + "command": "gitlens.views.resetToCommit", "when": "!gitlens:readonly && viewItem =~ /gitlens:commit\\b(?=.*?\\b\\+current\\b)/", "group": "1_gitlens_actions@4" }, { + "command": "gitlens.views.pushToCommit", + "when": "!gitlens:readonly && viewItem =~ /gitlens:commit\\b(?=.*?\\b\\+current\\b)/", + "group": "1_gitlens_actions@5" + }, + { "command": "gitlens.views.rebaseOntoCommit", "when": "!gitlens:readonly && viewItem =~ /gitlens:commit\\b/", - "group": "1_gitlens_actions@5" + "group": "1_gitlens_actions@6" }, { "command": "gitlens.views.switchToCommit", "when": "!gitlens:readonly && viewItem =~ /gitlens:commit\\b/", - "group": "1_gitlens_actions@6" + "group": "1_gitlens_actions@7" }, { "command": "gitlens.views.createBranch", diff --git a/src/git/models/models.ts b/src/git/models/models.ts index 50ff4d0..ed4d7a3 100644 --- a/src/git/models/models.ts +++ b/src/git/models/models.ts @@ -271,10 +271,20 @@ export namespace GitReference { : ` (${ref.message})`; } - result = `${options.label ? 'commit ' : ''}${ + let name; + let prefix; + if (options.expand && options.label && GitRevision.isShaParent(ref.ref)) { + name = ref.name.endsWith('^') ? ref.name.substr(0, ref.name.length - 1) : ref.name; + prefix = 'before '; + } else { + name = ref.name; + prefix = ''; + } + + result = `${options.label ? `${prefix}commit ` : ''}${ options.icon - ? `$(git-commit) ${ref.name}${message ?? ''}${GlyphChars.Space}` - : `${ref.name}${message ?? ''}` + ? `$(git-commit) ${name}${message ?? ''}${GlyphChars.Space}` + : `${name}${message ?? ''}` }`; } break; diff --git a/src/views/viewCommands.ts b/src/views/viewCommands.ts index c09ffbc..f6111f8 100644 --- a/src/views/viewCommands.ts +++ b/src/views/viewCommands.ts @@ -183,7 +183,8 @@ export class ViewCommands { commands.registerCommand('gitlens.views.rebaseOntoUpstream', this.rebaseToRemote, this); commands.registerCommand('gitlens.views.rebaseOntoCommit', this.rebase, this); - commands.registerCommand('gitlens.views.reset', this.reset, this); + commands.registerCommand('gitlens.views.resetCommit', this.resetCommit, this); + commands.registerCommand('gitlens.views.resetToCommit', this.resetToCommit, this); commands.registerCommand('gitlens.views.revert', this.revert, this); commands.registerCommand('gitlens.views.terminalRemoveRemote', this.terminalRemoveRemote, this); @@ -413,7 +414,21 @@ export class ViewCommands { } @debug() - private reset(node: CommitNode) { + private resetCommit(node: CommitNode) { + if (!(node instanceof CommitNode)) return Promise.resolve(); + + return GitActions.reset( + node.repoPath, + GitReference.create(`${node.ref.ref}^`, node.ref.repoPath, { + refType: 'revision', + name: `${node.ref.name}^`, + message: node.ref.message, + }), + ); + } + + @debug() + private resetToCommit(node: CommitNode) { if (!(node instanceof CommitNode)) return Promise.resolve(); return GitActions.reset(node.repoPath, node.ref);