Browse Source

Fixes #2301 handles new view/title callback change

main
Eric Amodio 2 years ago
parent
commit
d7ef13d09b
8 changed files with 147 additions and 71 deletions
  1. +1
    -0
      CHANGELOG.md
  2. +44
    -4
      package.json
  3. +4
    -4
      src/commands/searchCommits.ts
  4. +4
    -0
      src/views/nodes/contributorNode.ts
  5. +4
    -0
      src/views/nodes/contributorsNode.ts
  6. +8
    -0
      src/views/nodes/viewNode.ts
  7. +1
    -1
      src/views/searchAndCompareView.ts
  8. +81
    -62
      src/views/viewCommands.ts

+ 1
- 0
CHANGELOG.md View File

@ -29,6 +29,7 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/) and this p
### Fixed ### Fixed
- Fixes [#2301](https://github.com/gitkraken/vscode-gitlens/issues/2301) - Create Worktree button doesn't work in certain cases
- Fixes [#2318](https://github.com/gitkraken/vscode-gitlens/issues/2318) - GitLens need to login again after VS Code insiders upgrade every day - Fixes [#2318](https://github.com/gitkraken/vscode-gitlens/issues/2318) - GitLens need to login again after VS Code insiders upgrade every day
- Fixes [#2377](https://github.com/gitkraken/vscode-gitlens/issues/2377) - Missing Azure Devops Icon - Fixes [#2377](https://github.com/gitkraken/vscode-gitlens/issues/2377) - Missing Azure Devops Icon
- Fixes [#2380](https://github.com/gitkraken/vscode-gitlens/issues/2380) - Autolink fails with curly braces - Fixes [#2380](https://github.com/gitkraken/vscode-gitlens/issues/2380) - Autolink fails with curly braces

+ 44
- 4
package.json View File

@ -5406,12 +5406,24 @@
"icon": "$(person-add)" "icon": "$(person-add)"
}, },
{ {
"command": "gitlens.views.title.applyStash",
"title": "Apply a Stash...",
"category": "GitLens",
"icon": "$(gitlens-stash-pop)"
},
{
"command": "gitlens.views.createWorktree", "command": "gitlens.views.createWorktree",
"title": "Create Worktree...", "title": "Create Worktree...",
"category": "GitLens", "category": "GitLens",
"icon": "$(add)" "icon": "$(add)"
}, },
{ {
"command": "gitlens.views.title.createWorktree",
"title": "Create Worktree...",
"category": "GitLens",
"icon": "$(add)"
},
{
"command": "gitlens.views.deleteWorktree", "command": "gitlens.views.deleteWorktree",
"title": "Delete Worktree...", "title": "Delete Worktree...",
"category": "GitLens", "category": "GitLens",
@ -5446,6 +5458,12 @@
"icon": "$(add)" "icon": "$(add)"
}, },
{ {
"command": "gitlens.views.title.createBranch",
"title": "Create Branch...",
"category": "GitLens",
"icon": "$(add)"
},
{
"command": "gitlens.views.deleteBranch", "command": "gitlens.views.deleteBranch",
"title": "Delete Branch...", "title": "Delete Branch...",
"category": "GitLens", "category": "GitLens",
@ -5463,6 +5481,12 @@
"icon": "$(add)" "icon": "$(add)"
}, },
{ {
"command": "gitlens.views.title.createTag",
"title": "Create Tag...",
"category": "GitLens",
"icon": "$(add)"
},
{
"command": "gitlens.views.deleteTag", "command": "gitlens.views.deleteTag",
"title": "Delete Tag...", "title": "Delete Tag...",
"category": "GitLens", "category": "GitLens",
@ -7767,10 +7791,18 @@
"when": "false" "when": "false"
}, },
{ {
"command": "gitlens.views.title.applyStash",
"when": "false"
},
{
"command": "gitlens.views.createWorktree", "command": "gitlens.views.createWorktree",
"when": "false" "when": "false"
}, },
{ {
"command": "gitlens.views.title.createWorktree",
"when": "false"
},
{
"command": "gitlens.views.deleteWorktree", "command": "gitlens.views.deleteWorktree",
"when": "false" "when": "false"
}, },
@ -7791,6 +7823,10 @@
"when": "false" "when": "false"
}, },
{ {
"command": "gitlens.views.title.createBranch",
"when": "false"
},
{
"command": "gitlens.views.deleteBranch", "command": "gitlens.views.deleteBranch",
"when": "false" "when": "false"
}, },
@ -7847,6 +7883,10 @@
"when": "false" "when": "false"
}, },
{ {
"command": "gitlens.views.title.createTag",
"when": "false"
},
{
"command": "gitlens.views.deleteTag", "command": "gitlens.views.deleteTag",
"when": "false" "when": "false"
}, },
@ -9153,7 +9193,7 @@
"group": "navigation@10" "group": "navigation@10"
}, },
{ {
"command": "gitlens.views.createBranch",
"command": "gitlens.views.title.createBranch",
"when": "!gitlens:readonly && !gitlens:untrusted && !gitlens:hasVirtualFolders && view =~ /gitlens\\.views\\.branches\\b/", "when": "!gitlens:readonly && !gitlens:untrusted && !gitlens:hasVirtualFolders && view =~ /gitlens\\.views\\.branches\\b/",
"group": "navigation@11" "group": "navigation@11"
}, },
@ -9648,7 +9688,7 @@
"group": "navigation@10" "group": "navigation@10"
}, },
{ {
"command": "gitlens.stashApply",
"command": "gitlens.views.title.applyStash",
"when": "!gitlens:readonly && !gitlens:untrusted && !gitlens:hasVirtualFolders && view =~ /^gitlens\\.views\\.stashes/", "when": "!gitlens:readonly && !gitlens:untrusted && !gitlens:hasVirtualFolders && view =~ /^gitlens\\.views\\.stashes/",
"group": "navigation@11" "group": "navigation@11"
}, },
@ -9673,7 +9713,7 @@
"group": "navigation@99" "group": "navigation@99"
}, },
{ {
"command": "gitlens.views.createTag",
"command": "gitlens.views.title.createTag",
"when": "!gitlens:readonly && !gitlens:untrusted && !gitlens:hasVirtualFolders && view =~ /gitlens\\.views\\.tags\\b/", "when": "!gitlens:readonly && !gitlens:untrusted && !gitlens:hasVirtualFolders && view =~ /gitlens\\.views\\.tags\\b/",
"group": "navigation@10" "group": "navigation@10"
}, },
@ -9728,7 +9768,7 @@
"group": "navigation@99" "group": "navigation@99"
}, },
{ {
"command": "gitlens.views.createWorktree",
"command": "gitlens.views.title.createWorktree",
"when": "view =~ /^gitlens\\.views\\.worktrees/", "when": "view =~ /^gitlens\\.views\\.worktrees/",
"group": "navigation@10" "group": "navigation@10"
}, },

