From 396ba6b3e025a3af4b5a126b336fa3e86adeaf3a Mon Sep 17 00:00:00 2001 From: Fabian Date: Wed, 15 Jan 2025 13:21:07 +0000 Subject: [PATCH] attempt to set git config with passed token --- main.go | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/main.go b/main.go index f020c5a4..6fe7e1af 100644 --- a/main.go +++ b/main.go @@ -265,6 +265,18 @@ func getPullRequestDiffUsingGitCommand(ctx context.Context, config *lcr.Config, } mergeBaseSha := commitsComparison.GetMergeBaseCommit().GetSHA() + for _, sha := range []string{mergeBaseSha, headSha} { + gha.Debug("PR %d: running git fetch --depth=1 %s %s", number, head.GetRepo().GetHTMLURL(), sha) + _, err := exec.Command("git", "config", "--global", "credential.helper", "store", os.Getenv("GITHUB_TOKEN")).CombinedOutput() + if err != nil { + return nil, fmt.Errorf("failed to run git config: %w", err) + } + + _, err = exec.Command("git", "fetch", "--depth=1", head.GetRepo().GetHTMLURL(), sha).CombinedOutput() + if err != nil { + return nil, fmt.Errorf("failed to run git fetch: %w", err) + } + } bytes, err := exec.Command("git", "diff", "--find-renames", mergeBaseSha, headSha).CombinedOutput() if err != nil {