Skip to content

Commit 9c70620

Browse files
committed
Fixes issue with blame on versioned files
Stops falling back to the cached blame of the working file Handles git scheme urls properly
1 parent 9da80c1 commit 9c70620

File tree

2 files changed

+5
-18
lines changed

2 files changed

+5
-18
lines changed

src/git/gitUri.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -83,15 +83,15 @@ export class GitUri extends Uri {
8383

8484
if (!git.isTrackable(uri)) return new GitUri(uri, git.repoPath);
8585

86-
const gitUri = git.getGitUriForFile(uri.fsPath);
87-
if (gitUri) return gitUri;
88-
8986
// If this is a git uri, assume it is showing the most recent commit
90-
if (uri.scheme === DocumentSchemes.Git && uri.query === '~') {
87+
if (uri.scheme === DocumentSchemes.Git) {
9188
const commit = await git.getLogCommit(undefined, uri.fsPath);
92-
if (commit) return new GitUri(uri, commit);
89+
if (commit !== undefined) return new GitUri(uri, commit);
9390
}
9491

92+
const gitUri = git.getGitUriForFile(uri.fsPath);
93+
if (gitUri) return gitUri;
94+
9595
return new GitUri(uri, (await git.getRepoPathFromFile(uri.fsPath)) || git.repoPath);
9696
}
9797

src/gitService.ts

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -339,19 +339,6 @@ export class GitService extends Disposable {
339339
Logger.log(`Cached(${key}): getBlameForFile('${uri.repoPath}', '${uri.fsPath}', ${uri.sha})`);
340340
return cachedBlame.item;
341341
}
342-
343-
if (key !== 'blame') {
344-
// Since we are looking for partial blame, see if we have the blame of the whole file
345-
const cachedBlame = entry.get<ICachedBlame>('blame');
346-
if (cachedBlame !== undefined) {
347-
Logger.log(`? Cache(${key}): getBlameForFile('${uri.repoPath}', '${uri.fsPath}', ${uri.sha})`);
348-
const blame = await cachedBlame.item;
349-
if (blame !== undefined && blame.commits.has(uri.sha!)) {
350-
Logger.log(`Cached(${key}): getBlameForFile('${uri.repoPath}', '${uri.fsPath}', ${uri.sha})`);
351-
return cachedBlame.item;
352-
}
353-
}
354-
}
355342
}
356343

357344
Logger.log(`Not Cached(${key}): getBlameForFile('${uri.repoPath}', '${uri.fsPath}', ${uri.sha})`);

0 commit comments

Comments
 (0)