From 897676e371e89ad9578d8fdb35937c8a70cac5df Mon Sep 17 00:00:00 2001 From: Eric Amodio <eamodio@gmail.com> Date: Tue, 21 Aug 2018 03:31:31 -0400 Subject: [PATCH] Add support to filter logs by author --- src/git/git.ts | 5 ++++- src/gitService.ts | 9 +++++++-- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/src/git/git.ts b/src/git/git.ts index 1cbf8ee..939ef70 100644 --- a/src/git/git.ts +++ b/src/git/git.ts @@ -465,8 +465,11 @@ export class Git { return git({ cwd: repoPath }, ...params); } - static log(repoPath: string, options: { maxCount?: number; ref?: string; reverse?: boolean }) { + static log(repoPath: string, options: { author?: string; maxCount?: number; ref?: string; reverse?: boolean }) { const params = ['-c', 'diff.renameLimit=0', ...defaultLogParams, '--full-history', '-M', '-m']; + if (options.author) { + params.push(`--author=${options.author}`); + } if (options.maxCount && !options.reverse) { params.push(`-n${options.maxCount}`); } diff --git a/src/gitService.ts b/src/gitService.ts index cf795d0..bd8a5a2 100644 --- a/src/gitService.ts +++ b/src/gitService.ts @@ -1122,7 +1122,7 @@ export class GitService implements Disposable { async getLog( repoPath: string, - options: { maxCount?: number; ref?: string; reverse?: boolean } = {} + options: { author?: string; maxCount?: number; ref?: string; reverse?: boolean } = {} ): Promise<GitLog | undefined> { options = { reverse: false, ...options }; @@ -1131,7 +1131,12 @@ export class GitService implements Disposable { const maxCount = options.maxCount == null ? Container.config.advanced.maxListItems || 0 : options.maxCount; try { - const data = await Git.log(repoPath, { maxCount: maxCount, ref: options.ref, reverse: options.reverse }); + const data = await Git.log(repoPath, { + author: options.author, + maxCount: maxCount, + ref: options.ref, + reverse: options.reverse + }); const log = GitLogParser.parse( data, GitCommitType.Branch,