Browse Source

Switches to returning uris for versioned files

To allow greater flexibility in how versioned files are implemented
main
Eric Amodio 6 years ago
parent
commit
b5f94fc19c
3 changed files with 11 additions and 8 deletions
  1. +2
    -3
      src/commands/common.ts
  2. +2
    -2
      src/commands/diffWith.ts
  3. +7
    -3
      src/gitService.ts

+ 2
- 3
src/commands/common.ts View File

@ -405,9 +405,8 @@ export async function openEditor(
if (uri.scheme === DocumentSchemes.GitLensGit) {
const gitUri = GitUri.fromRevisionUri(uri);
if (ImageExtensions.includes(path.extname(gitUri.fsPath))) {
const fileName = await Container.git.getVersionedFile(gitUri.repoPath, gitUri.fsPath, gitUri.sha);
if (fileName !== undefined) {
uri = Uri.file(fileName);
const uri = await Container.git.getVersionedFile(gitUri.repoPath, gitUri.fsPath, gitUri.sha);
if (uri !== undefined) {
await commands.executeCommand(BuiltInCommands.Open, uri);
return undefined;

+ 2
- 2
src/commands/diffWith.ts View File

@ -164,10 +164,10 @@ export class DiffWithCommand extends ActiveEditorCommand {
BuiltInCommands.Diff,
lhs === undefined
? GitUri.toRevisionUri(GitService.deletedSha, args.lhs.uri.fsPath, args.repoPath)
: Uri.file(lhs),
: lhs,
rhs === undefined
? GitUri.toRevisionUri(GitService.deletedSha, args.rhs.uri.fsPath, args.repoPath)
: Uri.file(rhs),
: rhs,
title,
args.showOptions
);

+ 7
- 3
src/gitService.ts View File

@ -1611,13 +1611,17 @@ export class GitService extends Disposable {
return GitTagParser.parse(data, repoPath) || [];
}
async getVersionedFile(repoPath: string | undefined, fileName: string, sha: string | undefined) {
async getVersionedFile(
repoPath: string | undefined,
fileName: string,
sha: string | undefined
): Promise<Uri | undefined> {
Logger.log(`getVersionedFile('${repoPath}', '${fileName}', '${sha}')`);
if (sha === GitService.deletedSha) return undefined;
if (!sha || (Git.isUncommitted(sha) && !Git.isStagedUncommitted(sha))) {
if (await this.fileExists(repoPath!, fileName)) return fileName;
if (await this.fileExists(repoPath!, fileName)) return Uri.file(fileName);
return undefined;
}
@ -1630,7 +1634,7 @@ export class GitService extends Disposable {
new GitUri(Uri.file(fileName), { sha: sha, repoPath: repoPath!, versionedPath: file })
);
return file;
return Uri.file(file);
}
getVersionedFileText(repoPath: string, fileName: string, sha: string) {

Loading…
Cancel
Save