瀏覽代碼

Changes commit search by sha to jump to commit directly

main
Eric Amodio 6 年之前
父節點
當前提交
6ac6ebda3b
共有 2 個文件被更改,包括 47 次插入31 次删除
  1. +4
    -0
      CHANGELOG.md
  2. +43
    -31
      src/commands/showCommitSearch.ts

+ 4
- 0
CHANGELOG.md 查看文件

@ -4,6 +4,10 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](http://keepachangelog.com/) and this project adheres to [Semantic Versioning](http://semver.org/).
## [Unreleased]
### Changed
- Changes commit search by sha to jump directly to the commit (if one is found), rather than having to click through to the commit
## [8.5.3] - 2018-07-25
### Fixed
- Fixes [#454](https://github.com/eamodio/vscode-gitlens/issues/454) - Search for string returns merge commits (unlike raw `git log -S`)

+ 43
- 31
src/commands/showCommitSearch.ts 查看文件

@ -6,6 +6,7 @@ import { GitRepoSearchBy, GitService, GitUri } from '../gitService';
import { Logger } from '../logger';
import { CommandQuickPickItem, CommitsQuickPick, ShowCommitsSearchInResultsQuickPickItem } from '../quickpicks';
import { Strings } from '../system';
import { Iterables } from '../system/iterable';
import { ActiveEditorCachedCommand, Commands, getCommandUri, getRepoPathOrActiveOrPrompt } from './common';
import { ShowQuickCommitDetailsCommandArgs } from './showQuickCommitDetails';
@ -125,7 +126,7 @@ export class ShowCommitSearchCommand extends ActiveEditorCachedCommand {
if (progressCancellation.token.isCancellationRequested) return undefined;
const goBackCommand =
let goBackCommand: CommandQuickPickItem | undefined =
args.goBackCommand ||
new CommandQuickPickItem(
{
@ -136,37 +137,48 @@ export class ShowCommitSearchCommand extends ActiveEditorCachedCommand {
[uri, originalArgs]
);
const pick = await CommitsQuickPick.show(log, searchLabel!, progressCancellation, {
goBackCommand: goBackCommand,
showAllCommand:
log !== undefined && log.truncated
? new CommandQuickPickItem(
{
label: `$(sync) Show All Commits`,
description: `${Strings.pad(GlyphChars.Dash, 2, 3)} this may take a while`
},
Commands.ShowCommitSearch,
[uri, { ...args, maxCount: 0, goBackCommand: goBackCommand }]
)
: undefined,
showInResultsExplorerCommand:
log !== undefined ? new ShowCommitsSearchInResultsQuickPickItem(log, searchLabel!) : undefined
});
if (pick === undefined) return undefined;
if (pick instanceof CommandQuickPickItem) return pick.execute();
let commit;
if (args.searchBy !== GitRepoSearchBy.Sha || log === undefined || log.count !== 1) {
const pick = await CommitsQuickPick.show(log, searchLabel!, progressCancellation, {
goBackCommand: goBackCommand,
showAllCommand:
log !== undefined && log.truncated
? new CommandQuickPickItem(
{
label: `$(sync) Show All Commits`,
description: `${Strings.pad(GlyphChars.Dash, 2, 3)} this may take a while`
},
Commands.ShowCommitSearch,
[uri, { ...args, maxCount: 0, goBackCommand: goBackCommand }]
)
: undefined,
showInResultsExplorerCommand:
log !== undefined ? new ShowCommitsSearchInResultsQuickPickItem(log, searchLabel!) : undefined
});
if (pick === undefined) return undefined;
if (pick instanceof CommandQuickPickItem) return pick.execute();
commit = pick.commit;
goBackCommand = undefined;
}
else {
commit = Iterables.first(log.commits.values());
}
return commands.executeCommand(Commands.ShowQuickCommitDetails, pick.commit.toGitUri(), {
sha: pick.commit.sha,
commit: pick.commit,
goBackCommand: new CommandQuickPickItem(
{
label: `go back ${GlyphChars.ArrowBack}`,
description: `${Strings.pad(GlyphChars.Dash, 2, 2)} to search for ${searchLabel}`
},
Commands.ShowCommitSearch,
[uri, args]
)
return commands.executeCommand(Commands.ShowQuickCommitDetails, commit.toGitUri(), {
sha: commit.sha,
commit: commit,
goBackCommand:
goBackCommand ||
new CommandQuickPickItem(
{
label: `go back ${GlyphChars.ArrowBack}`,
description: `${Strings.pad(GlyphChars.Dash, 2, 2)} to search for ${searchLabel}`
},
Commands.ShowCommitSearch,
[uri, args]
)
} as ShowQuickCommitDetailsCommandArgs);
}
catch (ex) {

Loading…
取消
儲存