Git - fix regression with commits that contain addition/deletion/rename (#238349)
* Git - fix regression with commits that contain addition/deletion/rename * Fix compilation errorpull/238345/head^2
parent
98f16e88ef
commit
959d01a2a5
|
@ -3,7 +3,7 @@
|
|||
* Licensed under the MIT License. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import { workspace, Uri, Disposable, Event, EventEmitter, window, FileSystemProvider, FileChangeEvent, FileStat, FileType, FileChangeType, FileSystemError } from 'vscode';
|
||||
import { workspace, Uri, Disposable, Event, EventEmitter, window, FileSystemProvider, FileChangeEvent, FileStat, FileType, FileChangeType, FileSystemError, LogOutputChannel } from 'vscode';
|
||||
import { debounce, throttle } from './decorators';
|
||||
import { fromGitUri, toGitUri } from './uri';
|
||||
import { Model, ModelChangeEvent, OriginalResourceChangeEvent } from './model';
|
||||
|
@ -43,7 +43,7 @@ export class GitFileSystemProvider implements FileSystemProvider {
|
|||
private mtime = new Date().getTime();
|
||||
private disposables: Disposable[] = [];
|
||||
|
||||
constructor(private model: Model) {
|
||||
constructor(private readonly model: Model, private readonly logger: LogOutputChannel) {
|
||||
this.disposables.push(
|
||||
model.onDidChangeRepository(this.onDidChangeRepository, this),
|
||||
model.onDidChangeOriginalResource(this.onDidChangeOriginalResource, this),
|
||||
|
@ -136,6 +136,7 @@ export class GitFileSystemProvider implements FileSystemProvider {
|
|||
const { submoduleOf, path, ref } = fromGitUri(uri);
|
||||
const repository = submoduleOf ? this.model.getRepository(submoduleOf) : this.model.getRepository(uri);
|
||||
if (!repository) {
|
||||
this.logger.warn(`[GitFileSystemProvider][stat] Repository not found - ${uri.toString()}`);
|
||||
throw FileSystemError.FileNotFound();
|
||||
}
|
||||
|
||||
|
@ -181,6 +182,7 @@ export class GitFileSystemProvider implements FileSystemProvider {
|
|||
const repository = this.model.getRepository(uri);
|
||||
|
||||
if (!repository) {
|
||||
this.logger.warn(`[GitFileSystemProvider][readFile] Repository not found - ${uri.toString()}`);
|
||||
throw FileSystemError.FileNotFound();
|
||||
}
|
||||
|
||||
|
@ -192,6 +194,7 @@ export class GitFileSystemProvider implements FileSystemProvider {
|
|||
try {
|
||||
return await repository.buffer(sanitizeRef(ref, path, repository), path);
|
||||
} catch (err) {
|
||||
this.logger.warn(`[GitFileSystemProvider][readFile] File not found - ${uri.toString()}`);
|
||||
// File does not exist in git. This could be
|
||||
// because the file is untracked or ignored
|
||||
throw FileSystemError.FileNotFound();
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
import { Disposable, Event, EventEmitter, FileDecoration, FileDecorationProvider, SourceControlHistoryItem, SourceControlHistoryItemChange, SourceControlHistoryOptions, SourceControlHistoryProvider, ThemeIcon, Uri, window, LogOutputChannel, SourceControlHistoryItemRef, l10n, SourceControlHistoryItemRefsChangeEvent } from 'vscode';
|
||||
import { Repository, Resource } from './repository';
|
||||
import { IDisposable, deltaHistoryItemRefs, dispose, filterEvent, getCommitShortHash } from './util';
|
||||
import { toGitUri } from './uri';
|
||||
import { toMultiFileDiffEditorUris } from './uri';
|
||||
import { AvatarQuery, AvatarQueryCommit, Branch, LogOptions, Ref, RefType } from './api/git';
|
||||
import { emojify, ensureEmojis } from './emoji';
|
||||
import { Commit } from './git';
|
||||
|
@ -333,10 +333,8 @@ export class GitHistoryProvider implements SourceControlHistoryProvider, FileDec
|
|||
// History item change
|
||||
historyItemChanges.push({
|
||||
uri: historyItemUri,
|
||||
originalUri: toGitUri(change.originalUri, historyItemParentId),
|
||||
modifiedUri: toGitUri(change.uri, historyItemId),
|
||||
renameUri: change.renameUri,
|
||||
});
|
||||
...toMultiFileDiffEditorUris(change, historyItemParentId, historyItemId)
|
||||
} satisfies SourceControlHistoryItemChange);
|
||||
|
||||
// History item change decoration
|
||||
const letter = Resource.getStatusLetter(change.status);
|
||||
|
|
|
@ -112,7 +112,7 @@ async function createModel(context: ExtensionContext, logger: LogOutputChannel,
|
|||
const cc = new CommandCenter(git, model, context.globalState, logger, telemetryReporter);
|
||||
disposables.push(
|
||||
cc,
|
||||
new GitFileSystemProvider(model),
|
||||
new GitFileSystemProvider(model, logger),
|
||||
new GitDecorations(model),
|
||||
new GitBlameController(model),
|
||||
new GitTimelineProvider(model, cc),
|
||||
|
|
|
@ -64,12 +64,24 @@ export function toMergeUris(uri: Uri): { base: Uri; ours: Uri; theirs: Uri } {
|
|||
export function toMultiFileDiffEditorUris(change: Change, originalRef: string, modifiedRef: string): { originalUri: Uri | undefined; modifiedUri: Uri | undefined } {
|
||||
switch (change.status) {
|
||||
case Status.INDEX_ADDED:
|
||||
return { originalUri: undefined, modifiedUri: toGitUri(change.uri, modifiedRef) };
|
||||
return {
|
||||
originalUri: undefined,
|
||||
modifiedUri: toGitUri(change.uri, modifiedRef)
|
||||
};
|
||||
case Status.DELETED:
|
||||
return { originalUri: toGitUri(change.uri, originalRef), modifiedUri: undefined };
|
||||
return {
|
||||
originalUri: toGitUri(change.uri, originalRef),
|
||||
modifiedUri: undefined
|
||||
};
|
||||
case Status.INDEX_RENAMED:
|
||||
return { originalUri: toGitUri(change.originalUri, originalRef), modifiedUri: toGitUri(change.uri, modifiedRef) };
|
||||
return {
|
||||
originalUri: toGitUri(change.originalUri, originalRef),
|
||||
modifiedUri: toGitUri(change.uri, modifiedRef)
|
||||
};
|
||||
default:
|
||||
return { originalUri: toGitUri(change.uri, originalRef), modifiedUri: toGitUri(change.uri, modifiedRef) };
|
||||
return {
|
||||
originalUri: toGitUri(change.uri, originalRef),
|
||||
modifiedUri: toGitUri(change.uri, modifiedRef)
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
|
@ -212,8 +212,7 @@ class MainThreadSCMHistoryProvider implements ISCMHistoryProvider {
|
|||
return changes?.map(change => ({
|
||||
uri: URI.revive(change.uri),
|
||||
originalUri: change.originalUri && URI.revive(change.originalUri),
|
||||
modifiedUri: change.modifiedUri && URI.revive(change.modifiedUri),
|
||||
renameUri: change.renameUri && URI.revive(change.renameUri)
|
||||
modifiedUri: change.modifiedUri && URI.revive(change.modifiedUri)
|
||||
}));
|
||||
}
|
||||
|
||||
|
|
|
@ -1622,7 +1622,6 @@ export interface SCMHistoryItemChangeDto {
|
|||
readonly uri: UriComponents;
|
||||
readonly originalUri: UriComponents | undefined;
|
||||
readonly modifiedUri: UriComponents | undefined;
|
||||
readonly renameUri: UriComponents | undefined;
|
||||
}
|
||||
|
||||
export interface MainThreadSCMShape extends IDisposable {
|
||||
|
|
|
@ -98,5 +98,4 @@ export interface ISCMHistoryItemChange {
|
|||
readonly uri: URI;
|
||||
readonly originalUri?: URI;
|
||||
readonly modifiedUri?: URI;
|
||||
readonly renameUri?: URI;
|
||||
}
|
||||
|
|
|
@ -72,7 +72,6 @@ declare module 'vscode' {
|
|||
readonly uri: Uri;
|
||||
readonly originalUri: Uri | undefined;
|
||||
readonly modifiedUri: Uri | undefined;
|
||||
readonly renameUri: Uri | undefined;
|
||||
}
|
||||
|
||||
export interface SourceControlHistoryItemRefsChangeEvent {
|
||||
|
|
Loading…
Reference in New Issue