Skip to content

Commit

Permalink
Adds Git extended regex support to commit searches
Browse files Browse the repository at this point in the history
Changes commit search by message to be case-insensitive
Clarifies path/glob for file searches
  • Loading branch information
eamodio committed Dec 7, 2018
1 parent fc31295 commit a8cbe01
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 9 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 &mdash; use `<message>` to search for commits with messages that match `<message>` &mdash; See [Git docs](https://git-scm.com/docs/git-log#git-log---grepltpatterngt 'Open Git docs')
- or, by author &mdash; use `@<pattern>` to search for commits with authors that match `<pattern>` &mdash; See [Git docs](https://git-scm.com/docs/git-log#git-log---authorltpatterngt 'Open Git docs')
- or, by commit id &mdash; use `#<sha>` to search for a commit with id of `<sha>` &mdash; See [Git docs](https://git-scm.com/docs/git-log 'Open Git docs')
- or, by files &mdash; use `:<pattern>` to search for commits with file names that match `<pattern>` &mdash; See [Git docs](https://git-scm.com/docs/git-log 'Open Git docs')
- or, by commit id &mdash; use `#<sha>` to search for a commit with id of `<sha>` &mdash; See [Git docs](https://git-scm.com/docs/git-log#git-log-ltrevisionrangegt 'Open Git docs')
- or, by files &mdash; use `:<path/glob>` to search for commits with file names that match `<path/glob>` &mdash; See [Git docs](https://git-scm.com/docs/git-log---ltpathgt82308203 'Open Git docs')
- or, by changes &mdash; use `~<pattern>` to search for commits with differences whose patch text contains added/removed lines that match `<pattern>` &mdash; See [Git docs](https://git-scm.com/docs/git-log#git-log--Gltregexgt 'Open Git docs')
- or, by changed lines &mdash; use `=<string>` to search for commits with differences that change the number of occurrences of the specified string (i.e. addition/deletion) in a file &mdash; See [Git docs](https://git-scm.com/docs/git-log#git-log--Sltstringgt 'Open Git docs')

Expand Down
2 changes: 1 addition & 1 deletion src/commands/searchCommits.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 (@<pattern>), files (:<pattern>), commit id (#<sha>), changes (=<pattern>), changed lines (~<pattern>)`,
placeHolder: `Search commits by message, author (@<pattern>), files (:<path/glob>), commit id (#<sha>), changes (=<pattern>), changed lines (~<pattern>)`,
valueSelection: selection
} as InputBoxOptions);
if (args.search === undefined) {
Expand Down
10 changes: 5 additions & 5 deletions src/git/gitService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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}`);
}
Expand Down
2 changes: 1 addition & 1 deletion src/views/nodes/searchNode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 :&lt;file-pattern&gt;)`,
`${GlyphChars.Space.repeat(4)} or, by files (use :&lt;file-path/glob&gt;)`,
'Click to search commits by files'
),
new CommandMessageNode(
Expand Down

0 comments on commit a8cbe01

Please sign in to comment.