Consolidates certain getLogForFile usage patterns into getLogCommit

This commit is contained in:
Eric Amodio
2017-03-24 16:09:52 -04:00
parent ee40dc6325
commit c10a79a7ee
8 changed files with 40 additions and 35 deletions

View File

@@ -56,10 +56,7 @@ export class CopyMessageToClipboardCommand extends ActiveEditorCommand {
}
// Get the full commit message -- since blame only returns the summary
const log = await this.git.getLogForFile(gitUri.repoPath, gitUri.fsPath, sha, undefined, 1);
if (!log) return undefined;
const commit = log.commits.get(sha);
const commit = await this.git.getLogCommit(gitUri.repoPath, gitUri.fsPath, sha);
if (!commit) return undefined;
message = commit.message;

View File

@@ -1,5 +1,5 @@
'use strict';
import { Iterables } from '../system';
// import { Iterables } from '../system';
import { commands, TextEditor, Uri, window } from 'vscode';
import { ActiveEditorCommand, Commands } from './commands';
import { BuiltInCommands } from '../constants';
@@ -27,13 +27,11 @@ export class DiffWithWorkingCommand extends ActiveEditorCommand {
const gitUri = await GitUri.fromUri(uri, this.git);
try {
const log = await this.git.getLogForFile(gitUri.repoPath, gitUri.fsPath, gitUri.sha, undefined, gitUri.sha ? undefined : 1);
if (!log) return window.showWarningMessage(`Unable to open diff. File is probably not under source control`);
commit = (gitUri.sha && log.commits.get(gitUri.sha)) || Iterables.first(log.commits.values());
commit = await this.git.getLogCommit(gitUri.repoPath, gitUri.fsPath, gitUri.sha, { firstIfMissing: true });
if (!commit) return window.showWarningMessage(`Unable to open diff. File is probably not under source control`);
}
catch (ex) {
Logger.error('[GitLens.DiffWithWorkingCommand]', `getLogForFile(${gitUri.repoPath}, ${gitUri.fsPath})`, ex);
Logger.error('[GitLens.DiffWithWorkingCommand]', `getLogCommit(${gitUri.repoPath}, ${gitUri.fsPath}, ${gitUri.sha})`, ex);
return window.showErrorMessage(`Unable to open diff. See output channel for more details`);
}
}

View File

@@ -54,10 +54,8 @@ export class ShowQuickCommitFileDetailsCommand extends ActiveEditorCachedCommand
}
if (!fileLog) {
const log = await this.git.getLogForFile(commit ? commit.repoPath : gitUri.repoPath, commit ? commit.uri.fsPath : gitUri.fsPath, sha, undefined, 2);
if (!log) return window.showWarningMessage(`Unable to show commit file details`);
commit = log.commits.get(sha);
commit = await this.git.getLogCommit(commit ? commit.repoPath : gitUri.repoPath, commit ? commit.uri.fsPath : gitUri.fsPath, sha, { previous: true });
if (!commit) return window.showWarningMessage(`Unable to show commit file details`);
}
}