From 00ebb2ed648162b0b6181177bbbd1c78bc771785 Mon Sep 17 00:00:00 2001 From: Bill Rich Date: Thu, 26 Jan 2023 09:17:54 -0800 Subject: [PATCH] Full git log when targeting base merge commit (#1044) * Full git log when targeting merge commits * Full log is needed whenever base is specified. --- pkg/gitparse/gitparse.go | 7 +++++-- pkg/sources/git/git.go | 2 +- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/pkg/gitparse/gitparse.go b/pkg/gitparse/gitparse.go index caa8066a3..aa22a9212 100644 --- a/pkg/gitparse/gitparse.go +++ b/pkg/gitparse/gitparse.go @@ -75,8 +75,11 @@ func (c1 *Commit) Equal(c2 *Commit) bool { } // RepoPath parses the output of the `git log` command for the `source` path. -func RepoPath(ctx context.Context, source string, head string) (chan Commit, error) { - args := []string{"-C", source, "log", "-p", "-U5", "--full-history", "--diff-filter=AM", "--date=format:%a %b %d %H:%M:%S %Y %z"} +func RepoPath(ctx context.Context, source string, head string, abbreviatedLog bool) (chan Commit, error) { + args := []string{"-C", source, "log", "-p", "-U5", "--full-history", "--date=format:%a %b %d %H:%M:%S %Y %z"} + if abbreviatedLog { + args = append(args, "--diff-filter=AM") + } if head != "" { args = append(args, head) } else { diff --git a/pkg/sources/git/git.go b/pkg/sources/git/git.go index 1bdc3e12a..f2f580351 100644 --- a/pkg/sources/git/git.go +++ b/pkg/sources/git/git.go @@ -330,7 +330,7 @@ func (s *Git) ScanCommits(ctx context.Context, repo *git.Repository, path string return err } - commitChan, err := gitparse.RepoPath(ctx, path, scanOptions.HeadHash) + commitChan, err := gitparse.RepoPath(ctx, path, scanOptions.HeadHash, scanOptions.BaseHash == "") if err != nil { return err }