|
@ -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() |
|
|