Skip to content

Commit 58d0f87

Browse files
Update to go-github/v69
1 parent c9fc795 commit 58d0f87

12 files changed

+618
-93
lines changed

README.md

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -31,14 +31,14 @@ mockedHTTPClient := mock.NewMockedHTTPClient(
3131
mock.WithRequestMatch(
3232
mock.GetUsersByUsername,
3333
github.User{
34-
Name: github.String("foobar"),
34+
Name: github.Ptr("foobar"),
3535
},
3636
),
3737
mock.WithRequestMatch(
3838
mock.GetUsersOrgsByUsername,
3939
[]github.Organization{
4040
{
41-
Name: github.String("foobar123thisorgwasmocked"),
41+
Name: github.Ptr("foobar123thisorgwasmocked"),
4242
},
4343
},
4444
),
@@ -47,10 +47,10 @@ mockedHTTPClient := mock.NewMockedHTTPClient(
4747
http.HandlerFunc(func(w http.ResponseWriter, _ *http.Request) {
4848
w.Write(mock.MustMarshal([]github.Project{
4949
{
50-
Name: github.String("mocked-proj-1"),
50+
Name: github.Ptr("mocked-proj-1"),
5151
},
5252
{
53-
Name: github.String("mocked-proj-2"),
53+
Name: github.Ptr("mocked-proj-2"),
5454
},
5555
}))
5656
}),
@@ -92,11 +92,11 @@ mockedHTTPClient := NewMockedHTTPClient(
9292
[]github.Issue{
9393
{
9494
ID: github.Int64(123),
95-
Title: github.String("Issue 1"),
95+
Title: github.Ptr("Issue 1"),
9696
},
9797
{
9898
ID: github.Int64(456),
99-
Title: github.String("Issue 2"),
99+
Title: github.Ptr("Issue 2"),
100100
},
101101
},
102102
[]github.Issue{},
@@ -157,18 +157,18 @@ mockedHTTPClient := NewMockedHTTPClient(
157157
GetOrgsReposByOrg,
158158
[]github.Repository{
159159
{
160-
Name: github.String("repo-A-on-first-page"),
160+
Name: github.Ptr("repo-A-on-first-page"),
161161
},
162162
{
163-
Name: github.String("repo-B-on-first-page"),
163+
Name: github.Ptr("repo-B-on-first-page"),
164164
},
165165
},
166166
[]github.Repository{
167167
{
168-
Name: github.String("repo-C-on-second-page"),
168+
Name: github.Ptr("repo-C-on-second-page"),
169169
},
170170
{
171-
Name: github.String("repo-D-on-second-page"),
171+
Name: github.Ptr("repo-D-on-second-page"),
172172
},
173173
},
174174
),
@@ -222,7 +222,7 @@ mockedHTTPClient := mock.NewMockedHTTPClient(
222222
mock.WithRequestMatchEnterprise( // uses enterprise endpoints instead
223223
mock.GetUsersByUsername,
224224
github.User{
225-
Name: github.String("foobar"),
225+
Name: github.Ptr("foobar"),
226226
},
227227
),
228228
)
@@ -246,8 +246,8 @@ user, _, userErr := c.Users.Get(ctx, "myuser")
246246
mockedHTTPClient := mock.NewMockedHTTPClient(
247247
mock.WithRequestMatchPages(
248248
mock.GetOrgsReposByOrg,
249-
[]github.Repository{{Name: github.String(repoOne)}},
250-
[]github.Repository{{Name: github.String(repoTwo)}},
249+
[]github.Repository{{Name: github.Ptr(repoOne)}},
250+
[]github.Repository{{Name: github.Ptr(repoTwo)}},
251251
),
252252

253253
// The rate limiter will allow 10 requests per second, and a burst size of 1.

go.mod

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,9 @@ go 1.23
44

55
require (
66
github.com/buger/jsonparser v1.1.1
7-
github.com/google/go-github/v64 v64.0.0
7+
github.com/google/go-github/v69 v69.2.0
88
github.com/gorilla/mux v1.8.0
9+
golang.org/x/mod v0.17.0
910
golang.org/x/text v0.19.0
1011
golang.org/x/time v0.3.0
1112
)

go.sum

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,14 @@ github.com/buger/jsonparser v1.1.1/go.mod h1:6RYKKt7H4d4+iWqouImQ9R2FZql3VbhNgx2
33
github.com/google/go-cmp v0.5.2/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
44
github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI=
55
github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
6-
github.com/google/go-github/v64 v64.0.0 h1:4G61sozmY3eiPAjjoOHponXDBONm+utovTKbyUb2Qdg=
7-
github.com/google/go-github/v64 v64.0.0/go.mod h1:xB3vqMQNdHzilXBiO2I+M7iEFtHf+DP/omBOv6tQzVo=
6+
github.com/google/go-github/v69 v69.2.0 h1:wR+Wi/fN2zdUx9YxSmYE0ktiX9IAR/BeePzeaUUbEHE=
7+
github.com/google/go-github/v69 v69.2.0/go.mod h1:xne4jymxLR6Uj9b7J7PyTpkMYstEMMwGZa0Aehh1azM=
88
github.com/google/go-querystring v1.1.0 h1:AnCroh3fv4ZBgVIf1Iwtovgjaw/GiKJo8M8yD/fhyJ8=
99
github.com/google/go-querystring v1.1.0/go.mod h1:Kcdr2DB4koayq7X8pmAG4sNG59So17icRSOU623lUBU=
1010
github.com/gorilla/mux v1.8.0 h1:i40aqfkR1h2SlN9hojwV5ZA91wcXFOvkdNIeFDP5koI=
1111
github.com/gorilla/mux v1.8.0/go.mod h1:DVbg23sWSpFRCP0SfiEN6jmj59UnW/n46BH5rLB71So=
12+
golang.org/x/mod v0.17.0 h1:zY54UmvipHiNd+pm+m0x9KhZ9hl1/7QNMyxXbc6ICqA=
13+
golang.org/x/mod v0.17.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c=
1214
golang.org/x/text v0.19.0 h1:kTxAhCbGbxhK0IwgSKiMO5awPoDQ0RpfiVYBfK860YM=
1315
golang.org/x/text v0.19.0/go.mod h1:BuEKDfySbSR4drPmRPG/7iBdf8hvFMuRexcpahXilzY=
1416
golang.org/x/time v0.3.0 h1:rg5rLMjNzMS1RkNLzCG38eapWhnYLFYXDXj2gOlr8j4=

main.go

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,25 @@ package main
22

33
import (
44
"bytes"
5+
"context"
56
"flag"
7+
"fmt"
68
"log/slog"
79
"os"
810
"os/exec"
911

1012
"github.com/buger/jsonparser"
13+
"github.com/google/go-github/v69/github"
1114

1215
"github.com/migueleliasweb/go-github-mock/src/gen"
16+
"golang.org/x/mod/modfile"
1317
)
1418

1519
func main() {
1620
flag.Parse()
1721

1822
fetchAndWriteAPIDefinition()
23+
updateGoGithubDep()
1924
}
2025

2126
// type helper just to ensure uniqueness of the generated output
@@ -101,3 +106,37 @@ func fetchAndWriteAPIDefinition() {
101106
os.Exit(1)
102107
}
103108
}
109+
110+
func updateGoGithubDep() {
111+
ghClient := github.NewClient(nil)
112+
113+
fileContent, _, _, err := ghClient.Repositories.GetContents(
114+
context.Background(),
115+
"google",
116+
"go-github",
117+
"/go.mod",
118+
nil,
119+
)
120+
121+
if err != nil {
122+
panic("error fetching go.mod contents from google/go-github: " + err.Error())
123+
}
124+
125+
decodedContents, err := fileContent.GetContent()
126+
127+
if err != nil {
128+
panic("error decoding go.mod contents from google/go-github: " + err.Error())
129+
}
130+
131+
goModFile, err := modfile.Parse(
132+
"go.mod",
133+
[]byte(decodedContents),
134+
nil,
135+
)
136+
137+
if err != nil {
138+
panic("error parsing go.mod contents from google/go-github: " + err.Error())
139+
}
140+
141+
fmt.Println(goModFile.Module.Mod.Path)
142+
}

0 commit comments

Comments
 (0)