Browse Source

Adds support to search by multiple commit ids

main
Eric Amodio 5 years ago
parent
commit
c42fa6355b
2 changed files with 17 additions and 7 deletions
  1. +7
    -3
      src/git/git.ts
  2. +10
    -4
      src/git/gitService.ts

+ 7
- 3
src/git/git.ts View File

@ -802,9 +802,13 @@ export class Git {
return data.length === 0 ? undefined : data.trim();
}
static log__search(repoPath: string, search: string[] = emptyArray, { maxCount }: { maxCount?: number } = {}) {
const params = ['log', '--name-status', `--format=${GitLogParser.defaultFormat}`];
if (maxCount) {
static log__search(
repoPath: string,
search: string[] = emptyArray,
{ maxCount, useShow }: { maxCount?: number; useShow?: boolean } = {}
) {
const params = [useShow ? 'show' : 'log', '--name-status', `--format=${GitLogParser.defaultFormat}`];
if (maxCount && !useShow) {
params.push(`-n${maxCount}`);
}

+ 10
- 4
src/git/gitService.ts View File

@ -1435,7 +1435,8 @@ export class GitService implements Disposable {
search = { matchAll: false, matchCase: false, matchRegex: true, ...search };
try {
let maxCount = options.maxCount == null ? Container.config.advanced.maxSearchItems || 0 : options.maxCount;
const maxCount =
options.maxCount == null ? Container.config.advanced.maxSearchItems || 0 : options.maxCount;
const similarityThreshold = Container.config.advanced.similarityThreshold;
const operations = GitService.parseSearchOperations(search.pattern);
@ -1443,13 +1444,18 @@ export class GitService implements Disposable {
const searchArgs = new Set<string>();
const files: string[] = [];
let useShow = false;
let op;
let values = operations.get('commit:');
if (values !== undefined) {
useShow = true;
searchArgs.add('-m');
searchArgs.add(`-M${similarityThreshold == null ? '' : `${similarityThreshold}%`}`);
searchArgs.add(values[0]);
maxCount = 1;
for (const value of values) {
searchArgs.add(value);
}
} else {
searchArgs.add(`-M${similarityThreshold == null ? '' : `${similarityThreshold}%`}`);
searchArgs.add('--all');
@ -1503,7 +1509,7 @@ export class GitService implements Disposable {
args.push(...files);
}
const data = await Git.log__search(repoPath, args, { maxCount: maxCount });
const data = await Git.log__search(repoPath, args, { maxCount: maxCount, useShow: useShow });
const log = GitLogParser.parse(
data,
GitCommitType.Log,

Loading…
Cancel
Save