From e2fb2731f0f811d6b9f48be5c0dc1ed4f787c138 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 540c7b5be5e5f..e07159fa117de 100644 --- a/pkg/sources/git/git.go +++ b/pkg/sources/git/git.go @@ -356,7 +356,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...)