From a8cbe0188ea483ea06aa15b0631437cf016399c4 Mon Sep 17 00:00:00 2001 From: Eric Amodio Date: Fri, 7 Dec 2018 03:23:07 -0500 Subject: [PATCH] Adds Git extended regex support to commit searches Changes commit search by message to be case-insensitive Clarifies path/glob for file searches --- CHANGELOG.md | 2 ++ README.md | 4 ++-- src/commands/searchCommits.ts | 2 +- src/git/gitService.ts | 10 +++++----- src/views/nodes/searchNode.ts | 2 +- 5 files changed, 11 insertions(+), 9 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 691e92f..f0fcb02 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,11 +9,13 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/) and this p ### Added - Adds control over the contributed menu commands to the Source Control side bar to the GitLens interactive settings editor (via the `gitlens.menus` setting) +- Adds Git extended regex support to commit searches ### Changed - Changes the _Show Revision Details_ command (`gitlens.showQuickRevisionDetails`) to show file commit details - Changes the `alt`-command of the _Toggle File Blame Annotations_ command (`gitlens.toggleFileBlame`) to _Toggle File Heatmap Annotations_ command (`gitlens.toggleFileHeatmap`) +- Changes searching for commits by message to be case-insensitive - Reworks the layout of some contributed menu command ### Fixed diff --git a/README.md b/README.md index 8756759..4e9d5a9 100644 --- a/README.md +++ b/README.md @@ -430,8 +430,8 @@ A [customizable](#search-commits-view-settings- 'Jump to the Search Commits view - Use the _Search Commits_ command (`gitlens.showCommitSearch`) with a shortcut of `alt+/` to search for commits - by message — use `` to search for commits with messages that match `` — See [Git docs](https://git-scm.com/docs/git-log#git-log---grepltpatterngt 'Open Git docs') - or, by author — use `@` to search for commits with authors that match `` — See [Git docs](https://git-scm.com/docs/git-log#git-log---authorltpatterngt 'Open Git docs') - - or, by commit id — use `#` to search for a commit with id of `` — See [Git docs](https://git-scm.com/docs/git-log 'Open Git docs') - - or, by files — use `:` to search for commits with file names that match `` — See [Git docs](https://git-scm.com/docs/git-log 'Open Git docs') + - or, by commit id — use `#` to search for a commit with id of `` — See [Git docs](https://git-scm.com/docs/git-log#git-log-ltrevisionrangegt 'Open Git docs') + - or, by files — use `:` to search for commits with file names that match `` — See [Git docs](https://git-scm.com/docs/git-log---ltpathgt82308203 'Open Git docs') - or, by changes — use `~` to search for commits with differences whose patch text contains added/removed lines that match `` — See [Git docs](https://git-scm.com/docs/git-log#git-log--Gltregexgt 'Open Git docs') - or, by changed lines — use `=` to search for commits with differences that change the number of occurrences of the specified string (i.e. addition/deletion) in a file — See [Git docs](https://git-scm.com/docs/git-log#git-log--Sltstringgt 'Open Git docs') diff --git a/src/commands/searchCommits.ts b/src/commands/searchCommits.ts index 7d7d1be..3ae9c8c 100644 --- a/src/commands/searchCommits.ts +++ b/src/commands/searchCommits.ts @@ -100,7 +100,7 @@ export class SearchCommitsCommand extends ActiveEditorCachedCommand { args.search = await window.showInputBox({ value: args.search, prompt: `Please enter a search string`, - placeHolder: `Search commits by message, author (@), files (:), commit id (#), changes (=), changed lines (~)`, + placeHolder: `Search commits by message, author (@), files (:), commit id (#), changes (=), changed lines (~)`, valueSelection: selection } as InputBoxOptions); if (args.search === undefined) { diff --git a/src/git/gitService.ts b/src/git/gitService.ts index 4576470..621457c 100644 --- a/src/git/gitService.ts +++ b/src/git/gitService.ts @@ -1374,19 +1374,19 @@ export class GitService implements Disposable { let searchArgs: string[] | undefined = undefined; switch (searchBy) { case GitRepoSearchBy.Author: - searchArgs = ['-m', '-M', '--all', '--full-history', '-i', `--author=${search}`]; + searchArgs = ['-m', '-M', '--all', '--full-history', '-E', '-i', `--author=${search}`]; break; case GitRepoSearchBy.ChangedLines: - searchArgs = ['-M', '--all', '--full-history', '-i', `-G${search}`]; + searchArgs = ['-M', '--all', '--full-history', '-E', '-i', `-G${search}`]; break; case GitRepoSearchBy.Changes: - searchArgs = ['-M', '--all', '--full-history', '-i', '--pickaxe-regex', `-S${search}`]; + searchArgs = ['-M', '--all', '--full-history', '-E', '-i', '--pickaxe-regex', `-S${search}`]; break; case GitRepoSearchBy.Files: - searchArgs = ['-M', '--all', '--full-history', '-i', `--`, `${search}`]; + searchArgs = ['-M', '--all', '--full-history', '-E', '-i', `--`, `${search}`]; break; case GitRepoSearchBy.Message: - searchArgs = ['-m', '-M', '--all', '--full-history']; + searchArgs = ['-m', '-M', '--all', '--full-history', '-E', '-i']; if (search) { searchArgs.push(`--grep=${search}`); } diff --git a/src/views/nodes/searchNode.ts b/src/views/nodes/searchNode.ts index b27fd73..7fdd07a 100644 --- a/src/views/nodes/searchNode.ts +++ b/src/views/nodes/searchNode.ts @@ -60,7 +60,7 @@ export class SearchNode extends ViewNode { ...command, arguments: [this, { searchBy: GitRepoSearchBy.Files } as SearchCommitsCommandArgs] }, - `${GlyphChars.Space.repeat(4)} or, by files (use :<file-pattern>)`, + `${GlyphChars.Space.repeat(4)} or, by files (use :<file-path/glob>)`, 'Click to search commits by files' ), new CommandMessageNode(