mirror of
https://github.com/Microsoft/vscode
synced 2024-07-07 19:50:26 +00:00
Git - adopt _workbench.openMultiDiffEditor command (#202236)
This commit is contained in:
parent
effbda690c
commit
8720ead44d
|
@ -3550,14 +3550,16 @@ export class CommandCenter {
|
|||
return;
|
||||
}
|
||||
|
||||
const args: [Uri, Uri | undefined, Uri | undefined][] = [];
|
||||
const title = `Git Stash #${stash.index}: ${stash.description}`;
|
||||
const multiDiffSourceUri = toGitUri(Uri.file(repository.root), `stash@{${stash.index}}`, { scheme: 'git-stash' });
|
||||
|
||||
const resources: { originalUri: Uri; modifiedUri: Uri }[] = [];
|
||||
for (const file of stashFiles) {
|
||||
const fileUri = Uri.file(path.join(repository.root, file));
|
||||
args.push([fileUri, fileUri, toGitUri(fileUri, `stash@{${stash.index}}`)]);
|
||||
resources.push({ originalUri: fileUri, modifiedUri: toGitUri(fileUri, `stash@{${stash.index}}`) });
|
||||
}
|
||||
|
||||
commands.executeCommand('vscode.changes', `Git Stash #${stash.index}: ${stash.description}`, args);
|
||||
commands.executeCommand('_workbench.openMultiDiffEditor', { multiDiffSourceUri, title, resources });
|
||||
}
|
||||
|
||||
private async pickStash(repository: Repository, placeHolder: string): Promise<Stash | undefined> {
|
||||
|
@ -3649,16 +3651,19 @@ export class CommandCenter {
|
|||
const commit = await repository.getCommit(item.ref);
|
||||
const commitFiles = await repository.getCommitFiles(item.ref);
|
||||
|
||||
const args: [Uri, Uri | undefined, Uri | undefined][] = [];
|
||||
const title = `${item.shortRef} - ${commit.message}`;
|
||||
const multiDiffSourceUri = toGitUri(Uri.file(repository.root), item.ref, { scheme: 'git-commit' });
|
||||
|
||||
const resources: { originalUri: Uri; modifiedUri: Uri }[] = [];
|
||||
for (const commitFile of commitFiles) {
|
||||
const commitFileUri = Uri.file(path.join(repository.root, commitFile));
|
||||
args.push([commitFileUri, toGitUri(commitFileUri, item.previousRef), toGitUri(commitFileUri, item.ref)]);
|
||||
resources.push({ originalUri: toGitUri(commitFileUri, item.previousRef), modifiedUri: toGitUri(commitFileUri, item.ref) });
|
||||
}
|
||||
|
||||
return {
|
||||
command: 'vscode.changes',
|
||||
command: '_workbench.openMultiDiffEditor',
|
||||
title: l10n.t('Open Commit'),
|
||||
arguments: [`${item.shortRef} - ${commit.message}`, args, options]
|
||||
arguments: [{ multiDiffSourceUri, title, resources }, options]
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -3827,9 +3832,9 @@ export class CommandCenter {
|
|||
|
||||
const historyProvider = repository.historyProvider;
|
||||
const historyItemParentId = historyItem.parentIds.length > 0 ? historyItem.parentIds[0] : undefined;
|
||||
const historyItemChanges = await historyProvider.provideHistoryItemChanges(historyItem.id, historyItemParentId);
|
||||
const commitFiles = await historyProvider.provideHistoryItemChanges(historyItem.id, historyItemParentId);
|
||||
|
||||
if (historyItemChanges.length === 0) {
|
||||
if (commitFiles.length === 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -3837,9 +3842,10 @@ export class CommandCenter {
|
|||
const originalShortRef = historyItem.parentIds.length > 0 ? historyItem.parentIds[0].substring(0, 8) : `${modifiedShortRef}^`;
|
||||
|
||||
const title = l10n.t('Changes ({0} ↔ {1})', originalShortRef, modifiedShortRef);
|
||||
const args = historyItemChanges.map(change => [change.uri, change.originalUri, change.modifiedUri]);
|
||||
const multiDiffSourceUri = toGitUri(Uri.file(repository.root), historyItem.id, { scheme: 'git-commit' });
|
||||
const resources = commitFiles.map(change => ({ originalUri: change.originalUri, modifiedUri: change.modifiedUri }));
|
||||
|
||||
commands.executeCommand('vscode.changes', title, args);
|
||||
commands.executeCommand('_workbench.openMultiDiffEditor', { multiDiffSourceUri, title, resources });
|
||||
}
|
||||
|
||||
private createCommand(id: string, key: string, method: Function, options: ScmCommandOptions): (...args: any[]) => any {
|
||||
|
|
|
@ -20,6 +20,7 @@ export function fromGitUri(uri: Uri): GitUriParams {
|
|||
}
|
||||
|
||||
export interface GitUriOptions {
|
||||
scheme?: string;
|
||||
replaceFileExtension?: boolean;
|
||||
submoduleOf?: string;
|
||||
}
|
||||
|
@ -45,11 +46,7 @@ export function toGitUri(uri: Uri, ref: string, options: GitUriOptions = {}): Ur
|
|||
path = `${path}.diff`;
|
||||
}
|
||||
|
||||
return uri.with({
|
||||
scheme: 'git',
|
||||
path,
|
||||
query: JSON.stringify(params)
|
||||
});
|
||||
return uri.with({ scheme: options.scheme ?? 'git', path, query: JSON.stringify(params) });
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in New Issue
Block a user