From 74429a474828c5a6d515aa418c0333a9d4394625 Mon Sep 17 00:00:00 2001 From: Eric Amodio Date: Sat, 21 Oct 2017 12:52:24 -0400 Subject: [PATCH] Adds more commit search support for #127 Adds ~ to search for changes Adds = to search for changes with new occurrences only --- src/commands/showCommitSearch.ts | 14 +++++++++++++- src/gitService.ts | 8 ++++++++ 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/src/commands/showCommitSearch.ts b/src/commands/showCommitSearch.ts index e367f62..9185803 100644 --- a/src/commands/showCommitSearch.ts +++ b/src/commands/showCommitSearch.ts @@ -9,9 +9,11 @@ import { Messages } from '../messages'; import { CommandQuickPickItem, CommitsQuickPick } from '../quickPicks'; import { ShowQuickCommitDetailsCommandArgs } from './showQuickCommitDetails'; -const searchByRegex = /^([@:#])/; +const searchByRegex = /^([@~=:#])/; const searchByMap = new Map([ ['@', GitRepoSearchBy.Author], + ['~', GitRepoSearchBy.Changes], + ['=', GitRepoSearchBy.ChangesOccurrences], [':', GitRepoSearchBy.Files], ['#', GitRepoSearchBy.Sha] ]); @@ -85,6 +87,16 @@ export class ShowCommitSearchCommand extends ActiveEditorCachedCommand { placeHolder = `commits with author matching '${args.search}'`; break; + case GitRepoSearchBy.Changes: + originalSearch = `~${args.search}`; + placeHolder = `commits with changes matching '${args.search}'`; + break; + + case GitRepoSearchBy.ChangesOccurrences: + originalSearch = `=${args.search}`; + placeHolder = `commits with changes (new occurrences) matching '${args.search}'`; + break; + case GitRepoSearchBy.Files: originalSearch = `:${args.search}`; placeHolder = `commits with files matching '${args.search}'`; diff --git a/src/gitService.ts b/src/gitService.ts index 62b0735..a70ef64 100644 --- a/src/gitService.ts +++ b/src/gitService.ts @@ -58,6 +58,8 @@ enum RemoveCacheReason { export enum GitRepoSearchBy { Author = 'author', + Changes = 'changes', + ChangesOccurrences = 'changes-occurrences', Files = 'files', Message = 'message', Sha = 'sha' @@ -801,6 +803,12 @@ export class GitService extends Disposable { case GitRepoSearchBy.Author: searchArgs = [`--author=${search}`]; break; + case GitRepoSearchBy.Changes: + searchArgs = [`-G${search}`]; + break; + case GitRepoSearchBy.ChangesOccurrences: + searchArgs = [`-S${search}`, '--pickaxe-regex']; + break; case GitRepoSearchBy.Files: searchArgs = [`--`, `${search}`]; break;