mirror of
https://github.com/ckaczor/vscode-gitlens.git
synced 2026-01-24 01:35:37 -05:00
Consolidates certain getLogForFile usage patterns into getLogCommit
This commit is contained in:
@@ -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;
|
||||
|
||||
@@ -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`);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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`);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user