From ec2de50b698835a56b73713abb930048563cef9c Mon Sep 17 00:00:00 2001 From: Richard Gomez Date: Wed, 18 Oct 2023 17:18:58 -0400 Subject: [PATCH] feat(git): clone hidden refs --- pkg/sources/git/git.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/pkg/sources/git/git.go b/pkg/sources/git/git.go index 807c7b459744f..1fdfbe757de6e 100644 --- a/pkg/sources/git/git.go +++ b/pkg/sources/git/git.go @@ -358,7 +358,13 @@ func executeClone(ctx context.Context, params cloneParams) (*git.Repository, err cloneURL.User = params.userInfo } - gitArgs := []string{"clone", cloneURL.String(), params.clonePath} + gitArgs := []string{ + "clone", cloneURL.String(), params.clonePath, + // Fetch additional refs from GitHub and GitLab. + // https://github.com/trufflesecurity/trufflehog/issues/1588 + "-c", "remote.origin.fetch=+refs/pull/*:refs/heads/pull/*", + "-c", "remote.origin.fetch=+refs/merge-requests/*:refs/heads/merge-requests/*", + } gitArgs = append(gitArgs, params.args...) cloneCmd := exec.Command("git", gitArgs...)