Skip to content

Commit 947d2b1

Browse files
authored
Switch to go-git, go-github and go-billy stable versions (#399)
* Bump to go-github to v88 Signed-off-by: Adolfo García Veytia (Puerco) <puerco@carabiner.dev> * Switch to stable go-git/go-billy mods Signed-off-by: Adolfo García Veytia (Puerco) <puerco@carabiner.dev> * Use latest 1.25 go release Signed-off-by: Adolfo García Veytia (Puerco) <puerco@carabiner.dev> * Fix linter nit Signed-off-by: Adolfo García Veytia (Puerco) <puerco@carabiner.dev> --------- Signed-off-by: Adolfo García Veytia (Puerco) <puerco@carabiner.dev>
1 parent 26d8310 commit 947d2b1

14 files changed

Lines changed: 90 additions & 75 deletions

File tree

go.mod

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
module github.com/slsa-framework/source-tool
22

3-
go 1.25.9
3+
go 1.25.11
44

55
require (
66
github.com/carabiner-dev/attestation v0.2.1
77
github.com/carabiner-dev/collector v0.3.5
88
github.com/carabiner-dev/signer v0.4.5
99
github.com/carabiner-dev/vcslocator v0.4.3
1010
github.com/fatih/color v1.19.0
11-
github.com/go-git/go-billy/v6 v6.0.0-20260226131633-45bd0956d66f
12-
github.com/go-git/go-git/v6 v6.0.0-20260305211659-2083cf940afa
13-
github.com/google/go-github/v69 v69.2.0
11+
github.com/go-git/go-billy/v5 v5.9.0
12+
github.com/go-git/go-git/v5 v5.19.1
13+
github.com/google/go-github/v88 v88.0.0
1414
github.com/google/uuid v1.6.0
1515
github.com/hashicorp/go-retryablehttp v0.7.8
1616
github.com/in-toto/attestation v1.2.0
@@ -61,9 +61,6 @@ require (
6161
github.com/emirpasic/gods v1.18.1 // indirect
6262
github.com/github/smimesign v0.2.0 // indirect
6363
github.com/go-git/gcfg v1.5.1-0.20230307220236-3a3c6141e376 // indirect
64-
github.com/go-git/gcfg/v2 v2.0.2 // indirect
65-
github.com/go-git/go-billy/v5 v5.8.1-0.20260407233109-416e0a5b21a8 // indirect
66-
github.com/go-git/go-git/v5 v5.18.0 // indirect
6764
github.com/go-jose/go-jose/v4 v4.1.4 // indirect
6865
github.com/go-logr/logr v1.4.3 // indirect
6966
github.com/go-logr/stdr v1.2.2 // indirect
@@ -121,7 +118,7 @@ require (
121118
github.com/opencontainers/image-spec v1.1.1 // indirect
122119
github.com/openvex/go-vex v0.2.8 // indirect
123120
github.com/package-url/packageurl-go v0.1.5 // indirect
124-
github.com/pjbgf/sha1cd v0.5.0 // indirect
121+
github.com/pjbgf/sha1cd v0.6.0 // indirect
125122
github.com/pkg/browser v0.0.0-20240102092130-5ac0b6a4141c // indirect
126123
github.com/pkg/errors v0.9.1 // indirect
127124
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect

go.sum

Lines changed: 8 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -171,20 +171,12 @@ github.com/go-chi/chi/v5 v5.3.0 h1:halUjDxhshgXHMrao5bB8eNBXo/rnzwr8m5m36glehM=
171171
github.com/go-chi/chi/v5 v5.3.0/go.mod h1:R+tYY2hNuVUUjxoPtqUdgBqevM9s9njzkTLutVsOCto=
172172
github.com/go-git/gcfg v1.5.1-0.20230307220236-3a3c6141e376 h1:+zs/tPmkDkHx3U66DAb0lQFJrpS6731Oaa12ikc+DiI=
173173
github.com/go-git/gcfg v1.5.1-0.20230307220236-3a3c6141e376/go.mod h1:an3vInlBmSxCcxctByoQdvwPiA7DTK7jaaFDBTtu0ic=
174-
github.com/go-git/gcfg/v2 v2.0.2 h1:MY5SIIfTGGEMhdA7d7JePuVVxtKL7Hp+ApGDJAJ7dpo=
175-
github.com/go-git/gcfg/v2 v2.0.2/go.mod h1:/lv2NsxvhepuMrldsFilrgct6pxzpGdSRC13ydTLSLs=
176-
github.com/go-git/go-billy/v5 v5.8.1-0.20260407233109-416e0a5b21a8 h1:Ol1+pjteoiYrrxjMmR+YvpS23HGy6B0YPVjvk7CnRDY=
177-
github.com/go-git/go-billy/v5 v5.8.1-0.20260407233109-416e0a5b21a8/go.mod h1:RpvI/rw4Vr5QA+Z60c6d6LXH0rYJo0uD5SqfmrrheCY=
178-
github.com/go-git/go-billy/v6 v6.0.0-20260226131633-45bd0956d66f h1:Uvbx7nITO3Sd1GdXarX0TbyYmOaSNIJP0mm4LocEyyA=
179-
github.com/go-git/go-billy/v6 v6.0.0-20260226131633-45bd0956d66f/go.mod h1:ZW9JC5gionMP1kv5uiaOaV23q0FFmNrVOV8VW+y/acc=
174+
github.com/go-git/go-billy/v5 v5.9.0 h1:jItGXszUDRtR/AlferWPTMN4j38BQ88XnXKbilmmBPA=
175+
github.com/go-git/go-billy/v5 v5.9.0/go.mod h1:jCnQMLj9eUgGU7+ludSTYoZL/GGmii14RxKFj7ROgHw=
180176
github.com/go-git/go-git-fixtures/v4 v4.3.2-0.20231010084843-55a94097c399 h1:eMje31YglSBqCdIqdhKBW8lokaMrL3uTkpGYlE2OOT4=
181177
github.com/go-git/go-git-fixtures/v4 v4.3.2-0.20231010084843-55a94097c399/go.mod h1:1OCfN199q1Jm3HZlxleg+Dw/mwps2Wbk9frAWm+4FII=
182-
github.com/go-git/go-git-fixtures/v5 v5.1.2-0.20260122163445-0622d7459a67 h1:3hutPZF+/FBjR/9MdsLJ7e1mlt9pwHgwxMW7CrbmWII=
183-
github.com/go-git/go-git-fixtures/v5 v5.1.2-0.20260122163445-0622d7459a67/go.mod h1:xKt0pNHST9tYHvbiLxSY27CQWFwgIxBJuDrOE0JvbZw=
184-
github.com/go-git/go-git/v5 v5.18.0 h1:O831KI+0PR51hM2kep6T8k+w0/LIAD490gvqMCvL5hM=
185-
github.com/go-git/go-git/v5 v5.18.0/go.mod h1:pW/VmeqkanRFqR6AljLcs7EA7FbZaN5MQqO7oZADXpo=
186-
github.com/go-git/go-git/v6 v6.0.0-20260305211659-2083cf940afa h1:fIbZ264qSeJ+GRz+5nq6SFonkCanp/6CRXhYutq8GlE=
187-
github.com/go-git/go-git/v6 v6.0.0-20260305211659-2083cf940afa/go.mod h1:V/qoTD4qCYizR+fKFA9++d2APoE8Yheci7dXALaSeuI=
178+
github.com/go-git/go-git/v5 v5.19.1 h1:nX27AnaU43/K5bKktKwgBmR9lawoYVe1Ckg0rgzzN00=
179+
github.com/go-git/go-git/v5 v5.19.1/go.mod h1:Pb1v0c7/g8aGQJwx9Us09W85yGoyvSwuhEGMH7zjDKQ=
188180
github.com/go-jose/go-jose/v4 v4.1.4 h1:moDMcTHmvE6Groj34emNPLs/qtYXRVcd6S7NHbHz3kA=
189181
github.com/go-jose/go-jose/v4 v4.1.4/go.mod h1:x4oUasVrzR7071A4TnHLGSPpNOm2a21K9Kf04k1rs08=
190182
github.com/go-logr/logr v1.2.2/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A=
@@ -269,10 +261,10 @@ github.com/google/go-cmp v0.7.0 h1:wk8382ETsv4JYUZwIsn6YpYiWiBsYLSJiTsyBybVuN8=
269261
github.com/google/go-cmp v0.7.0/go.mod h1:pXiqmnSA92OHEEa9HXL2W4E7lf9JzCmGVUdgjX3N/iU=
270262
github.com/google/go-containerregistry v0.21.6 h1:T+yqQIlJXKrM98Om4DlW3GoWQAmhZuLMwoDOvVrtiUM=
271263
github.com/google/go-containerregistry v0.21.6/go.mod h1:U7MMSBIJynke2MVQrQk19NP9k/uQsGz/h0amIFSHMbo=
272-
github.com/google/go-github/v69 v69.2.0 h1:wR+Wi/fN2zdUx9YxSmYE0ktiX9IAR/BeePzeaUUbEHE=
273-
github.com/google/go-github/v69 v69.2.0/go.mod h1:xne4jymxLR6Uj9b7J7PyTpkMYstEMMwGZa0Aehh1azM=
274264
github.com/google/go-github/v73 v73.0.0 h1:aR+Utnh+Y4mMkS+2qLQwcQ/cF9mOTpdwnzlaw//rG24=
275265
github.com/google/go-github/v73 v73.0.0/go.mod h1:fa6w8+/V+edSU0muqdhCVY7Beh1M8F1IlQPZIANKIYw=
266+
github.com/google/go-github/v88 v88.0.0 h1:dZA9IKkPK1eXZj4ypngnpRj5FwdpTv4whix2PrQMP7M=
267+
github.com/google/go-github/v88 v88.0.0/go.mod h1:rufTDgn2N45wjhukLTyxmvc9nilSp3mr3Rgtt6b1MPw=
276268
github.com/google/go-querystring v1.2.0 h1:yhqkPbu2/OH+V9BfpCVPZkNmUXhb2gBxJArfhIxNtP0=
277269
github.com/google/go-querystring v1.2.0/go.mod h1:8IFJqpSRITyJ8QhQ13bmbeMBDfmeEJZD5A0egEOmkqU=
278270
github.com/google/gofuzz v1.2.0 h1:xRy4A+RhZaiKjJ1bPfwQ8sedCA+YS2YcCHW6ec7JMi0=
@@ -390,8 +382,8 @@ github.com/package-url/packageurl-go v0.1.5 h1:O4efRXja2XQ5CtiiYiCZ22k/m7i5ugLiA
390382
github.com/package-url/packageurl-go v0.1.5/go.mod h1:nKAWB8E6uk1MHqiS/lQb9pYBGH2+mdJ2PJc2s50dQY0=
391383
github.com/pborman/getopt v0.0.0-20170112200414-7148bc3a4c30/go.mod h1:85jBQOZwpVEaDAr341tbn15RS4fCAsIst0qp7i8ex1o=
392384
github.com/pborman/getopt v0.0.0-20180811024354-2b5b3bfb099b/go.mod h1:85jBQOZwpVEaDAr341tbn15RS4fCAsIst0qp7i8ex1o=
393-
github.com/pjbgf/sha1cd v0.5.0 h1:a+UkboSi1znleCDUNT3M5YxjOnN1fz2FhN48FlwCxs0=
394-
github.com/pjbgf/sha1cd v0.5.0/go.mod h1:lhpGlyHLpQZoxMv8HcgXvZEhcGs0PG/vsZnEJ7H0iCM=
385+
github.com/pjbgf/sha1cd v0.6.0 h1:3WJ8Wz8gvDz29quX1OcEmkAlUg9diU4GxJHqs0/XiwU=
386+
github.com/pjbgf/sha1cd v0.6.0/go.mod h1:lhpGlyHLpQZoxMv8HcgXvZEhcGs0PG/vsZnEJ7H0iCM=
395387
github.com/pkg/browser v0.0.0-20240102092130-5ac0b6a4141c h1:+mdjkGKdHQG3305AYmdv1U2eRNDiU2ErMBj1gwrq8eQ=
396388
github.com/pkg/browser v0.0.0-20240102092130-5ac0b6a4141c/go.mod h1:7rwL4CYBLnjLxUqIJNnCWiEdr3bn6IUYi15bNlnbCCU=
397389
github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=

pkg/auth/authenticator.go

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ import (
1616
"time"
1717

1818
"github.com/fatih/color"
19-
"github.com/google/go-github/v69/github"
19+
"github.com/google/go-github/v88/github"
2020
"github.com/hashicorp/go-retryablehttp"
2121

2222
"github.com/slsa-framework/source-tool/pkg/sourcetool/models"
@@ -146,7 +146,11 @@ func (a *Authenticator) GetGitHubClient() (*github.Client, error) {
146146
rClient.RetryMax = 3
147147
rClient.Logger = nil // Comment this line to monitor GH api calls
148148
httpClient := rClient.StandardClient()
149-
return github.NewClient(httpClient).WithAuthToken(token), nil
149+
client, err := github.NewClient(github.WithHTTPClient(httpClient), github.WithAuthToken(token))
150+
if err != nil {
151+
return nil, fmt.Errorf("creating github client: %w", err)
152+
}
153+
return client, nil
150154
}
151155

152156
// WhoAmI returns the user authenticated with the token

pkg/ghcontrol/checklevel.go

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import (
1111
"slices"
1212
"time"
1313

14-
"github.com/google/go-github/v69/github"
14+
"github.com/google/go-github/v88/github"
1515

1616
"github.com/slsa-framework/source-tool/pkg/slsa"
1717
"github.com/slsa-framework/source-tool/pkg/sourcetool/models"
@@ -38,13 +38,13 @@ type activity struct {
3838
func (ghc *GitHubConnection) commitActivity(ctx context.Context, commit, targetRef string) (*activity, error) {
3939
// Unfortunately the gh_client doesn't have native support for this...'
4040
reqUrl := fmt.Sprintf("repos/%s/%s/activity", ghc.Owner(), ghc.Repo())
41-
req, err := ghc.Client().NewRequest("GET", reqUrl, nil)
41+
req, err := ghc.Client().NewRequest(ctx, "GET", reqUrl, nil)
4242
if err != nil {
4343
return nil, err
4444
}
4545

4646
var result []*activity
47-
_, err = ghc.Client().Do(ctx, req, &result)
47+
_, err = ghc.Client().Do(req, &result)
4848
if err != nil {
4949
return nil, err
5050
}
@@ -234,8 +234,8 @@ func (ghc *GitHubConnection) computeRequiredChecks(ctx context.Context, ghCheckR
234234
// protection if one of them is missing. We check first so if other rules
235235
// already protect the branch, this function noops.
236236
func (ghc *GitHubConnection) EnableBranchRules(ctx context.Context) error {
237-
branchRules, _, err := ghc.Client().Repositories.GetRulesForBranch(
238-
ctx, ghc.Owner(), ghc.Repo(), GetBranchFromRef(ghc.ref),
237+
branchRules, _, err := ghc.Client().Repositories.ListRulesForBranch(
238+
ctx, ghc.Owner(), ghc.Repo(), GetBranchFromRef(ghc.ref), nil,
239239
)
240240
if err != nil {
241241
return fmt.Errorf("fetching branch rules: %w", err)
@@ -286,7 +286,7 @@ func (ghc *GitHubConnection) EnableBranchRules(ctx context.Context) error {
286286
// protection on all branches.
287287
func (ghc *GitHubConnection) EnableTagRules(ctx context.Context) error {
288288
allRules, _, err := ghc.Client().Repositories.GetAllRulesets(
289-
ctx, ghc.Owner(), ghc.Repo(), true,
289+
ctx, ghc.Owner(), ghc.Repo(), &github.RepositoryListRulesetsOptions{IncludesParents: github.Ptr(true)},
290290
)
291291
if err != nil {
292292
return fmt.Errorf("fetching tag rules: %w", err)
@@ -357,7 +357,7 @@ func (ghc *GitHubConnection) GetBranchControls(ctx context.Context, ref string)
357357
controls := &slsa.ControlSet{}
358358

359359
// Do the branch specific stuff.
360-
branchRules, _, err := ghc.Client().Repositories.GetRulesForBranch(ctx, ghc.Owner(), ghc.Repo(), branch)
360+
branchRules, _, err := ghc.Client().Repositories.ListRulesForBranch(ctx, ghc.Owner(), ghc.Repo(), branch, nil)
361361
if err != nil {
362362
return nil, err
363363
}
@@ -382,7 +382,7 @@ func (ghc *GitHubConnection) GetBranchControls(ctx context.Context, ref string)
382382
controls.AddControl(requiredCheckControls...)
383383

384384
// Check the tag rules.
385-
allRulesets, _, err := ghc.Client().Repositories.GetAllRulesets(ctx, ghc.Owner(), ghc.Repo(), true)
385+
allRulesets, _, err := ghc.Client().Repositories.GetAllRulesets(ctx, ghc.Owner(), ghc.Repo(), &github.RepositoryListRulesetsOptions{IncludesParents: github.Ptr(true)})
386386
if err != nil {
387387
return nil, err
388388
}
@@ -432,7 +432,7 @@ func (ghc *GitHubConnection) GetTagControls(ctx context.Context, commit, ref str
432432
Controls: &slsa.ControlSet{},
433433
}
434434

435-
allRulesets, _, err := ghc.Client().Repositories.GetAllRulesets(ctx, ghc.Owner(), ghc.Repo(), true)
435+
allRulesets, _, err := ghc.Client().Repositories.GetAllRulesets(ctx, ghc.Owner(), ghc.Repo(), &github.RepositoryListRulesetsOptions{IncludesParents: github.Ptr(true)})
436436
if err != nil {
437437
return nil, fmt.Errorf("getting repository rules from API: %w", err)
438438
}

pkg/ghcontrol/checklevel_test.go

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,13 @@ package ghcontrol
55

66
import (
77
"encoding/json"
8+
"fmt"
89
"log"
910
"slices"
1011
"testing"
1112
"time"
1213

13-
"github.com/google/go-github/v69/github"
14+
"github.com/google/go-github/v88/github"
1415
"github.com/migueleliasweb/go-github-mock/src/mock"
1516

1617
"github.com/slsa-framework/source-tool/pkg/slsa"
@@ -180,7 +181,7 @@ func newMockedGitHubClient(rulesetResponse *github.RepositoryRuleset, activityRe
180181
// values. We're not going to both with that and instead just return as many copies of the same response
181182
// as needed. In the future we might want to support testing different rules being enabled in different
182183
// rulesets, but that's a problem for the future.
183-
return github.NewClient(mock.NewMockedHTTPClient(
184+
client, err := github.NewClient(github.WithHTTPClient(mock.NewMockedHTTPClient(
184185
mock.WithRequestMatch(
185186
mock.GetReposRulesetsByOwnerByRepo,
186187
[]*github.RepositoryRuleset{
@@ -201,7 +202,11 @@ func newMockedGitHubClient(rulesetResponse *github.RepositoryRuleset, activityRe
201202
mock.GetReposRulesBranchesByOwnerByRepoByBranch,
202203
*branchRulesResponse,
203204
),
204-
))
205+
)))
206+
if err != nil {
207+
panic(fmt.Sprintf("creating mocked github client: %v", err))
208+
}
209+
return client
205210
}
206211

207212
// Helper to create a test GH Branch connection with no client.

pkg/ghcontrol/connection.go

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,10 @@ package ghcontrol
66
import (
77
"context"
88
"fmt"
9+
"net/http"
910
"os"
1011

11-
"github.com/google/go-github/v69/github"
12+
"github.com/google/go-github/v88/github"
1213
"github.com/hashicorp/go-retryablehttp"
1314

1415
"github.com/slsa-framework/source-tool/pkg/sourcetool/models"
@@ -28,7 +29,23 @@ func NewGhConnection(owner, repo, ref string) *GitHubConnection {
2829
rClient := retryablehttp.NewClient()
2930
rClient.RetryMax = int(opts.ApiRetries)
3031
rClient.Logger = nil
31-
return NewGhConnectionWithClient(owner, repo, ref, github.NewClient(rClient.StandardClient()))
32+
return NewGhConnectionWithClient(owner, repo, ref, newGitHubClient(rClient.StandardClient(), ""))
33+
}
34+
35+
// newGitHubClient builds a go-github client backed by the given HTTP client
36+
// and, when set, authenticated with the provided token. WithHTTPClient only
37+
// fails on a nil HTTP client and WithAuthToken never fails, so with a non-nil
38+
// httpClient the returned error only signals a programming error and we panic.
39+
func newGitHubClient(httpClient *http.Client, token string) *github.Client {
40+
clientOpts := []github.ClientOptionsFunc{github.WithHTTPClient(httpClient)}
41+
if token != "" {
42+
clientOpts = append(clientOpts, github.WithAuthToken(token))
43+
}
44+
client, err := github.NewClient(clientOpts...)
45+
if err != nil {
46+
panic(fmt.Sprintf("building github client: %v", err))
47+
}
48+
return client
3249
}
3350

3451
func NewGhConnectionWithClient(owner, repo, ref string, client *github.Client) *GitHubConnection {
@@ -38,7 +55,7 @@ func NewGhConnectionWithClient(owner, repo, ref string, client *github.Client) *
3855
if t := os.Getenv(tokenEnvVar); t != "" {
3956
opts.accessToken = t
4057
if client != nil {
41-
client = client.WithAuthToken(t)
58+
client = newGitHubClient(client.Client(), t)
4259
}
4360
}
4461

@@ -72,7 +89,7 @@ func (ghc *GitHubConnection) GetFullRef() string {
7289
func (ghc *GitHubConnection) WithAuthToken(token string) *GitHubConnection {
7390
if token != "" {
7491
ghc.Options.accessToken = token
75-
ghc.client = ghc.client.WithAuthToken(ghc.Options.accessToken)
92+
ghc.client = newGitHubClient(ghc.client.Client(), ghc.Options.accessToken)
7693
}
7794
return ghc
7895
}

pkg/ghcontrol/notes.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import (
88
"fmt"
99
"net/http"
1010

11-
"github.com/google/go-github/v69/github"
11+
"github.com/google/go-github/v88/github"
1212
)
1313

1414
// GetNotesForCommit returns the unparsed notes blob for a commit as stored in

pkg/policy/policy.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@ import (
1515
"strings"
1616
"time"
1717

18-
git "github.com/go-git/go-git/v6"
19-
"github.com/go-git/go-git/v6/plumbing"
20-
"github.com/google/go-github/v69/github" // Use v69
18+
git "github.com/go-git/go-git/v5"
19+
"github.com/go-git/go-git/v5/plumbing"
20+
"github.com/google/go-github/v88/github" // Use v88
2121
spb "github.com/in-toto/attestation/go/v1"
2222
"google.golang.org/protobuf/encoding/protojson"
2323
"google.golang.org/protobuf/types/known/timestamppb"

pkg/policy/policy_test.go

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,14 @@ import (
1010
"fmt"
1111
"net/http"
1212
"net/http/httptest"
13-
"net/url"
1413
"os"
1514
"reflect" // Ensure reflect is imported
1615
"slices"
1716
"strings"
1817
"testing"
1918
"time"
2019

21-
"github.com/google/go-github/v69/github" // Use v69
20+
"github.com/google/go-github/v88/github" // Use v88
2221
spb "github.com/in-toto/attestation/go/v1"
2322
"github.com/stretchr/testify/require"
2423
"google.golang.org/protobuf/encoding/protojson"
@@ -655,14 +654,15 @@ func setupMockGitHubTestEnv(t *testing.T, targetOwner, targetRepo, targetBranch
655654
server := httptest.NewServer(handler)
656655

657656
httpClient := server.Client()
658-
ghClient := github.NewClient(httpClient)
659-
660-
baseURL, err := url.Parse(server.URL + "/")
657+
baseURL := server.URL + "/"
658+
ghClient, err := github.NewClient(
659+
github.WithHTTPClient(httpClient),
660+
github.WithEnterpriseURLs(baseURL, baseURL),
661+
)
661662
if err != nil {
662-
server.Close() // Close the server if URL parsing fails
663-
t.Fatalf("Failed to parse mock server URL: %v", err)
663+
server.Close()
664+
t.Fatalf("Failed to create GitHub client: %v", err)
664665
}
665-
ghClient.BaseURL = baseURL
666666

667667
ghConn := ghcontrol.NewGhConnectionWithClient(targetOwner, targetRepo, targetBranch, ghClient)
668668
return ghConn, server

pkg/repo/clone.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,11 @@ import (
1313
"strings"
1414
"time"
1515

16-
billy "github.com/go-git/go-billy/v6"
17-
git "github.com/go-git/go-git/v6"
18-
"github.com/go-git/go-git/v6/config"
19-
"github.com/go-git/go-git/v6/plumbing"
20-
"github.com/go-git/go-git/v6/plumbing/object"
16+
billy "github.com/go-git/go-billy/v5"
17+
git "github.com/go-git/go-git/v5"
18+
"github.com/go-git/go-git/v5/config"
19+
"github.com/go-git/go-git/v5/plumbing"
20+
"github.com/go-git/go-git/v5/plumbing/object"
2121
"github.com/google/uuid"
2222
"sigs.k8s.io/release-utils/command"
2323

0 commit comments

Comments
 (0)