Reduces git calls on known untrackables

This commit is contained in:
Eric Amodio
2017-05-15 01:50:09 -04:00
parent 3a38f6ae39
commit ce5ff1eb47
3 changed files with 18 additions and 11 deletions

View File

@@ -72,17 +72,19 @@ export class GitUri extends Uri {
}
getRelativePath(): string {
return GitService.normalizePath(path.relative(this.repoPath || '', this.fsPath));
return GitService.normalizePath(path.relative(this.repoPath || '', this.fsPath));
}
static async fromUri(uri: Uri, git: GitService) {
if (uri instanceof GitUri) return uri;
if (!git.isTrackable(uri)) return new GitUri(uri, git.repoPath);
const gitUri = git.getGitUriForFile(uri.fsPath);
if (gitUri) return gitUri;
// If this is a git uri, assume it is showing the most recent commit
if (uri.scheme === 'git' && uri.query === '~') {
if (uri.scheme === DocumentSchemes.Git && uri.query === '~') {
const commit = await git.getLogCommit(undefined, uri.fsPath);
if (commit) return new GitUri(uri, commit);
}