瀏覽代碼

Adds reset commit view command

Renames Reset to Commit... -> Reset Current Branch to Commit...
Renames Current -> Current Branch on other commands
main
Eric Amodio 4 年之前
父節點
當前提交
13c4370939
共有 3 個檔案被更改,包括 55 行新增16 行删除
  1. +25
    -11
      package.json
  2. +13
    -3
      src/git/models/models.ts
  3. +17
    -2
      src/views/viewCommands.ts

+ 25
- 11
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",

+ 13
- 3
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;

+ 17
- 2
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);

Loading…
取消
儲存