Git - use commit id for the left-hand editor (#194302)

* Git - use commit id for the left-hand editor

* Remove console.log
This commit is contained in:
Ladislau Szomoru
2023-09-27 16:24:35 +02:00
committed by GitHub
parent d2302f42d5
commit 707e061b3a

View File

@@ -102,13 +102,19 @@ export class GitHistoryProvider implements SourceControlHistoryProvider, FileDec
}
async provideHistoryItemChanges(historyItemId: string): Promise<SourceControlHistoryItemChange[]> {
const [ref1, ref2] = historyItemId.includes('..')
? historyItemId.split('..')
: [`${historyItemId}^`, historyItemId];
// The "All Changes" history item uses a special id
// which is a commit range instead of a single commit id
let [originalRef, modifiedRef] = historyItemId.includes('..')
? historyItemId.split('..') : [undefined, historyItemId];
if (!originalRef) {
const commit = await this.repository.getCommit(modifiedRef);
originalRef = commit.parents.length > 0 ? commit.parents[0] : `${modifiedRef}^`;
}
const historyItemChangesUri: Uri[] = [];
const historyItemChanges: SourceControlHistoryItemChange[] = [];
const changes = await this.repository.diffBetween(ref1, ref2);
const changes = await this.repository.diffBetween(originalRef, modifiedRef);
for (const change of changes) {
const historyItemUri = change.uri.with({
@@ -118,8 +124,8 @@ export class GitHistoryProvider implements SourceControlHistoryProvider, FileDec
// History item change
historyItemChanges.push({
uri: historyItemUri,
originalUri: toGitUri(change.originalUri, ref1),
modifiedUri: toGitUri(change.originalUri, ref2),
originalUri: toGitUri(change.originalUri, originalRef),
modifiedUri: toGitUri(change.originalUri, modifiedRef),
renameUri: change.renameUri,
});