+ 4
- 4
src/commands/searchCommits.ts View File

@ -25,7 +25,10 @@ export class SearchCommitsCommand extends Command {
} }
protected override preExecute(context: CommandContext, args?: SearchCommitsCommandArgs) { protected override preExecute(context: CommandContext, args?: SearchCommitsCommandArgs) {
if (context.type === 'viewItem') {
if (context.command === Commands.SearchCommitsInView) {
args = { ...args };
args.showResultsInSideBar = true;
} else if (context.type === 'viewItem') {
args = { ...args }; args = { ...args };
args.showResultsInSideBar = true; args.showResultsInSideBar = true;
@ -38,9 +41,6 @@ export class SearchCommitsCommand extends Command {
if (isCommandContextViewNodeHasRepository(context)) { if (isCommandContextViewNodeHasRepository(context)) {
args.repoPath = context.node.repo.path; args.repoPath = context.node.repo.path;
} }
} else if (context.command === Commands.SearchCommitsInView) {
args = { ...args };
args.showResultsInSideBar = true;
} }
return this.execute(args); return this.execute(args);

+ 4
- 0
src/views/nodes/contributorNode.ts View File

@ -57,6 +57,10 @@ export class ContributorNode extends ViewNode
); );
} }
get repoPath(): string {
return this.contributor.repoPath;
}
async getChildren(): Promise<ViewNode[]> { async getChildren(): Promise<ViewNode[]> {
const log = await this.getLog(); const log = await this.getLog();
if (log == null) return [new MessageNode(this.view, this, 'No commits could be found.')]; if (log == null) return [new MessageNode(this.view, this, 'No commits could be found.')];

+ 4
- 0
src/views/nodes/contributorsNode.ts View File

@ -36,6 +36,10 @@ export class ContributorsNode extends ViewNode
return ContributorsNode.getId(this.repo.path); return ContributorsNode.getId(this.repo.path);
} }
get repoPath(): string {
return this.repo.path;
}
async getChildren(): Promise<ViewNode[]> { async getChildren(): Promise<ViewNode[]> {
if (this._children == null) { if (this._children == null) {
const all = configuration.get('views.contributors.showAllBranches'); const all = configuration.get('views.contributors.showAllBranches');

+ 8
- 0
src/views/nodes/viewNode.ts View File

@ -627,6 +627,14 @@ export function canEditNode(node: ViewNode): node is ViewNode & { edit(): void |
return typeof (node as ViewNode & { edit(): void | Promise<void> }).edit === 'function'; return typeof (node as ViewNode & { edit(): void | Promise<void> }).edit === 'function';
} }
export function canGetNodeRepoPath(node?: ViewNode): node is ViewNode & { repoPath: string | undefined } {
return node != null && 'repoPath' in node && typeof node.repoPath === 'string';
}
export function canViewDismissNode(view: View): view is View & { dismissNode(node: ViewNode): void } { export function canViewDismissNode(view: View): view is View & { dismissNode(node: ViewNode): void } {
return typeof (view as View & { dismissNode(node: ViewNode): void }).dismissNode === 'function'; return typeof (view as View & { dismissNode(node: ViewNode): void }).dismissNode === 'function';
} }
export function getNodeRepoPath(node?: ViewNode): string | undefined {
return canGetNodeRepoPath(node) ? node.repoPath : undefined;
}

+ 1
- 1
src/views/searchAndCompareView.ts View File

@ -295,7 +295,7 @@ export class SearchAndCompareView extends ViewBase
registerViewCommand(this.getQualifiedCommand('pin'), this.pin, this), registerViewCommand(this.getQualifiedCommand('pin'), this.pin, this),
registerViewCommand(this.getQualifiedCommand('unpin'), this.unpin, this), registerViewCommand(this.getQualifiedCommand('unpin'), this.unpin, this),
registerViewCommand(this.getQualifiedCommand('swapComparison'), this.swapComparison, this), registerViewCommand(this.getQualifiedCommand('swapComparison'), this.swapComparison, this),
registerViewCommand(this.getQualifiedCommand('selectForCompare'), this.selectForCompare, this),
registerViewCommand(this.getQualifiedCommand('selectForCompare'), () => this.selectForCompare()),
registerViewCommand(this.getQualifiedCommand('compareWithSelected'), this.compareWithSelected, this), registerViewCommand(this.getQualifiedCommand('compareWithSelected'), this.compareWithSelected, this),
registerViewCommand( registerViewCommand(

+ 81
- 62
src/views/viewCommands.ts View File

@ -27,7 +27,7 @@ import { debug } from '../system/decorators/log';
import { sequentialize } from '../system/function'; import { sequentialize } from '../system/function';
import { OpenWorkspaceLocation } from '../system/utils'; import { OpenWorkspaceLocation } from '../system/utils';
import { runGitCommandInTerminal } from '../terminal'; import { runGitCommandInTerminal } from '../terminal';
import { BranchesNode } from './nodes/branchesNode';
import type { BranchesNode } from './nodes/branchesNode';
import { BranchNode } from './nodes/branchNode'; import { BranchNode } from './nodes/branchNode';
import { BranchTrackingStatusNode } from './nodes/branchTrackingStatusNode'; import { BranchTrackingStatusNode } from './nodes/branchTrackingStatusNode';
import { CommitFileNode } from './nodes/commitFileNode'; import { CommitFileNode } from './nodes/commitFileNode';
@ -35,7 +35,6 @@ import { CommitNode } from './nodes/commitNode';
import type { PagerNode } from './nodes/common'; import type { PagerNode } from './nodes/common';
import { CompareBranchNode } from './nodes/compareBranchNode'; import { CompareBranchNode } from './nodes/compareBranchNode';
import { ContributorNode } from './nodes/contributorNode'; import { ContributorNode } from './nodes/contributorNode';
import { ContributorsNode } from './nodes/contributorsNode';
import { FileHistoryNode } from './nodes/fileHistoryNode'; import { FileHistoryNode } from './nodes/fileHistoryNode';
import { FileRevisionAsCommitNode } from './nodes/fileRevisionAsCommitNode'; import { FileRevisionAsCommitNode } from './nodes/fileRevisionAsCommitNode';
import { FolderNode } from './nodes/folderNode'; import { FolderNode } from './nodes/folderNode';
@ -43,7 +42,6 @@ import { LineHistoryNode } from './nodes/lineHistoryNode';
import { MergeConflictFileNode } from './nodes/mergeConflictFileNode'; import { MergeConflictFileNode } from './nodes/mergeConflictFileNode';
import { PullRequestNode } from './nodes/pullRequestNode'; import { PullRequestNode } from './nodes/pullRequestNode';
import { RemoteNode } from './nodes/remoteNode'; import { RemoteNode } from './nodes/remoteNode';
import type { RemotesNode } from './nodes/remotesNode';
import { RepositoryNode } from './nodes/repositoryNode'; import { RepositoryNode } from './nodes/repositoryNode';
import { ResultsFileNode } from './nodes/resultsFileNode'; import { ResultsFileNode } from './nodes/resultsFileNode';
import { ResultsFilesNode } from './nodes/resultsFilesNode'; import { ResultsFilesNode } from './nodes/resultsFilesNode';
@ -56,6 +54,7 @@ import {
canClearNode, canClearNode,
canEditNode, canEditNode,
canViewDismissNode, canViewDismissNode,
getNodeRepoPath,
PageableViewNode, PageableViewNode,
RepositoryFolderNode, RepositoryFolderNode,
ViewNode, ViewNode,
@ -199,7 +198,7 @@ export class ViewCommands {
); );
registerViewCommand('gitlens.views.addAuthors', this.addAuthors, this); registerViewCommand('gitlens.views.addAuthors', this.addAuthors, this);
registerViewCommand('gitlens.views.addAuthor', this.addAuthors, this);
registerViewCommand('gitlens.views.addAuthor', this.addAuthor, this);
registerViewCommand('gitlens.views.openChanges', this.openChanges, this); registerViewCommand('gitlens.views.openChanges', this.openChanges, this);
registerViewCommand('gitlens.views.openChangesWithWorking', this.openChangesWithWorking, this); registerViewCommand('gitlens.views.openChangesWithWorking', this.openChangesWithWorking, this);
@ -214,10 +213,10 @@ export class ViewCommands {
registerViewCommand('gitlens.views.highlightChanges', this.highlightChanges, this); registerViewCommand('gitlens.views.highlightChanges', this.highlightChanges, this);
registerViewCommand('gitlens.views.highlightRevisionChanges', this.highlightRevisionChanges, this); registerViewCommand('gitlens.views.highlightRevisionChanges', this.highlightRevisionChanges, this);
registerViewCommand('gitlens.views.restore', this.restore, this); registerViewCommand('gitlens.views.restore', this.restore, this);
registerViewCommand('gitlens.views.switchToBranch', this.switch, this);
registerViewCommand('gitlens.views.switchToAnotherBranch', this.switch, this); registerViewCommand('gitlens.views.switchToAnotherBranch', this.switch, this);
registerViewCommand('gitlens.views.switchToCommit', this.switch, this);
registerViewCommand('gitlens.views.switchToTag', this.switch, this);
registerViewCommand('gitlens.views.switchToBranch', this.switchTo, this);
registerViewCommand('gitlens.views.switchToCommit', this.switchTo, this);
registerViewCommand('gitlens.views.switchToTag', this.switchTo, this);
registerViewCommand('gitlens.views.addRemote', this.addRemote, this); registerViewCommand('gitlens.views.addRemote', this.addRemote, this);
registerViewCommand('gitlens.views.pruneRemote', this.pruneRemote, this); registerViewCommand('gitlens.views.pruneRemote', this.pruneRemote, this);
@ -247,10 +246,16 @@ export class ViewCommands {
); );
registerViewCommand('gitlens.views.cherryPick', this.cherryPick, this, ViewCommandMultiSelectMode.Custom); registerViewCommand('gitlens.views.cherryPick', this.cherryPick, this, ViewCommandMultiSelectMode.Custom);
registerViewCommand('gitlens.views.title.createBranch', () => this.createBranch());
registerViewCommand('gitlens.views.createBranch', this.createBranch, this); registerViewCommand('gitlens.views.createBranch', this.createBranch, this);
registerViewCommand('gitlens.views.deleteBranch', this.deleteBranch, this); registerViewCommand('gitlens.views.deleteBranch', this.deleteBranch, this);
registerViewCommand('gitlens.views.renameBranch', this.renameBranch, this); registerViewCommand('gitlens.views.renameBranch', this.renameBranch, this);
registerViewCommand('gitlens.views.title.applyStash', () => this.applyStash());
registerViewCommand('gitlens.views.deleteStash', this.deleteStash, this, ViewCommandMultiSelectMode.Custom); registerViewCommand('gitlens.views.deleteStash', this.deleteStash, this, ViewCommandMultiSelectMode.Custom);
registerViewCommand('gitlens.views.title.createTag', () => this.createTag());
registerViewCommand('gitlens.views.createTag', this.createTag, this); registerViewCommand('gitlens.views.createTag', this.createTag, this);
registerViewCommand('gitlens.views.deleteTag', this.deleteTag, this); registerViewCommand('gitlens.views.deleteTag', this.deleteTag, this);
@ -271,6 +276,7 @@ export class ViewCommands {
registerViewCommand('gitlens.views.createPullRequest', this.createPullRequest, this); registerViewCommand('gitlens.views.createPullRequest', this.createPullRequest, this);
registerViewCommand('gitlens.views.openPullRequest', this.openPullRequest, this); registerViewCommand('gitlens.views.openPullRequest', this.openPullRequest, this);
registerViewCommand('gitlens.views.title.createWorktree', () => this.createWorktree());
registerViewCommand('gitlens.views.createWorktree', this.createWorktree, this); registerViewCommand('gitlens.views.createWorktree', this.createWorktree, this);
registerViewCommand('gitlens.views.deleteWorktree', this.deleteWorktree, this); registerViewCommand('gitlens.views.deleteWorktree', this.deleteWorktree, this);
registerViewCommand('gitlens.views.openWorktree', this.openWorktree, this); registerViewCommand('gitlens.views.openWorktree', this.openWorktree, this);
@ -283,20 +289,25 @@ export class ViewCommands {
} }
@debug() @debug()
private addAuthors(node?: ContributorNode | ContributorsNode) {
if (node != null && !(node instanceof ContributorNode) && !(node instanceof ContributorsNode)) {
return Promise.resolve();
private addAuthors(node?: ViewNode) {
return GitActions.Contributor.addAuthors(getNodeRepoPath(node));
}
@debug()
private addAuthor(node?: ContributorNode) {
if (node instanceof ContributorNode) {
return GitActions.Contributor.addAuthors(
node.repoPath,
node.contributor.current ? undefined : node.contributor,
);
} }
return GitActions.Contributor.addAuthors(
node?.uri.repoPath,
node instanceof ContributorNode ? node.contributor : undefined,
);
return Promise.resolve();
} }
@debug() @debug()
private addRemote(node?: RemotesNode) {
return GitActions.Remote.add(node?.repoPath);
private addRemote(node?: ViewNode) {
return GitActions.Remote.add(getNodeRepoPath(node));
} }
@debug() @debug()
@ -317,6 +328,11 @@ export class ViewCommands {
} }
@debug() @debug()
private applyStash() {
return GitActions.Stash.apply();
}
@debug()
private browseRepoAtRevision(node: ViewRefNode, options?: { before?: boolean; openInNewWindow?: boolean }) { private browseRepoAtRevision(node: ViewRefNode, options?: { before?: boolean; openInNewWindow?: boolean }) {
if (!(node instanceof ViewRefNode)) return Promise.resolve(); if (!(node instanceof ViewRefNode)) return Promise.resolve();
@ -365,37 +381,6 @@ export class ViewCommands {
} }
@debug() @debug()
private async createWorktree(node?: BranchNode | WorktreesNode) {
if (node instanceof WorktreesNode) {
node = undefined;
}
if (node != null && !(node instanceof BranchNode)) return undefined;
return GitActions.Worktree.create(node?.repoPath, undefined, node?.ref);
}
@debug()
private openWorktree(node: WorktreeNode, options?: { location?: OpenWorkspaceLocation }) {
if (!(node instanceof WorktreeNode)) return undefined;
return GitActions.Worktree.open(node.worktree, options);
}
@debug()
private revealWorktreeInExplorer(node: WorktreeNode) {
if (!(node instanceof WorktreeNode)) return undefined;
return GitActions.Worktree.revealInFileExplorer(node.worktree);
}
@debug()
private async deleteWorktree(node: WorktreeNode) {
if (!(node instanceof WorktreeNode)) return undefined;
return GitActions.Worktree.remove(node.repoPath, node.worktree.uri);
}
@debug()
private async createPullRequest(node: BranchNode | BranchTrackingStatusNode) { private async createPullRequest(node: BranchNode | BranchTrackingStatusNode) {
if (!(node instanceof BranchNode) && !(node instanceof BranchTrackingStatusNode)) { if (!(node instanceof BranchNode) && !(node instanceof BranchTrackingStatusNode)) {
return Promise.resolve(); return Promise.resolve();
@ -446,6 +431,16 @@ export class ViewCommands {
} }
@debug() @debug()
private async createWorktree(node?: BranchNode | WorktreesNode) {
if (node instanceof WorktreesNode) {
node = undefined;
}
if (node != null && !(node instanceof BranchNode)) return undefined;
return GitActions.Worktree.create(node?.repoPath, undefined, node?.ref);
}
@debug()
private deleteBranch(node: BranchNode) { private deleteBranch(node: BranchNode) {
if (!(node instanceof BranchNode)) return Promise.resolve(); if (!(node instanceof BranchNode)) return Promise.resolve();
@ -476,6 +471,13 @@ export class ViewCommands {
} }
@debug() @debug()
private async deleteWorktree(node: WorktreeNode) {
if (!(node instanceof WorktreeNode)) return undefined;
return GitActions.Worktree.remove(node.repoPath, node.worktree.uri);
}
@debug()
private fetch(node: RemoteNode | RepositoryNode | RepositoryFolderNode | BranchNode | BranchTrackingStatusNode) { private fetch(node: RemoteNode | RepositoryNode | RepositoryFolderNode | BranchNode | BranchTrackingStatusNode) {
if (node instanceof RepositoryNode || node instanceof RepositoryFolderNode) return GitActions.fetch(node.repo); if (node instanceof RepositoryNode || node instanceof RepositoryFolderNode) return GitActions.fetch(node.repo);
if (node instanceof RemoteNode) return GitActions.Remote.fetch(node.remote.repoPath, node.remote.name); if (node instanceof RemoteNode) return GitActions.Remote.fetch(node.remote.repoPath, node.remote.name);
@ -536,10 +538,10 @@ export class ViewCommands {
} }
@debug() @debug()
private pushToCommit(node: CommitNode | FileRevisionAsCommitNode) {
if (!(node instanceof CommitNode) && !(node instanceof FileRevisionAsCommitNode)) return Promise.resolve();
private openInTerminal(node: RepositoryNode | RepositoryFolderNode) {
if (!(node instanceof RepositoryNode) && !(node instanceof RepositoryFolderNode)) return Promise.resolve();
return GitActions.push(node.repoPath, false, node.commit);
return executeCoreCommand(CoreCommands.OpenInTerminal, Uri.file(node.repo.path));
} }
@debug() @debug()
@ -561,10 +563,10 @@ export class ViewCommands {
} }
@debug() @debug()
private openInTerminal(node: RepositoryNode | RepositoryFolderNode) {
if (!(node instanceof RepositoryNode) && !(node instanceof RepositoryFolderNode)) return Promise.resolve();
private openWorktree(node: WorktreeNode, options?: { location?: OpenWorkspaceLocation }) {
if (!(node instanceof WorktreeNode)) return undefined;
return executeCoreCommand(CoreCommands.OpenInTerminal, Uri.file(node.repo.path));
return GitActions.Worktree.open(node.worktree, options);
} }
@debug() @debug()
@ -631,6 +633,13 @@ export class ViewCommands {
} }
@debug() @debug()
private pushToCommit(node: CommitNode | FileRevisionAsCommitNode) {
if (!(node instanceof CommitNode) && !(node instanceof FileRevisionAsCommitNode)) return Promise.resolve();
return GitActions.push(node.repoPath, false, node.commit);
}
@debug()
private rebase(node: BranchNode | CommitNode | FileRevisionAsCommitNode | TagNode) { private rebase(node: BranchNode | CommitNode | FileRevisionAsCommitNode | TagNode) {
if ( if (
!(node instanceof BranchNode) && !(node instanceof BranchNode) &&
@ -697,6 +706,13 @@ export class ViewCommands {
} }
@debug() @debug()
private revealWorktreeInExplorer(node: WorktreeNode) {
if (!(node instanceof WorktreeNode)) return undefined;
return GitActions.Worktree.revealInFileExplorer(node.worktree);
}
@debug()
private revert(node: CommitNode | FileRevisionAsCommitNode) { private revert(node: CommitNode | FileRevisionAsCommitNode) {
if (!(node instanceof CommitNode) && !(node instanceof FileRevisionAsCommitNode)) return Promise.resolve(); if (!(node instanceof CommitNode) && !(node instanceof FileRevisionAsCommitNode)) return Promise.resolve();
@ -758,17 +774,20 @@ export class ViewCommands {
} }
@debug() @debug()
private switch(node?: ViewRefNode | BranchesNode) {
if (node == null) {
return GitActions.switchTo(this.container.git.highlander);
}
private switch(node?: ViewNode) {
return GitActions.switchTo(getNodeRepoPath(node));
}
if (!(node instanceof ViewRefNode) && !(node instanceof BranchesNode)) return Promise.resolve();
@debug()
private switchTo(node?: ViewNode) {
if (node instanceof ViewRefNode) {
return GitActions.switchTo(
node.repoPath,
node instanceof BranchNode && node.branch.current ? undefined : node.ref,
);
}
return GitActions.switchTo(
node.repoPath,
node instanceof BranchesNode || (node instanceof BranchNode && node.branch.current) ? undefined : node.ref,
);
return GitActions.switchTo(getNodeRepoPath(node));
} }
@debug() @debug()

Loading…
Cancel
Save