|
|
@ -23,8 +23,6 @@ export class ShowCommitsInViewCommand extends ActiveEditorCommand { |
|
|
|
args = { ...args }; |
|
|
|
|
|
|
|
if (args.refs === undefined) { |
|
|
|
if (editor == null) return undefined; |
|
|
|
|
|
|
|
uri = getCommandUri(uri, editor); |
|
|
|
if (uri == null) return undefined; |
|
|
|
|
|
|
@ -32,23 +30,33 @@ export class ShowCommitsInViewCommand extends ActiveEditorCommand { |
|
|
|
|
|
|
|
args.repoPath = gitUri.repoPath; |
|
|
|
|
|
|
|
try { |
|
|
|
// Check for any uncommitted changes in the range
|
|
|
|
const blame = editor.document.isDirty |
|
|
|
? await Container.git.getBlameForRangeContents(gitUri, editor.selection, editor.document.getText()) |
|
|
|
: await Container.git.getBlameForRange(gitUri, editor.selection); |
|
|
|
if (blame === undefined) { |
|
|
|
return Messages.showFileNotUnderSourceControlWarningMessage( |
|
|
|
'Unable to show commits in Search Commits view' |
|
|
|
); |
|
|
|
if (editor != null) { |
|
|
|
try { |
|
|
|
// Check for any uncommitted changes in the range
|
|
|
|
const blame = editor.document.isDirty |
|
|
|
? await Container.git.getBlameForRangeContents( |
|
|
|
gitUri, |
|
|
|
editor.selection, |
|
|
|
editor.document.getText() |
|
|
|
) |
|
|
|
: await Container.git.getBlameForRange(gitUri, editor.selection); |
|
|
|
if (blame === undefined) { |
|
|
|
return Messages.showFileNotUnderSourceControlWarningMessage( |
|
|
|
'Unable to show commits in Search Commits view' |
|
|
|
); |
|
|
|
} |
|
|
|
|
|
|
|
args.refs = [ |
|
|
|
...Iterables.filterMap(blame.commits.values(), c => (c.isUncommitted ? undefined : c.ref)) |
|
|
|
]; |
|
|
|
} catch (ex) { |
|
|
|
Logger.error(ex, 'ShowCommitsInViewCommand', 'getBlameForRange'); |
|
|
|
return Messages.showGenericErrorMessage('Unable to show commits in Search Commits view'); |
|
|
|
} |
|
|
|
} else { |
|
|
|
if (gitUri.sha == null) return undefined; |
|
|
|
|
|
|
|
args.refs = [ |
|
|
|
...Iterables.filterMap(blame.commits.values(), c => (c.isUncommitted ? undefined : c.ref)) |
|
|
|
]; |
|
|
|
} catch (ex) { |
|
|
|
Logger.error(ex, 'ShowCommitsInViewCommand', 'getBlameForRange'); |
|
|
|
return Messages.showGenericErrorMessage('Unable to show commits in Search Commits view'); |
|
|
|
args.refs = [gitUri.sha]; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|