Refactors GitService to mostly use GitUris

This commit is contained in:
Eric Amodio
2017-03-18 01:15:50 -04:00
parent b51d25829b
commit 164cb2bfe0
20 changed files with 88 additions and 82 deletions

View File

@@ -35,20 +35,20 @@ export class DiffWithNextCommand extends ActiveEditorCommand {
try {
if (!gitUri.sha) {
// If the file is uncommitted, treat it as a DiffWithWorking
if (await this.git.isFileUncommitted(gitUri.fsPath, gitUri.repoPath)) {
if (await this.git.isFileUncommitted(gitUri)) {
return commands.executeCommand(Commands.DiffWithWorking, uri);
}
}
const sha = (commit && commit.sha) || gitUri.sha;
const log = await this.git.getLogForFile(gitUri.fsPath, undefined, gitUri.repoPath, rangeOrLine as Range, sha ? undefined : 2);
const log = await this.git.getLogForFile(gitUri.repoPath, gitUri.fsPath, undefined, rangeOrLine as Range, sha ? undefined : 2);
if (!log) return window.showWarningMessage(`Unable to open diff. File is probably not under source control`);
commit = (sha && log.commits.get(sha)) || Iterables.first(log.commits.values());
}
catch (ex) {
Logger.error('[GitLens.DiffWithNextCommand]', `getLogForFile(${gitUri.fsPath})`, ex);
Logger.error('[GitLens.DiffWithNextCommand]', `getLogForFile(${gitUri.repoPath}, ${gitUri.fsPath})`, ex);
return window.showErrorMessage(`Unable to open diff. See output channel for more details`);
}
}
@@ -59,8 +59,8 @@ export class DiffWithNextCommand extends ActiveEditorCommand {
try {
const [rhs, lhs] = await Promise.all([
this.git.getVersionedFile(commit.nextUri.fsPath, commit.repoPath, commit.nextSha),
this.git.getVersionedFile(commit.uri.fsPath, commit.repoPath, commit.sha)
this.git.getVersionedFile(commit.repoPath, commit.nextUri.fsPath, commit.nextSha),
this.git.getVersionedFile(commit.repoPath, commit.uri.fsPath, commit.sha)
]);
await commands.executeCommand(BuiltInCommands.Diff, Uri.file(lhs), Uri.file(rhs), `${path.basename(commit.uri.fsPath)} (${commit.shortSha}) ↔ ${path.basename(commit.nextUri.fsPath)} (${commit.nextShortSha})`);
return await commands.executeCommand(BuiltInCommands.RevealLine, { lineNumber: line, at: 'center' });