|
|
@ -62,8 +62,11 @@ export namespace GitActions { |
|
|
|
return executeGitCommand({ command: 'pull', state: { repos: repos } }); |
|
|
|
} |
|
|
|
|
|
|
|
export function push(repos?: string | string[] | Repository | Repository[], force?: boolean) { |
|
|
|
return executeGitCommand({ command: 'push', state: { repos: repos, flags: force ? ['--force'] : [] } }); |
|
|
|
export function push(repos?: string | string[] | Repository | Repository[], force?: boolean, ref?: GitReference) { |
|
|
|
return executeGitCommand({ |
|
|
|
command: 'push', |
|
|
|
state: { repos: repos, flags: force ? ['--force'] : [], reference: ref }, |
|
|
|
}); |
|
|
|
} |
|
|
|
|
|
|
|
export async function rebase(repo?: string | Repository, ref?: GitReference, interactive: boolean = true) { |
|
|
@ -94,556 +97,6 @@ export namespace GitActions { |
|
|
|
}); |
|
|
|
} |
|
|
|
|
|
|
|
// @debug()
|
|
|
|
// private async highlightChanges(node: CommitFileNode | ResultsFileNode | StashFileNode) {
|
|
|
|
// if (
|
|
|
|
// !(node instanceof CommitFileNode) &&
|
|
|
|
// !(node instanceof StashFileNode) &&
|
|
|
|
// !(node instanceof ResultsFileNode)
|
|
|
|
// ) {
|
|
|
|
// return;
|
|
|
|
// }
|
|
|
|
|
|
|
|
// void (await this.openFile(node));
|
|
|
|
// void (await Container.fileAnnotations.toggle(
|
|
|
|
// window.activeTextEditor,
|
|
|
|
// FileAnnotationType.RecentChanges,
|
|
|
|
// node.ref,
|
|
|
|
// true,
|
|
|
|
// ));
|
|
|
|
// }
|
|
|
|
|
|
|
|
// @debug()
|
|
|
|
// private async highlightRevisionChanges(node: CommitFileNode | ResultsFileNode | StashFileNode) {
|
|
|
|
// if (
|
|
|
|
// !(node instanceof CommitFileNode) &&
|
|
|
|
// !(node instanceof StashFileNode) &&
|
|
|
|
// !(node instanceof ResultsFileNode)
|
|
|
|
// ) {
|
|
|
|
// return;
|
|
|
|
// }
|
|
|
|
|
|
|
|
// void (await this.openFileRevision(node, { showOptions: { preserveFocus: true, preview: true } }));
|
|
|
|
// void (await Container.fileAnnotations.toggle(
|
|
|
|
// window.activeTextEditor,
|
|
|
|
// FileAnnotationType.RecentChanges,
|
|
|
|
// node.ref,
|
|
|
|
// true,
|
|
|
|
// ));
|
|
|
|
// }
|
|
|
|
|
|
|
|
// @debug()
|
|
|
|
// private openInTerminal(node: RepositoryNode) {
|
|
|
|
// if (!(node instanceof RepositoryNode)) return undefined;
|
|
|
|
|
|
|
|
// return commands.executeCommand(BuiltInCommands.OpenInTerminal, Uri.file(node.repo.path));
|
|
|
|
// }
|
|
|
|
|
|
|
|
// @debug()
|
|
|
|
// private async rebaseToRemote(node: BranchNode | BranchTrackingStatusNode) {
|
|
|
|
// if (!(node instanceof BranchNode) && !(node instanceof BranchTrackingStatusNode)) return undefined;
|
|
|
|
|
|
|
|
// const upstream = node instanceof BranchNode ? node.branch.tracking : node.status.upstream;
|
|
|
|
// if (upstream == null) return undefined;
|
|
|
|
|
|
|
|
// const repo = await Container.git.getRepository(node.repoPath);
|
|
|
|
|
|
|
|
// const args: GitCommandsCommandArgs = {
|
|
|
|
// command: 'rebase',
|
|
|
|
// state: {
|
|
|
|
// repo: repo!,
|
|
|
|
// reference: GitReference.create(upstream, repo!.path, {
|
|
|
|
// refType: 'branch',
|
|
|
|
// name: upstream,
|
|
|
|
// remote: true,
|
|
|
|
// }),
|
|
|
|
// },
|
|
|
|
// };
|
|
|
|
// return commands.executeCommand(Commands.GitCommands, args);
|
|
|
|
// }
|
|
|
|
|
|
|
|
// @debug()
|
|
|
|
// private setAsDefault(node: RemoteNode) {
|
|
|
|
// if (node instanceof RemoteNode) return node.setAsDefault();
|
|
|
|
// return undefined;
|
|
|
|
// }
|
|
|
|
|
|
|
|
// @debug()
|
|
|
|
// private setComparisonNotation(node: ViewNode, comparisonNotation: '...' | '..') {
|
|
|
|
// if (!(node instanceof CompareResultsNode) && !(node instanceof CompareBranchNode)) return undefined;
|
|
|
|
|
|
|
|
// return node.setComparisonNotation(comparisonNotation);
|
|
|
|
// }
|
|
|
|
|
|
|
|
// @debug()
|
|
|
|
// private async stageFile(node: CommitFileNode | StatusFileNode) {
|
|
|
|
// if (!(node instanceof CommitFileNode) && !(node instanceof StatusFileNode)) return;
|
|
|
|
|
|
|
|
// void (await Container.git.stageFile(node.repoPath, node.file.fileName));
|
|
|
|
// void node.triggerChange();
|
|
|
|
// }
|
|
|
|
|
|
|
|
// @debug()
|
|
|
|
// private async stageDirectory(node: FolderNode) {
|
|
|
|
// if (!(node instanceof FolderNode) || !node.relativePath) return;
|
|
|
|
|
|
|
|
// void (await Container.git.stageDirectory(node.repoPath, node.relativePath));
|
|
|
|
// void node.triggerChange();
|
|
|
|
// }
|
|
|
|
|
|
|
|
// @debug()
|
|
|
|
// private star(node: BranchNode | RepositoryNode) {
|
|
|
|
// if (node instanceof BranchNode || node instanceof RepositoryNode) return node.star();
|
|
|
|
// return undefined;
|
|
|
|
// }
|
|
|
|
|
|
|
|
// @debug()
|
|
|
|
// private unsetAsDefault(node: RemoteNode) {
|
|
|
|
// if (node instanceof RemoteNode) return node.setAsDefault(false);
|
|
|
|
// return undefined;
|
|
|
|
// }
|
|
|
|
|
|
|
|
// @debug()
|
|
|
|
// private async unstageFile(node: CommitFileNode | StatusFileNode) {
|
|
|
|
// if (!(node instanceof CommitFileNode) && !(node instanceof StatusFileNode)) return;
|
|
|
|
|
|
|
|
// void (await Container.git.unStageFile(node.repoPath, node.file.fileName));
|
|
|
|
// void node.triggerChange();
|
|
|
|
// }
|
|
|
|
|
|
|
|
// @debug()
|
|
|
|
// private async unstageDirectory(node: FolderNode) {
|
|
|
|
// if (!(node instanceof FolderNode) || !node.relativePath) return;
|
|
|
|
|
|
|
|
// void (await Container.git.unStageDirectory(node.repoPath, node.relativePath));
|
|
|
|
// void node.triggerChange();
|
|
|
|
// }
|
|
|
|
|
|
|
|
// @debug()
|
|
|
|
// private unstar(node: BranchNode | RepositoryNode) {
|
|
|
|
// if (node instanceof BranchNode || node instanceof RepositoryNode) return node.unstar();
|
|
|
|
// return undefined;
|
|
|
|
// }
|
|
|
|
|
|
|
|
// @debug()
|
|
|
|
// private compareWithHead(node: ViewRefNode) {
|
|
|
|
// if (!(node instanceof ViewRefNode)) return undefined;
|
|
|
|
|
|
|
|
// return Container.compareView.compare(node.repoPath, node.ref, 'HEAD');
|
|
|
|
// }
|
|
|
|
|
|
|
|
// @debug()
|
|
|
|
// private compareWithRemote(node: BranchNode) {
|
|
|
|
// if (!(node instanceof BranchNode)) return undefined;
|
|
|
|
// if (!node.branch.tracking) return undefined;
|
|
|
|
|
|
|
|
// return Container.compareView.compare(node.repoPath, node.branch.tracking, node.ref);
|
|
|
|
// }
|
|
|
|
|
|
|
|
// @debug()
|
|
|
|
// private compareWithWorking(node: ViewRefNode) {
|
|
|
|
// if (!(node instanceof ViewRefNode)) return undefined;
|
|
|
|
|
|
|
|
// return Container.compareView.compare(node.repoPath, node.ref, '');
|
|
|
|
// }
|
|
|
|
|
|
|
|
// @debug()
|
|
|
|
// private async compareAncestryWithWorking(node: BranchNode) {
|
|
|
|
// if (!(node instanceof BranchNode)) return undefined;
|
|
|
|
|
|
|
|
// const branch = await Container.git.getBranch(node.repoPath);
|
|
|
|
// if (branch == null) return undefined;
|
|
|
|
|
|
|
|
// const commonAncestor = await Container.git.getMergeBase(node.repoPath, branch.ref, node.ref);
|
|
|
|
// if (commonAncestor == null) return undefined;
|
|
|
|
|
|
|
|
// return Container.compareView.compare(
|
|
|
|
// node.repoPath,
|
|
|
|
// { ref: commonAncestor, label: `ancestry with ${node.ref} (${GitRevision.shorten(commonAncestor)})` },
|
|
|
|
// '',
|
|
|
|
// );
|
|
|
|
// }
|
|
|
|
|
|
|
|
// @debug()
|
|
|
|
// private compareWithSelected(node: ViewRefNode) {
|
|
|
|
// if (!(node instanceof ViewRefNode)) return;
|
|
|
|
|
|
|
|
// Container.compareView.compareWithSelected(node.repoPath, node.ref);
|
|
|
|
// }
|
|
|
|
|
|
|
|
// @debug()
|
|
|
|
// private selectForCompare(node: ViewRefNode) {
|
|
|
|
// if (!(node instanceof ViewRefNode)) return;
|
|
|
|
|
|
|
|
// Container.compareView.selectForCompare(node.repoPath, node.ref);
|
|
|
|
// }
|
|
|
|
|
|
|
|
// @debug()
|
|
|
|
// private compareFileWithSelected(node: ViewRefFileNode) {
|
|
|
|
// if (this._selectedFile == null || !(node instanceof ViewRefFileNode) || node.ref == null) {
|
|
|
|
// return undefined;
|
|
|
|
// }
|
|
|
|
|
|
|
|
// if (this._selectedFile.repoPath !== node.repoPath) {
|
|
|
|
// this.selectFileForCompare(node);
|
|
|
|
// return undefined;
|
|
|
|
// }
|
|
|
|
|
|
|
|
// const selected = this._selectedFile;
|
|
|
|
|
|
|
|
// this._selectedFile = undefined;
|
|
|
|
// setCommandContext(CommandContext.ViewsCanCompareFile, false);
|
|
|
|
|
|
|
|
// const diffArgs: DiffWithCommandArgs = {
|
|
|
|
// repoPath: selected.repoPath,
|
|
|
|
// lhs: {
|
|
|
|
// sha: selected.ref,
|
|
|
|
// uri: selected.uri!,
|
|
|
|
// },
|
|
|
|
// rhs: {
|
|
|
|
// sha: node.ref,
|
|
|
|
// uri: node.uri,
|
|
|
|
// },
|
|
|
|
// };
|
|
|
|
// return commands.executeCommand(Commands.DiffWith, diffArgs);
|
|
|
|
// }
|
|
|
|
|
|
|
|
// private _selectedFile: CompareSelectedInfo | undefined;
|
|
|
|
|
|
|
|
// @debug()
|
|
|
|
// private selectFileForCompare(node: ViewRefFileNode) {
|
|
|
|
// if (!(node instanceof ViewRefFileNode) || node.ref == null) return;
|
|
|
|
|
|
|
|
// this._selectedFile = {
|
|
|
|
// ref: node.ref,
|
|
|
|
// repoPath: node.repoPath,
|
|
|
|
// uri: node.uri,
|
|
|
|
// };
|
|
|
|
// setCommandContext(CommandContext.ViewsCanCompareFile, true);
|
|
|
|
// }
|
|
|
|
|
|
|
|
// @debug()
|
|
|
|
// private openChanges(node: ViewRefFileNode | StatusFileNode) {
|
|
|
|
// if (!(node instanceof ViewRefFileNode) && !(node instanceof StatusFileNode)) return undefined;
|
|
|
|
|
|
|
|
// const command = node.getCommand();
|
|
|
|
// if (command == null || command.arguments == null) return undefined;
|
|
|
|
|
|
|
|
// const [uri, args] = command.arguments as [Uri, DiffWithPreviousCommandArgs];
|
|
|
|
// args.showOptions!.preview = false;
|
|
|
|
// return commands.executeCommand(command.command, uri, args);
|
|
|
|
// }
|
|
|
|
|
|
|
|
// @debug()
|
|
|
|
// private openChangesWithWorking(node: ViewRefFileNode | StatusFileNode) {
|
|
|
|
// if (!(node instanceof ViewRefFileNode) && !(node instanceof StatusFileNode)) return undefined;
|
|
|
|
|
|
|
|
// const args: DiffWithWorkingCommandArgs = {
|
|
|
|
// showOptions: {
|
|
|
|
// preserveFocus: true,
|
|
|
|
// preview: false,
|
|
|
|
// },
|
|
|
|
// };
|
|
|
|
// return commands.executeCommand(Commands.DiffWithWorking, node.uri, args);
|
|
|
|
// }
|
|
|
|
|
|
|
|
// @debug()
|
|
|
|
// private openFile(node: ViewRefFileNode | StatusFileNode | FileHistoryNode | LineHistoryNode) {
|
|
|
|
// if (
|
|
|
|
// !(node instanceof ViewRefFileNode) &&
|
|
|
|
// !(node instanceof StatusFileNode) &&
|
|
|
|
// !(node instanceof FileHistoryNode) &&
|
|
|
|
// !(node instanceof LineHistoryNode)
|
|
|
|
// ) {
|
|
|
|
// return undefined;
|
|
|
|
// }
|
|
|
|
|
|
|
|
// const args: OpenWorkingFileCommandArgs = {
|
|
|
|
// uri: node.uri,
|
|
|
|
// showOptions: {
|
|
|
|
// preserveFocus: true,
|
|
|
|
// preview: false,
|
|
|
|
// },
|
|
|
|
// };
|
|
|
|
// return commands.executeCommand(Commands.OpenWorkingFile, undefined, args);
|
|
|
|
// }
|
|
|
|
|
|
|
|
// @debug()
|
|
|
|
// private openFileRevision(
|
|
|
|
// node: CommitFileNode | ResultsFileNode | StashFileNode | StatusFileNode,
|
|
|
|
// options?: OpenFileRevisionCommandArgs,
|
|
|
|
// ) {
|
|
|
|
// if (
|
|
|
|
// !(node instanceof CommitFileNode) &&
|
|
|
|
// !(node instanceof StashFileNode) &&
|
|
|
|
// !(node instanceof ResultsFileNode) &&
|
|
|
|
// !(node instanceof StatusFileNode)
|
|
|
|
// ) {
|
|
|
|
// return undefined;
|
|
|
|
// }
|
|
|
|
|
|
|
|
// options = { showOptions: { preserveFocus: true, preview: false }, ...options };
|
|
|
|
|
|
|
|
// let uri = options.uri;
|
|
|
|
// if (uri == null) {
|
|
|
|
// if (node instanceof ResultsFileNode) {
|
|
|
|
// uri = GitUri.toRevisionUri(node.uri);
|
|
|
|
// } else {
|
|
|
|
// uri =
|
|
|
|
// node.commit.status === 'D'
|
|
|
|
// ? GitUri.toRevisionUri(
|
|
|
|
// node.commit.previousSha!,
|
|
|
|
// node.commit.previousUri.fsPath,
|
|
|
|
// node.commit.repoPath,
|
|
|
|
// )
|
|
|
|
// : GitUri.toRevisionUri(node.uri);
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
|
|
|
|
// return findOrOpenEditor(uri, options.showOptions || { preserveFocus: true, preview: false });
|
|
|
|
// }
|
|
|
|
|
|
|
|
// @debug()
|
|
|
|
// private openFileRevisionInRemote(node: CommitFileNode) {
|
|
|
|
// if (!(node instanceof CommitFileNode) || node instanceof StashFileNode) return undefined;
|
|
|
|
|
|
|
|
// const args: OpenFileInRemoteCommandArgs = {
|
|
|
|
// range: false,
|
|
|
|
// };
|
|
|
|
// return commands.executeCommand(
|
|
|
|
// Commands.OpenFileInRemote,
|
|
|
|
// node.commit.toGitUri(node.commit.status === 'D'),
|
|
|
|
// args,
|
|
|
|
// );
|
|
|
|
// }
|
|
|
|
|
|
|
|
// @debug()
|
|
|
|
// private async openChangedFiles(
|
|
|
|
// node: CommitNode | StashNode | ResultsFilesNode,
|
|
|
|
// options?: TextDocumentShowOptions,
|
|
|
|
// ) {
|
|
|
|
// if (!(node instanceof CommitNode) && !(node instanceof StashNode) && !(node instanceof ResultsFilesNode)) {
|
|
|
|
// return;
|
|
|
|
// }
|
|
|
|
|
|
|
|
// options = { preserveFocus: false, preview: false, ...options };
|
|
|
|
|
|
|
|
// let repoPath: string;
|
|
|
|
// let files;
|
|
|
|
// let ref: string;
|
|
|
|
|
|
|
|
// if (node instanceof ResultsFilesNode) {
|
|
|
|
// const { diff } = await node.getFilesQueryResults();
|
|
|
|
// if (diff == null || diff.length === 0) return;
|
|
|
|
|
|
|
|
// repoPath = node.repoPath;
|
|
|
|
// files = diff;
|
|
|
|
// ref = node.ref1 || node.ref2;
|
|
|
|
// } else {
|
|
|
|
// repoPath = node.commit.repoPath;
|
|
|
|
// files = node.commit.files;
|
|
|
|
// ref = node.commit.sha;
|
|
|
|
// }
|
|
|
|
|
|
|
|
// if (files.length > 20) {
|
|
|
|
// const result = await window.showWarningMessage(
|
|
|
|
// `Are your sure you want to open all ${files.length} files?`,
|
|
|
|
// { title: 'Yes' },
|
|
|
|
// { title: 'No', isCloseAffordance: true },
|
|
|
|
// );
|
|
|
|
// if (result == null || result.title === 'No') return;
|
|
|
|
// }
|
|
|
|
|
|
|
|
// for (const file of files) {
|
|
|
|
// const uri = GitUri.fromFile(file, repoPath, ref);
|
|
|
|
|
|
|
|
// const args: OpenWorkingFileCommandArgs = {
|
|
|
|
// uri: uri,
|
|
|
|
// showOptions: options,
|
|
|
|
// };
|
|
|
|
// await commands.executeCommand(Commands.OpenWorkingFile, undefined, args);
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
|
|
|
|
// @debug()
|
|
|
|
// private async openChangedFileDiffs(
|
|
|
|
// node: CommitNode | StashNode | ResultsFilesNode,
|
|
|
|
// options?: TextDocumentShowOptions,
|
|
|
|
// ) {
|
|
|
|
// if (!(node instanceof CommitNode) && !(node instanceof StashNode) && !(node instanceof ResultsFilesNode)) {
|
|
|
|
// return;
|
|
|
|
// }
|
|
|
|
|
|
|
|
// options = { preserveFocus: false, preview: false, ...options };
|
|
|
|
|
|
|
|
// let repoPath: string;
|
|
|
|
// let files;
|
|
|
|
// let ref1: string;
|
|
|
|
// let ref2: string;
|
|
|
|
|
|
|
|
// if (node instanceof ResultsFilesNode) {
|
|
|
|
// const { diff } = await node.getFilesQueryResults();
|
|
|
|
// if (diff == null || diff.length === 0) return;
|
|
|
|
|
|
|
|
// repoPath = node.repoPath;
|
|
|
|
// files = diff;
|
|
|
|
// ref1 = node.ref1;
|
|
|
|
// ref2 = node.ref2;
|
|
|
|
// } else {
|
|
|
|
// repoPath = node.commit.repoPath;
|
|
|
|
// files = node.commit.files;
|
|
|
|
// ref1 = node.commit.previousSha != null ? node.commit.previousSha : GitRevision.deletedOrMissing;
|
|
|
|
// ref2 = node.commit.sha;
|
|
|
|
// }
|
|
|
|
|
|
|
|
// if (files.length > 20) {
|
|
|
|
// const result = await window.showWarningMessage(
|
|
|
|
// `Are your sure you want to open all ${files.length} files?`,
|
|
|
|
// { title: 'Yes' },
|
|
|
|
// { title: 'No', isCloseAffordance: true },
|
|
|
|
// );
|
|
|
|
// if (result == null || result.title === 'No') return;
|
|
|
|
// }
|
|
|
|
|
|
|
|
// let diffArgs: DiffWithCommandArgs;
|
|
|
|
// for (const file of files) {
|
|
|
|
// if (file.status === 'A') continue;
|
|
|
|
|
|
|
|
// const uri1 = GitUri.fromFile(file, repoPath);
|
|
|
|
// const uri2 =
|
|
|
|
// file.status === 'R' || file.status === 'C' ? GitUri.fromFile(file, repoPath, ref2, true) : uri1;
|
|
|
|
|
|
|
|
// diffArgs = {
|
|
|
|
// repoPath: repoPath,
|
|
|
|
// lhs: { uri: uri1, sha: ref1 },
|
|
|
|
// rhs: { uri: uri2, sha: ref2 },
|
|
|
|
// showOptions: options,
|
|
|
|
// };
|
|
|
|
// void (await commands.executeCommand(Commands.DiffWith, diffArgs));
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
|
|
|
|
// @debug()
|
|
|
|
// private async openChangedFileDiffsWithWorking(
|
|
|
|
// node: CommitNode | StashNode | ResultsFilesNode,
|
|
|
|
// options?: TextDocumentShowOptions,
|
|
|
|
// ) {
|
|
|
|
// if (!(node instanceof CommitNode) && !(node instanceof StashNode) && !(node instanceof ResultsFilesNode)) {
|
|
|
|
// return;
|
|
|
|
// }
|
|
|
|
|
|
|
|
// options = { preserveFocus: false, preview: false, ...options };
|
|
|
|
|
|
|
|
// let repoPath: string;
|
|
|
|
// let files;
|
|
|
|
// let ref: string;
|
|
|
|
|
|
|
|
// if (node instanceof ResultsFilesNode) {
|
|
|
|
// const { diff } = await node.getFilesQueryResults();
|
|
|
|
// if (diff == null || diff.length === 0) return;
|
|
|
|
|
|
|
|
// repoPath = node.repoPath;
|
|
|
|
// files = diff;
|
|
|
|
// ref = node.ref1 || node.ref2;
|
|
|
|
// } else {
|
|
|
|
// repoPath = node.commit.repoPath;
|
|
|
|
// files = node.commit.files;
|
|
|
|
// ref = node.commit.sha;
|
|
|
|
// }
|
|
|
|
|
|
|
|
// if (files.length > 20) {
|
|
|
|
// const result = await window.showWarningMessage(
|
|
|
|
// `Are your sure you want to open all ${files.length} files?`,
|
|
|
|
// { title: 'Yes' },
|
|
|
|
// { title: 'No', isCloseAffordance: true },
|
|
|
|
// );
|
|
|
|
// if (result == null || result.title === 'No') return;
|
|
|
|
// }
|
|
|
|
|
|
|
|
// for (const file of files) {
|
|
|
|
// if (file.status === 'A' || file.status === 'D') continue;
|
|
|
|
|
|
|
|
// const args: DiffWithWorkingCommandArgs = {
|
|
|
|
// showOptions: options,
|
|
|
|
// };
|
|
|
|
|
|
|
|
// const uri = GitUri.fromFile(file, repoPath, ref);
|
|
|
|
// await commands.executeCommand(Commands.DiffWithWorking, uri, args);
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
|
|
|
|
// @debug()
|
|
|
|
// private async openChangedFileRevisions(
|
|
|
|
// node: CommitNode | StashNode | ResultsFilesNode,
|
|
|
|
// options?: TextDocumentShowOptions,
|
|
|
|
// ) {
|
|
|
|
// if (!(node instanceof CommitNode) && !(node instanceof StashNode) && !(node instanceof ResultsFilesNode)) {
|
|
|
|
// return;
|
|
|
|
// }
|
|
|
|
|
|
|
|
// options = { preserveFocus: false, preview: false, ...options };
|
|
|
|
|
|
|
|
// let repoPath: string;
|
|
|
|
// let files;
|
|
|
|
// let ref1: string;
|
|
|
|
// let ref2: string;
|
|
|
|
|
|
|
|
// if (node instanceof ResultsFilesNode) {
|
|
|
|
// const { diff } = await node.getFilesQueryResults();
|
|
|
|
// if (diff == null || diff.length === 0) return;
|
|
|
|
|
|
|
|
// repoPath = node.repoPath;
|
|
|
|
// files = diff;
|
|
|
|
// ref1 = node.ref1;
|
|
|
|
// ref2 = node.ref2;
|
|
|
|
// } else {
|
|
|
|
// repoPath = node.commit.repoPath;
|
|
|
|
// files = node.commit.files;
|
|
|
|
// ref1 = node.commit.sha;
|
|
|
|
// ref2 = node.commit.previousFileSha;
|
|
|
|
// }
|
|
|
|
|
|
|
|
// if (files.length > 20) {
|
|
|
|
// const result = await window.showWarningMessage(
|
|
|
|
// `Are your sure you want to open all ${files.length} files?`,
|
|
|
|
// { title: 'Yes' },
|
|
|
|
// { title: 'No', isCloseAffordance: true },
|
|
|
|
// );
|
|
|
|
// if (result == null || result.title === 'No') return;
|
|
|
|
// }
|
|
|
|
|
|
|
|
// for (const file of files) {
|
|
|
|
// const uri = GitUri.toRevisionUri(file.status === 'D' ? ref2 : ref1, file, repoPath);
|
|
|
|
|
|
|
|
// await findOrOpenEditor(uri, options);
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
|
|
|
|
// terminalCheckoutCommit(node: CommitNode) {
|
|
|
|
// if (!(node instanceof CommitNode)) return;
|
|
|
|
|
|
|
|
// runGitCommandInTerminal('checkout', `${node.ref}`, node.repoPath);
|
|
|
|
// }
|
|
|
|
|
|
|
|
// async terminalPushCommit(node: CommitNode) {
|
|
|
|
// if (!(node instanceof CommitNode)) return;
|
|
|
|
|
|
|
|
// const branch = node.branch || (await Container.git.getBranch(node.repoPath));
|
|
|
|
// if (branch == null) return;
|
|
|
|
|
|
|
|
// runGitCommandInTerminal(
|
|
|
|
// 'push',
|
|
|
|
// `${branch.getRemoteName()} ${node.ref}:${branch.getNameWithoutRemote()}`,
|
|
|
|
// node.repoPath,
|
|
|
|
// );
|
|
|
|
// }
|
|
|
|
|
|
|
|
// terminalRemoveRemote(node: RemoteNode) {
|
|
|
|
// if (!(node instanceof RemoteNode)) return;
|
|
|
|
|
|
|
|
// runGitCommandInTerminal('remote', `remove ${node.remote.name}`, node.remote.repoPath);
|
|
|
|
// }
|
|
|
|
|
|
|
|
export namespace Branch { |
|
|
|
export function create(repo?: string | Repository, ref?: GitReference, name?: string) { |
|
|
|
return executeGitCommand({ |
|
|
|