mirror of
https://github.com/ckaczor/vscode-gitlens.git
synced 2026-01-17 17:25:51 -05:00
Refactors GitService to mostly use GitUris
This commit is contained in:
@@ -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' });
|
||||
|
||||
Reference in New Issue
Block a user