Skip to content

Commit 15bfc40

Browse files
committed
smaller footprint
1 parent 5d60b7f commit 15bfc40

5 files changed

Lines changed: 18 additions & 30 deletions

File tree

extensions/git/src/commands.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import { CommitOptions, ForcePushMode, Git, Stash } from './git';
1414
import { Model } from './model';
1515
import { Repository, Resource, ResourceGroupType } from './repository';
1616
import { applyLineChanges, getModifiedRange, intersectDiffWithRange, invertLineChange, toLineRanges } from './staging';
17-
import { fromGitUri, toGitFSUri } from './uri';
17+
import { fromGitUri, toGitUri } from './uri';
1818
import { grep, isDescendant, pathEquals } from './util';
1919

2020
const localize = nls.loadMessageBundle();
@@ -291,7 +291,7 @@ export class CommandCenter {
291291
const repository = this.model.getRepositoryForSubmodule(resource.resourceUri);
292292

293293
if (repository) {
294-
right = toGitFSUri(resource.resourceUri, resource.resourceGroupType === ResourceGroupType.Index ? 'index' : 'wt', { submoduleOf: repository.root });
294+
right = toGitUri(resource.resourceUri, resource.resourceGroupType === ResourceGroupType.Index ? 'index' : 'wt', { submoduleOf: repository.root });
295295
}
296296
} else {
297297
if (resource.type !== Status.DELETED_BY_THEM) {
@@ -334,7 +334,7 @@ export class CommandCenter {
334334
const repository = this.model.getRepository(uri);
335335

336336
if (!repository) {
337-
return toGitFSUri(uri, ref);
337+
return toGitUri(uri, ref);
338338
}
339339

340340
try {
@@ -350,7 +350,7 @@ export class CommandCenter {
350350
const { mimetype } = await repository.detectObjectType(object);
351351

352352
if (mimetype === 'text/plain') {
353-
return toGitFSUri(uri, ref);
353+
return toGitUri(uri, ref);
354354
}
355355

356356
if (size > 1000000) { // 1 MB
@@ -365,7 +365,7 @@ export class CommandCenter {
365365
return Uri.parse(`data:;label:${path.basename(uri.fsPath)};description:${gitRef},`);
366366

367367
} catch (err) {
368-
return toGitFSUri(uri, ref);
368+
return toGitUri(uri, ref);
369369
}
370370
}
371371

@@ -1012,7 +1012,7 @@ export class CommandCenter {
10121012
return;
10131013
}
10141014

1015-
const originalUri = toGitFSUri(modifiedUri, '~');
1015+
const originalUri = toGitUri(modifiedUri, '~');
10161016
const originalDocument = await workspace.openTextDocument(originalUri);
10171017
const result = applyLineChanges(originalDocument, modifiedDocument, changes);
10181018

@@ -1060,7 +1060,7 @@ export class CommandCenter {
10601060
return;
10611061
}
10621062

1063-
const originalUri = toGitFSUri(modifiedUri, '~');
1063+
const originalUri = toGitUri(modifiedUri, '~');
10641064
const originalDocument = await workspace.openTextDocument(originalUri);
10651065
const selectionsBeforeRevert = textEditor.selections;
10661066
const visibleRangesBeforeRevert = textEditor.visibleRanges;
@@ -1127,7 +1127,7 @@ export class CommandCenter {
11271127
return;
11281128
}
11291129

1130-
const originalUri = toGitFSUri(modifiedUri, 'HEAD');
1130+
const originalUri = toGitUri(modifiedUri, 'HEAD');
11311131
const originalDocument = await workspace.openTextDocument(originalUri);
11321132
const selectedLines = toLineRanges(textEditor.selections, modifiedDocument);
11331133
const selectedDiffs = diffs

extensions/git/src/contentProvider.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
import { workspace, Uri, Disposable, Event, EventEmitter, window } from 'vscode';
77
import { debounce, throttle } from './decorators';
8-
import { fromGitUri, toGitFSUri } from './uri';
8+
import { fromGitUri, toGitUri } from './uri';
99
import { Model, ModelChangeEvent, OriginalResourceChangeEvent } from './model';
1010
import { filterEvent, eventToPromise, isDescendant, pathEquals } from './util';
1111

@@ -50,7 +50,7 @@ export class GitContentProvider {
5050
return;
5151
}
5252

53-
this._onDidChange.fire(toGitFSUri(uri, '', { replaceFileExtension: true }));
53+
this._onDidChange.fire(toGitUri(uri, '', { replaceFileExtension: true }));
5454
}
5555

5656
@debounce(1100)

extensions/git/src/fileSystemProvider.ts

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@
55

66
import { workspace, Uri, Disposable, Event, EventEmitter, window, FileSystemProvider, FileChangeEvent, FileStat, FileType, FileChangeType, FileSystemError } from 'vscode';
77
import { debounce, throttle } from './decorators';
8-
import { fromGitUri, toGitFSUri } from './uri';
8+
import { fromGitUri, toGitUri } from './uri';
99
import { Model, ModelChangeEvent, OriginalResourceChangeEvent } from './model';
10-
import { filterEvent, eventToPromise, isDescendant, pathEquals } from './util';
10+
import { filterEvent, eventToPromise, isDescendant, pathEquals, EmptyDisposable } from './util';
1111

1212
interface CacheRow {
1313
uri: Uri;
@@ -46,7 +46,7 @@ export class GitFileSystemProvider implements FileSystemProvider {
4646
return;
4747
}
4848

49-
const gitUri = toGitFSUri(uri, '', { replaceFileExtension: true });
49+
const gitUri = toGitUri(uri, '', { replaceFileExtension: true });
5050
this._onDidChangeFile.fire([{ type: FileChangeType.Changed, uri: gitUri }]);
5151
}
5252

@@ -102,10 +102,8 @@ export class GitFileSystemProvider implements FileSystemProvider {
102102
this.cache = cache;
103103
}
104104

105-
//#region File System Provider
106-
107105
watch(): Disposable {
108-
throw new Error('Method not implemented.');
106+
return EmptyDisposable;
109107
}
110108

111109
stat(uri: Uri): FileStat {
@@ -185,8 +183,6 @@ export class GitFileSystemProvider implements FileSystemProvider {
185183
throw new Error('Method not implemented.');
186184
}
187185

188-
//#endregion File System Provider
189-
190186
dispose(): void {
191187
this.disposables.forEach(d => d.dispose());
192188
}

extensions/git/src/repository.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import { AutoFetcher } from './autofetch';
1212
import { debounce, memoize, throttle } from './decorators';
1313
import { Commit, CommitOptions, ForcePushMode, GitError, Repository as BaseRepository, Stash, Submodule } from './git';
1414
import { StatusBarCommands } from './statusbar';
15-
import { toGitFSUri } from './uri';
15+
import { toGitUri } from './uri';
1616
import { anyEvent, combinedDisposable, debounceEvent, dispose, EmptyDisposable, eventToPromise, filterEvent, find, IDisposable, isDescendant, onceEvent } from './util';
1717
import { IFileWatcher, watch } from './watch';
1818

@@ -834,7 +834,7 @@ export class Repository implements Disposable {
834834
return;
835835
}
836836

837-
return toGitFSUri(uri, '', { replaceFileExtension: true });
837+
return toGitUri(uri, '', { replaceFileExtension: true });
838838
}
839839

840840
async getInputTemplate(): Promise<string> {

extensions/git/src/uri.ts

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ export interface GitUriOptions {
2323
// As a mitigation for extensions like ESLint showing warnings and errors
2424
// for git URIs, let's change the file extension of these uris to .git,
2525
// when `replaceFileExtension` is true.
26-
function _toGitUri(scheme: string, uri: Uri, ref: string, options: GitUriOptions = {}): Uri {
26+
export function toGitUri(uri: Uri, ref: string, options: GitUriOptions = {}): Uri {
2727
const params: GitUriParams = {
2828
path: uri.fsPath,
2929
ref
@@ -42,16 +42,8 @@ function _toGitUri(scheme: string, uri: Uri, ref: string, options: GitUriOptions
4242
}
4343

4444
return uri.with({
45-
scheme,
45+
scheme: 'gitfs',
4646
path,
4747
query: JSON.stringify(params)
4848
});
4949
}
50-
51-
export function toGitUri(uri: Uri, ref: string, options: GitUriOptions = {}): Uri {
52-
return _toGitUri('git', uri, ref, options);
53-
}
54-
55-
export function toGitFSUri(uri: Uri, ref: string, options: GitUriOptions = {}): Uri {
56-
return _toGitUri('gitfs', uri, ref, options);
57-
}

0 commit comments

Comments
 (0)