Skip to content

Commit 446a40b

Browse files
authored
Merge branch 'main' into dependabot/go_modules/github.com/spf13/cobra-1.10.2
2 parents f1fe7e1 + a1be537 commit 446a40b

2 files changed

Lines changed: 18 additions & 1 deletion

File tree

internal/git/git.go

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import (
55
"errors"
66
"fmt"
77
"io"
8+
"os"
89
"os/exec"
910
"path/filepath"
1011
"strings"
@@ -13,6 +14,8 @@ import (
1314
"github.com/go-git/go-git/v5/plumbing"
1415
"github.com/go-git/go-git/v5/plumbing/format/diff"
1516
object "github.com/go-git/go-git/v5/plumbing/object"
17+
"github.com/go-git/go-git/v5/plumbing/transport"
18+
"github.com/go-git/go-git/v5/plumbing/transport/http"
1619

1720
"github.com/launchdarkly/ld-find-code-refs/v2/internal/ld"
1821
"github.com/launchdarkly/ld-find-code-refs/v2/options"
@@ -199,13 +202,25 @@ func (c *Client) RemoteBranches() (branches map[string]bool, err error) {
199202
return branches, err
200203
}
201204

205+
// Configure authentication for GitHub Actions
206+
var auth transport.AuthMethod
207+
if os.Getenv("GITHUB_ACTIONS") == "true" {
208+
if token := os.Getenv("GITHUB_TOKEN"); token != "" {
209+
log.Debug.Printf("using GitHub token authentication for remote operations")
210+
auth = &http.BasicAuth{
211+
Username: "x-access-token", // GitHub requires this specific username
212+
Password: token,
213+
}
214+
}
215+
}
216+
202217
remotes, err := repo.Remotes()
203218
if err != nil {
204219
return branches, err
205220
}
206221

207222
for _, r := range remotes {
208-
refList, err := r.List(&git.ListOptions{})
223+
refList, err := r.List(&git.ListOptions{Auth: auth})
209224
if err != nil {
210225
return branches, err
211226
}

internal/ld/ld.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -485,6 +485,8 @@ func (c ApiClient) do(req *h.Request) (*http.Response, error) {
485485
return nil, err
486486
}
487487

488+
log.Debug.Printf("response status %d %s for %s %s", res.StatusCode, http.StatusText(res.StatusCode), req.Method, req.URL)
489+
488490
// Check for all general status codes returned by the code references API, attempting to deconstruct LD error messages, if possible.
489491
switch res.StatusCode {
490492
case http.StatusOK, http.StatusCreated, http.StatusNoContent:

0 commit comments

Comments
 (0)