From 6a81121b1efa66801fc464151cbe298e556e3e65 Mon Sep 17 00:00:00 2001 From: "mm-renovate-bot[bot]" <265138953+mm-renovate-bot[bot]@users.noreply.github.com> Date: Tue, 17 Mar 2026 03:16:59 +0000 Subject: [PATCH 1/4] dev: Update module github.com/google/go-github/v63 to v84 --- go.mod | 5 +++-- go.sum | 3 +++ 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/go.mod b/go.mod index f4e881e..6672785 100644 --- a/go.mod +++ b/go.mod @@ -1,11 +1,12 @@ module github.com/multimediallc/codeowners-plus -go 1.23.1 +go 1.25.0 require ( github.com/bmatcuk/doublestar/v4 v4.10.0 github.com/boyter/gocodewalker v1.5.1 github.com/google/go-github/v63 v63.0.0 + github.com/google/go-github/v84 v84.0.0 github.com/pelletier/go-toml/v2 v2.2.4 github.com/sourcegraph/go-diff v0.7.0 github.com/urfave/cli/v2 v2.27.7 @@ -14,7 +15,7 @@ require ( require ( github.com/cpuguy83/go-md2man/v2 v2.0.7 // indirect github.com/danwakefield/fnmatch v0.0.0-20160403171240-cbb64ac3d964 // indirect - github.com/google/go-querystring v1.1.0 // indirect + github.com/google/go-querystring v1.2.0 // indirect github.com/russross/blackfriday/v2 v2.1.0 // indirect github.com/xrash/smetrics v0.0.0-20240521201337-686a1a2994c1 // indirect golang.org/x/sync v0.12.0 // indirect diff --git a/go.sum b/go.sum index 0835e2b..b96f857 100644 --- a/go.sum +++ b/go.sum @@ -11,8 +11,11 @@ github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI= github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= github.com/google/go-github/v63 v63.0.0 h1:13xwK/wk9alSokujB9lJkuzdmQuVn2QCPeck76wR3nE= github.com/google/go-github/v63 v63.0.0/go.mod h1:IqbcrgUmIcEaioWrGYei/09o+ge5vhffGOcxrO0AfmA= +github.com/google/go-github/v84 v84.0.0/go.mod h1:WwYL1z1ajRdlaPszjVu/47x1L0PXukJBn73xsiYrRRQ= github.com/google/go-querystring v1.1.0 h1:AnCroh3fv4ZBgVIf1Iwtovgjaw/GiKJo8M8yD/fhyJ8= github.com/google/go-querystring v1.1.0/go.mod h1:Kcdr2DB4koayq7X8pmAG4sNG59So17icRSOU623lUBU= +github.com/google/go-querystring v1.2.0 h1:yhqkPbu2/OH+V9BfpCVPZkNmUXhb2gBxJArfhIxNtP0= +github.com/google/go-querystring v1.2.0/go.mod h1:8IFJqpSRITyJ8QhQ13bmbeMBDfmeEJZD5A0egEOmkqU= github.com/pelletier/go-toml/v2 v2.2.4 h1:mye9XuhQ6gvn5h28+VilKrrPoQVanw5PMw/TB0t5Ec4= github.com/pelletier/go-toml/v2 v2.2.4/go.mod h1:2gIqNv+qfxSVS7cM2xJQKtLSTLUE9V8t9Stt+h56mCY= github.com/russross/blackfriday/v2 v2.1.0 h1:JIOH55/0cWyOuilr9/qlrm0BSXldqnqwMsf35Ld67mk= From 054fc2923f58a5cc9e5eb0b926c87f6f728f36af Mon Sep 17 00:00:00 2001 From: BakerNet Date: Tue, 17 Mar 2026 11:22:53 -0700 Subject: [PATCH 2/4] upgrade go-github and go version fixes --- go.mod | 1 - go.sum | 8 +++----- internal/app/app.go | 4 ++-- internal/app/app_test.go | 2 +- internal/github/gh.go | 2 +- internal/github/gh_test.go | 2 +- 6 files changed, 8 insertions(+), 11 deletions(-) diff --git a/go.mod b/go.mod index 6672785..26488a1 100644 --- a/go.mod +++ b/go.mod @@ -5,7 +5,6 @@ go 1.25.0 require ( github.com/bmatcuk/doublestar/v4 v4.10.0 github.com/boyter/gocodewalker v1.5.1 - github.com/google/go-github/v63 v63.0.0 github.com/google/go-github/v84 v84.0.0 github.com/pelletier/go-toml/v2 v2.2.4 github.com/sourcegraph/go-diff v0.7.0 diff --git a/go.sum b/go.sum index b96f857..672ed04 100644 --- a/go.sum +++ b/go.sum @@ -7,13 +7,11 @@ github.com/cpuguy83/go-md2man/v2 v2.0.7/go.mod h1:oOW0eioCTA6cOiMLiUPZOpcVxMig6N github.com/danwakefield/fnmatch v0.0.0-20160403171240-cbb64ac3d964 h1:y5HC9v93H5EPKqaS1UYVg1uYah5Xf51mBfIoWehClUQ= github.com/danwakefield/fnmatch v0.0.0-20160403171240-cbb64ac3d964/go.mod h1:Xd9hchkHSWYkEqJwUGisez3G1QY8Ryz0sdWrLPMGjLk= github.com/google/go-cmp v0.5.2/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= -github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI= github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= -github.com/google/go-github/v63 v63.0.0 h1:13xwK/wk9alSokujB9lJkuzdmQuVn2QCPeck76wR3nE= -github.com/google/go-github/v63 v63.0.0/go.mod h1:IqbcrgUmIcEaioWrGYei/09o+ge5vhffGOcxrO0AfmA= +github.com/google/go-cmp v0.7.0 h1:wk8382ETsv4JYUZwIsn6YpYiWiBsYLSJiTsyBybVuN8= +github.com/google/go-cmp v0.7.0/go.mod h1:pXiqmnSA92OHEEa9HXL2W4E7lf9JzCmGVUdgjX3N/iU= +github.com/google/go-github/v84 v84.0.0 h1:I/0Xn5IuChMe8TdmI2bbim5nyhaRFJ7DEdzmD2w+yVA= github.com/google/go-github/v84 v84.0.0/go.mod h1:WwYL1z1ajRdlaPszjVu/47x1L0PXukJBn73xsiYrRRQ= -github.com/google/go-querystring v1.1.0 h1:AnCroh3fv4ZBgVIf1Iwtovgjaw/GiKJo8M8yD/fhyJ8= -github.com/google/go-querystring v1.1.0/go.mod h1:Kcdr2DB4koayq7X8pmAG4sNG59So17icRSOU623lUBU= github.com/google/go-querystring v1.2.0 h1:yhqkPbu2/OH+V9BfpCVPZkNmUXhb2gBxJArfhIxNtP0= github.com/google/go-querystring v1.2.0/go.mod h1:8IFJqpSRITyJ8QhQ13bmbeMBDfmeEJZD5A0egEOmkqU= github.com/pelletier/go-toml/v2 v2.2.4 h1:mye9XuhQ6gvn5h28+VilKrrPoQVanw5PMw/TB0t5Ec4= diff --git a/internal/app/app.go b/internal/app/app.go index 69c0b41..8365e89 100644 --- a/internal/app/app.go +++ b/internal/app/app.go @@ -552,9 +552,9 @@ func (a *App) requestReviews() error { func (a *App) printFileOwners(codeOwners codeowners.CodeOwners) { a.printDebug("File Reviewers:\n") - a.printDebug(a.getFileOwnersMapToString(codeOwners.FileRequired())) + a.printDebug("%s", a.getFileOwnersMapToString(codeOwners.FileRequired())) a.printDebug("File Optional:\n") - a.printDebug(a.getFileOwnersMapToString(codeOwners.FileOptional())) + a.printDebug("%s", a.getFileOwnersMapToString(codeOwners.FileOptional())) } func (a *App) getFileOwnersMapToString(fileReviewers map[string]codeowners.ReviewerGroups) string { diff --git a/internal/app/app_test.go b/internal/app/app_test.go index dd774bb..310ea18 100644 --- a/internal/app/app_test.go +++ b/internal/app/app_test.go @@ -8,7 +8,7 @@ import ( "testing" "time" - "github.com/google/go-github/v63/github" + "github.com/google/go-github/v84/github" owners "github.com/multimediallc/codeowners-plus/internal/config" "github.com/multimediallc/codeowners-plus/internal/git" gh "github.com/multimediallc/codeowners-plus/internal/github" diff --git a/internal/github/gh.go b/internal/github/gh.go index bd14108..85942a1 100644 --- a/internal/github/gh.go +++ b/internal/github/gh.go @@ -9,7 +9,7 @@ import ( "strings" "time" - "github.com/google/go-github/v63/github" + "github.com/google/go-github/v84/github" "github.com/multimediallc/codeowners-plus/internal/git" "github.com/multimediallc/codeowners-plus/pkg/codeowners" f "github.com/multimediallc/codeowners-plus/pkg/functional" diff --git a/internal/github/gh_test.go b/internal/github/gh_test.go index d928c1b..980879a 100644 --- a/internal/github/gh_test.go +++ b/internal/github/gh_test.go @@ -13,7 +13,7 @@ import ( "testing" "time" - "github.com/google/go-github/v63/github" + "github.com/google/go-github/v84/github" "github.com/multimediallc/codeowners-plus/pkg/codeowners" f "github.com/multimediallc/codeowners-plus/pkg/functional" ) From 3d559f34fe0ac2b4d8bbd0b42f837893855d375b Mon Sep 17 00:00:00 2001 From: BakerNet Date: Tue, 17 Mar 2026 11:26:44 -0700 Subject: [PATCH 3/4] rebase --- go.mod | 5 +++-- go.sum | 7 ++++--- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/go.mod b/go.mod index 5857e23..ec8d2c2 100644 --- a/go.mod +++ b/go.mod @@ -1,6 +1,6 @@ module github.com/multimediallc/codeowners-plus -go 1.23.1 +go 1.25.0 require ( github.com/bmatcuk/doublestar/v4 v4.10.0 @@ -13,6 +13,7 @@ require ( require ( github.com/danwakefield/fnmatch v0.0.0-20160403171240-cbb64ac3d964 // indirect - github.com/google/go-querystring v1.1.0 // indirect + github.com/google/go-cmp v0.7.0 // indirect + github.com/google/go-querystring v1.2.0 // indirect golang.org/x/sync v0.12.0 // indirect ) diff --git a/go.sum b/go.sum index ce4f73c..8df4e63 100644 --- a/go.sum +++ b/go.sum @@ -7,12 +7,13 @@ github.com/danwakefield/fnmatch v0.0.0-20160403171240-cbb64ac3d964/go.mod h1:Xd9 github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/google/go-cmp v0.5.2/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= -github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI= github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= +github.com/google/go-cmp v0.7.0 h1:wk8382ETsv4JYUZwIsn6YpYiWiBsYLSJiTsyBybVuN8= +github.com/google/go-cmp v0.7.0/go.mod h1:pXiqmnSA92OHEEa9HXL2W4E7lf9JzCmGVUdgjX3N/iU= github.com/google/go-github/v63 v63.0.0 h1:13xwK/wk9alSokujB9lJkuzdmQuVn2QCPeck76wR3nE= github.com/google/go-github/v63 v63.0.0/go.mod h1:IqbcrgUmIcEaioWrGYei/09o+ge5vhffGOcxrO0AfmA= -github.com/google/go-querystring v1.1.0 h1:AnCroh3fv4ZBgVIf1Iwtovgjaw/GiKJo8M8yD/fhyJ8= -github.com/google/go-querystring v1.1.0/go.mod h1:Kcdr2DB4koayq7X8pmAG4sNG59So17icRSOU623lUBU= +github.com/google/go-querystring v1.2.0 h1:yhqkPbu2/OH+V9BfpCVPZkNmUXhb2gBxJArfhIxNtP0= +github.com/google/go-querystring v1.2.0/go.mod h1:8IFJqpSRITyJ8QhQ13bmbeMBDfmeEJZD5A0egEOmkqU= github.com/pelletier/go-toml/v2 v2.2.4 h1:mye9XuhQ6gvn5h28+VilKrrPoQVanw5PMw/TB0t5Ec4= github.com/pelletier/go-toml/v2 v2.2.4/go.mod h1:2gIqNv+qfxSVS7cM2xJQKtLSTLUE9V8t9Stt+h56mCY= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= From 9ca49d1428899379b31db232e495afe0dbbe9637 Mon Sep 17 00:00:00 2001 From: BakerNet Date: Tue, 17 Mar 2026 11:42:41 -0700 Subject: [PATCH 4/4] fix linters --- internal/app/app_test.go | 8 +- internal/github/gh.go | 4 +- internal/github/gh_test.go | 170 ++++++++++++++++++------------------- 3 files changed, 91 insertions(+), 91 deletions(-) diff --git a/internal/app/app_test.go b/internal/app/app_test.go index 310ea18..10ab418 100644 --- a/internal/app/app_test.go +++ b/internal/app/app_test.go @@ -201,7 +201,7 @@ func (m *mockGitHubClient) InitPR(pr_id int) error { return m.initPRError } if m.pr == nil { - m.pr = &github.PullRequest{Number: github.Int(pr_id)} + m.pr = &github.PullRequest{Number: github.Ptr(pr_id)} } return nil } @@ -233,7 +233,7 @@ func (m *mockGitHubClient) AddComment(comment string) error { if m.comments == nil { m.comments = make([]*github.IssueComment, 0) } - m.comments = append(m.comments, &github.IssueComment{Body: github.String(comment)}) + m.comments = append(m.comments, &github.IssueComment{Body: github.Ptr(comment)}) return nil } @@ -555,8 +555,8 @@ func TestAddReviewStatusComment(t *testing.T) { }, existingComments: []*github.IssueComment{ { - ID: github.Int64(1), - Body: github.String("Codeowners approval required for this PR:\n[ ] @user1"), + ID: github.Ptr[int64](1), + Body: github.Ptr("Codeowners approval required for this PR:\n[ ] @user1"), }, }, expectUpdateComment: true, diff --git a/internal/github/gh.go b/internal/github/gh.go index 85942a1..a7f02bb 100644 --- a/internal/github/gh.go +++ b/internal/github/gh.go @@ -411,8 +411,8 @@ func (gh *GHClient) ApprovePR() error { return &NoPRError{} } createReviewOptions := &github.PullRequestReviewRequest{ - Event: github.String("APPROVE"), - Body: github.String("Codeowners reviews satisfied"), + Event: github.Ptr("APPROVE"), + Body: github.Ptr("Codeowners reviews satisfied"), } _, res, err := gh.client.PullRequests.CreateReview(gh.ctx, gh.owner, gh.repo, gh.pr.GetNumber(), createReviewOptions) if err != nil { diff --git a/internal/github/gh_test.go b/internal/github/gh_test.go index 980879a..56a3a28 100644 --- a/internal/github/gh_test.go +++ b/internal/github/gh_test.go @@ -20,10 +20,10 @@ import ( func setupReviews() *GHClient { reviews := []*github.PullRequestReview{ - {User: &github.User{Login: github.String("reviewer1")}, State: github.String("APPROVED"), ID: github.Int64(1), CommitID: github.String("commit1")}, - {User: &github.User{Login: github.String("reviewer2")}, State: github.String("REQUEST_CHANGES"), ID: github.Int64(2), CommitID: github.String("commit2")}, - {User: &github.User{Login: github.String("reviewer3")}, State: github.String("APPROVED"), ID: github.Int64(1), CommitID: github.String("commit1")}, - {User: &github.User{Login: github.String("reviewer4")}, State: github.String("APPROVED"), ID: github.Int64(3), CommitID: github.String("commit3")}, + {User: &github.User{Login: github.Ptr("reviewer1")}, State: github.Ptr("APPROVED"), ID: github.Ptr[int64](1), CommitID: github.Ptr("commit1")}, + {User: &github.User{Login: github.Ptr("reviewer2")}, State: github.Ptr("REQUEST_CHANGES"), ID: github.Ptr[int64](2), CommitID: github.Ptr("commit2")}, + {User: &github.User{Login: github.Ptr("reviewer3")}, State: github.Ptr("APPROVED"), ID: github.Ptr[int64](1), CommitID: github.Ptr("commit1")}, + {User: &github.User{Login: github.Ptr("reviewer4")}, State: github.Ptr("APPROVED"), ID: github.Ptr[int64](3), CommitID: github.Ptr("commit3")}, } userReviewerMap := ghUserReviewerMap{ "reviewer1": codeowners.NewSlugs([]string{"@a", "@b"}), @@ -33,7 +33,7 @@ func setupReviews() *GHClient { gh := &GHClient{ reviews: reviews, userReviewerMap: userReviewerMap, - pr: &github.PullRequest{Number: github.Int(1)}, + pr: &github.PullRequest{Number: github.Ptr(1)}, } return gh } @@ -42,9 +42,9 @@ func TestApprovals(t *testing.T) { gh := setupReviews() approvals := gh.approvals() expectedApprovals := []*github.PullRequestReview{ - {User: &github.User{Login: github.String("reviewer1")}, State: github.String("APPROVED"), ID: github.Int64(1), CommitID: github.String("commit1")}, - {User: &github.User{Login: github.String("reviewer3")}, State: github.String("APPROVED"), ID: github.Int64(1), CommitID: github.String("commit1")}, - {User: &github.User{Login: github.String("reviewer4")}, State: github.String("APPROVED"), ID: github.Int64(3), CommitID: github.String("commit3")}, + {User: &github.User{Login: github.Ptr("reviewer1")}, State: github.Ptr("APPROVED"), ID: github.Ptr[int64](1), CommitID: github.Ptr("commit1")}, + {User: &github.User{Login: github.Ptr("reviewer3")}, State: github.Ptr("APPROVED"), ID: github.Ptr[int64](1), CommitID: github.Ptr("commit1")}, + {User: &github.User{Login: github.Ptr("reviewer4")}, State: github.Ptr("APPROVED"), ID: github.Ptr[int64](3), CommitID: github.Ptr("commit3")}, } if len(approvals) != len(expectedApprovals) { @@ -169,12 +169,12 @@ func TestCurrentlyRequested(t *testing.T) { } pr := &github.PullRequest{ RequestedReviewers: []*github.User{ - {Login: github.String("user1")}, - {Login: github.String("user2")}, + {Login: github.Ptr("user1")}, + {Login: github.Ptr("user2")}, }, RequestedTeams: []*github.Team{ - {Slug: github.String("team1")}, - {Slug: github.String("team2")}, + {Slug: github.Ptr("team1")}, + {Slug: github.Ptr("team2")}, }, } @@ -217,12 +217,12 @@ func TestMakeGHUserReviewerMap(t *testing.T) { } if team == "team1" { return []*github.User{ - {Login: github.String("user1")}, - {Login: github.String("user3")}, + {Login: github.Ptr("user1")}, + {Login: github.Ptr("user3")}, } } return []*github.User{ - {Login: github.String("user1")}, + {Login: github.Ptr("user1")}, } } userReviewerMap := makeGHUserReviwerMap([]string{"@user1", "@user2", "@org/team1", "@org/team2", "@other/teamX"}, teamFetcher) @@ -242,11 +242,11 @@ func TestMakeGHUserReviewerMap(t *testing.T) { func TestIsInComments(t *testing.T) { gh := &GHClient{ - pr: &github.PullRequest{Number: github.Int(1)}, + pr: &github.PullRequest{Number: github.Ptr(1)}, comments: []*github.IssueComment{ - {Body: github.String("comment1"), CreatedAt: &github.Timestamp{Time: time.Now().AddDate(0, 0, -2)}}, - {Body: github.String("comment2"), CreatedAt: &github.Timestamp{Time: time.Now().AddDate(0, 0, -1)}}, - {Body: github.String("comment3"), CreatedAt: &github.Timestamp{Time: time.Now()}}, + {Body: github.Ptr("comment1"), CreatedAt: &github.Timestamp{Time: time.Now().AddDate(0, 0, -2)}}, + {Body: github.Ptr("comment2"), CreatedAt: &github.Timestamp{Time: time.Now().AddDate(0, 0, -1)}}, + {Body: github.Ptr("comment3"), CreatedAt: &github.Timestamp{Time: time.Now()}}, }, } @@ -280,11 +280,11 @@ func TestIsInComments(t *testing.T) { func TestIsSubstringInComments(t *testing.T) { gh := &GHClient{ - pr: &github.PullRequest{Number: github.Int(1)}, + pr: &github.PullRequest{Number: github.Ptr(1)}, comments: []*github.IssueComment{ - {Body: github.String("part1 part4"), CreatedAt: &github.Timestamp{Time: time.Now().AddDate(0, 0, -2)}}, - {Body: github.String("part2 part5"), CreatedAt: &github.Timestamp{Time: time.Now().AddDate(0, 0, -1)}}, - {Body: github.String("part3 part6"), CreatedAt: &github.Timestamp{Time: time.Now()}}, + {Body: github.Ptr("part1 part4"), CreatedAt: &github.Timestamp{Time: time.Now().AddDate(0, 0, -2)}}, + {Body: github.Ptr("part2 part5"), CreatedAt: &github.Timestamp{Time: time.Now().AddDate(0, 0, -1)}}, + {Body: github.Ptr("part3 part6"), CreatedAt: &github.Timestamp{Time: time.Now()}}, }, } @@ -451,7 +451,7 @@ func TestNilPRErr(t *testing.T) { func TestNilUserReviewerMapErr(t *testing.T) { gh := &GHClient{ - pr: &github.PullRequest{Number: github.Int(1)}, + pr: &github.PullRequest{Number: github.Ptr(1)}, } tt := []struct { name string @@ -489,7 +489,7 @@ func TestNilReviewsErr(t *testing.T) { mux, server, gh := mockServerAndClient(t) defer server.Close() - gh.pr = &github.PullRequest{Number: github.Int(1)} + gh.pr = &github.PullRequest{Number: github.Ptr(1)} gh.userReviewerMap = make(ghUserReviewerMap) mux.HandleFunc("/repos/test-owner/test-repo/pulls/123/reviews", func(w http.ResponseWriter, r *http.Request) { @@ -540,7 +540,7 @@ func TestNilCommentsErr(t *testing.T) { mux, server, gh := mockServerAndClient(t) defer server.Close() - gh.pr = &github.PullRequest{Number: github.Int(1)} + gh.pr = &github.PullRequest{Number: github.Ptr(1)} gh.userReviewerMap = make(ghUserReviewerMap) mux.HandleFunc("/repos/test-owner/test-repo/issues/123/comments", func(w http.ResponseWriter, r *http.Request) { @@ -605,7 +605,7 @@ func TestInitPRSuccess(t *testing.T) { defer server.Close() prID := 123 - mockPR := &github.PullRequest{Number: github.Int(prID)} + mockPR := &github.PullRequest{Number: github.Ptr(prID)} mux.HandleFunc("/repos/test-owner/test-repo/pulls/123", func(w http.ResponseWriter, r *http.Request) { if r.Method != http.MethodGet { @@ -651,7 +651,7 @@ func TestGetTokenUserSuccess(t *testing.T) { mux, server, gh := mockServerAndClient(t) defer server.Close() - mockUser := &github.User{Login: github.String("test-user")} + mockUser := &github.User{Login: github.Ptr("test-user")} mux.HandleFunc("/user", func(w http.ResponseWriter, r *http.Request) { if r.Method != http.MethodGet { @@ -691,10 +691,10 @@ func TestInitReviewsSuccess(t *testing.T) { mux, server, gh := mockServerAndClient(t) defer server.Close() - gh.pr = &github.PullRequest{Number: github.Int(123)} + gh.pr = &github.PullRequest{Number: github.Ptr(123)} mockReviews := []*github.PullRequestReview{ - {User: &github.User{Login: github.String("test")}, ID: github.Int64(1)}, - {User: &github.User{Login: github.String("test")}, ID: github.Int64(2)}, + {User: &github.User{Login: github.Ptr("test")}, ID: github.Ptr[int64](1)}, + {User: &github.User{Login: github.Ptr("test")}, ID: github.Ptr[int64](2)}, } mux.HandleFunc("/repos/test-owner/test-repo/pulls/123/reviews", func(w http.ResponseWriter, r *http.Request) { @@ -718,7 +718,7 @@ func TestInitReviewsFailure(t *testing.T) { mux, server, gh := mockServerAndClient(t) defer server.Close() - gh.pr = &github.PullRequest{Number: github.Int(123)} + gh.pr = &github.PullRequest{Number: github.Ptr(123)} mux.HandleFunc("/repos/test-owner/test-repo/pulls/123/reviews", func(w http.ResponseWriter, r *http.Request) { http.Error(w, "Unauthorized", http.StatusUnauthorized) @@ -737,7 +737,7 @@ func TestDismissStaleReviewsSuccess(t *testing.T) { mux, server, gh := mockServerAndClient(t) defer server.Close() - gh.pr = &github.PullRequest{Number: github.Int(123)} + gh.pr = &github.PullRequest{Number: github.Ptr(123)} staleApprovals := []*CurrentApproval{ {ReviewID: 1}, @@ -768,7 +768,7 @@ func TestDismissStaleReviewsFailure(t *testing.T) { mux, server, gh := mockServerAndClient(t) defer server.Close() - gh.pr = &github.PullRequest{Number: github.Int(123)} + gh.pr = &github.PullRequest{Number: github.Ptr(123)} staleApprovals := []*CurrentApproval{ {ReviewID: 1}, } @@ -788,7 +788,7 @@ func TestRequestReviewersSuccess(t *testing.T) { mux, server, gh := mockServerAndClient(t) defer server.Close() - gh.pr = &github.PullRequest{Number: github.Int(123)} + gh.pr = &github.PullRequest{Number: github.Ptr(123)} reviewers := []string{"@reviewer1", "@org/team1"} @@ -823,7 +823,7 @@ func TestRequestReviewersFailure(t *testing.T) { mux, server, gh := mockServerAndClient(t) defer server.Close() - gh.pr = &github.PullRequest{Number: github.Int(123)} + gh.pr = &github.PullRequest{Number: github.Ptr(123)} reviewers := []string{"@reviewer1", "@org/team1"} @@ -842,7 +842,7 @@ func TestApprovePRSuccess(t *testing.T) { mux, server, gh := mockServerAndClient(t) defer server.Close() - gh.pr = &github.PullRequest{Number: github.Int(123)} + gh.pr = &github.PullRequest{Number: github.Ptr(123)} // Mock the GitHub API endpoint mux.HandleFunc("/repos/test-owner/test-repo/pulls/123/reviews", func(w http.ResponseWriter, r *http.Request) { @@ -875,7 +875,7 @@ func TestApprovePRFailure(t *testing.T) { mux, server, gh := mockServerAndClient(t) defer server.Close() - gh.pr = &github.PullRequest{Number: github.Int(123)} + gh.pr = &github.PullRequest{Number: github.Ptr(123)} // Mock the GitHub API to simulate an error mux.HandleFunc("/repos/test-owner/test-repo/pulls/123/reviews", func(w http.ResponseWriter, r *http.Request) { @@ -892,11 +892,11 @@ func TestInitCommentsSuccess(t *testing.T) { mux, server, gh := mockServerAndClient(t) defer server.Close() - gh.pr = &github.PullRequest{Number: github.Int(123)} + gh.pr = &github.PullRequest{Number: github.Ptr(123)} mockComments := []*github.IssueComment{ - {ID: github.Int64(1), Body: github.String("Comment 1")}, - {ID: github.Int64(2), Body: github.String("Comment 2")}, + {ID: github.Ptr[int64](1), Body: github.Ptr("Comment 1")}, + {ID: github.Ptr[int64](2), Body: github.Ptr("Comment 2")}, } mux.HandleFunc("/repos/test-owner/test-repo/issues/123/comments", func(w http.ResponseWriter, r *http.Request) { @@ -920,7 +920,7 @@ func TestInitCommentsFailure(t *testing.T) { mux, server, gh := mockServerAndClient(t) defer server.Close() - gh.pr = &github.PullRequest{Number: github.Int(123)} + gh.pr = &github.PullRequest{Number: github.Ptr(123)} mux.HandleFunc("/repos/test-owner/test-repo/issues/123/comments", func(w http.ResponseWriter, r *http.Request) { http.Error(w, "Internal Server Error", http.StatusInternalServerError) @@ -936,7 +936,7 @@ func TestAddCommentSuccess(t *testing.T) { mux, server, gh := mockServerAndClient(t) defer server.Close() - gh.pr = &github.PullRequest{Number: github.Int(123)} + gh.pr = &github.PullRequest{Number: github.Ptr(123)} // Mock the GitHub API endpoint mux.HandleFunc("/repos/test-owner/test-repo/issues/123/comments", func(w http.ResponseWriter, r *http.Request) { @@ -966,7 +966,7 @@ func TestAddCommentFailure(t *testing.T) { mux, server, gh := mockServerAndClient(t) defer server.Close() - gh.pr = &github.PullRequest{Number: github.Int(123)} + gh.pr = &github.PullRequest{Number: github.Ptr(123)} // Mock the GitHub API to simulate an error mux.HandleFunc("/repos/test-owner/test-repo/issues/123/comments", func(w http.ResponseWriter, r *http.Request) { @@ -983,7 +983,7 @@ func TestInitUserReviewerMap(t *testing.T) { mux, server, gh := mockServerAndClient(t) defer server.Close() - gh.pr = &github.PullRequest{Number: github.Int(123)} + gh.pr = &github.PullRequest{Number: github.Ptr(123)} // Mock the GitHub API endpoint reviewers := []string{"@org1/team1", "@user1", "@org2/team2"} @@ -995,8 +995,8 @@ func TestInitUserReviewerMap(t *testing.T) { } w.Header().Set("Content-Type", "application/json") _ = json.NewEncoder(w).Encode([]*github.User{ - {Login: github.String("team_member1")}, - {Login: github.String("team_member2")}, + {Login: github.Ptr("team_member1")}, + {Login: github.Ptr("team_member2")}, }) }) @@ -1007,7 +1007,7 @@ func TestInitUserReviewerMap(t *testing.T) { } w.Header().Set("Content-Type", "application/json") _ = json.NewEncoder(w).Encode([]*github.User{ - {Login: github.String("team_member1")}, + {Login: github.Ptr("team_member1")}, }) }) @@ -1043,7 +1043,7 @@ func TestIsInLabels(t *testing.T) { name: "has matching label", pr: &github.PullRequest{ Labels: []*github.Label{ - {Name: github.String("high-priority")}, + {Name: github.Ptr("high-priority")}, }, }, labels: []string{"high-priority"}, @@ -1055,8 +1055,8 @@ func TestIsInLabels(t *testing.T) { name: "has multiple labels but no match", pr: &github.PullRequest{ Labels: []*github.Label{ - {Name: github.String("bug")}, - {Name: github.String("enhancement")}, + {Name: github.Ptr("bug")}, + {Name: github.Ptr("enhancement")}, }, }, labels: []string{"high-priority"}, @@ -1068,7 +1068,7 @@ func TestIsInLabels(t *testing.T) { name: "empty labels list", pr: &github.PullRequest{ Labels: []*github.Label{ - {Name: github.String("high-priority")}, + {Name: github.Ptr("high-priority")}, }, }, labels: []string{}, @@ -1080,7 +1080,7 @@ func TestIsInLabels(t *testing.T) { name: "multiple target labels", pr: &github.PullRequest{ Labels: []*github.Label{ - {Name: github.String("urgent")}, + {Name: github.Ptr("urgent")}, }, }, labels: []string{"high-priority", "urgent"}, @@ -1135,8 +1135,8 @@ func TestFindExistingComment(t *testing.T) { name: "comment found", comments: []*github.IssueComment{ { - ID: github.Int64(1), - Body: github.String("Codeowners approval required for this PR:\n- [ ] @user1"), + ID: github.Ptr[int64](1), + Body: github.Ptr("Codeowners approval required for this PR:\n- [ ] @user1"), }, }, prefix: "Codeowners approval required for this PR:", @@ -1148,8 +1148,8 @@ func TestFindExistingComment(t *testing.T) { name: "comment not found", comments: []*github.IssueComment{ { - ID: github.Int64(1), - Body: github.String("Some other comment"), + ID: github.Ptr[int64](1), + Body: github.Ptr("Some other comment"), }, }, prefix: "Codeowners approval required for this PR:", @@ -1161,8 +1161,8 @@ func TestFindExistingComment(t *testing.T) { name: "comment too old", comments: []*github.IssueComment{ { - ID: github.Int64(1), - Body: github.String("Codeowners approval required for this PR:\n- [ ] @user1"), + ID: github.Ptr[int64](1), + Body: github.Ptr("Codeowners approval required for this PR:\n- [ ] @user1"), CreatedAt: &github.Timestamp{Time: time.Now().AddDate(0, 0, -6)}, // 6 days old }, }, @@ -1176,8 +1176,8 @@ func TestFindExistingComment(t *testing.T) { name: "comment within time range", comments: []*github.IssueComment{ { - ID: github.Int64(1), - Body: github.String("Codeowners approval required for this PR:\n- [ ] @user1"), + ID: github.Ptr[int64](1), + Body: github.Ptr("Codeowners approval required for this PR:\n- [ ] @user1"), CreatedAt: &github.Timestamp{Time: time.Now().AddDate(0, 0, -4)}, // 4 days old }, }, @@ -1194,7 +1194,7 @@ func TestFindExistingComment(t *testing.T) { mux, server, gh := mockServerAndClient(t) defer server.Close() - gh.pr = &github.PullRequest{Number: github.Int(123)} + gh.pr = &github.PullRequest{Number: github.Ptr(123)} // Mock the GitHub API endpoint mux.HandleFunc("/repos/test-owner/test-repo/issues/123/comments", func(w http.ResponseWriter, r *http.Request) { @@ -1255,7 +1255,7 @@ func TestUpdateComment(t *testing.T) { mux, server, gh := mockServerAndClient(t) defer server.Close() - gh.pr = &github.PullRequest{Number: github.Int(123)} + gh.pr = &github.PullRequest{Number: github.Ptr(123)} if tc.commentID != 0 { // Mock the GitHub API endpoint @@ -1305,9 +1305,9 @@ func TestContainsValidBypassApproval(t *testing.T) { name: "admin user with bypass text", reviews: []*github.PullRequestReview{ { - ID: github.Int64(123), - Body: github.String("🔓 Codeowners Bypass Approved by admin"), - User: &github.User{Login: github.String("admin-user")}, + ID: github.Ptr[int64](123), + Body: github.Ptr("🔓 Codeowners Bypass Approved by admin"), + User: &github.User{Login: github.Ptr("admin-user")}, }, }, allowedUsers: []string{}, @@ -1319,9 +1319,9 @@ func TestContainsValidBypassApproval(t *testing.T) { name: "allowed user with bypass text", reviews: []*github.PullRequestReview{ { - ID: github.Int64(124), - Body: github.String("Emergency bypass - codeowners bypass"), - User: &github.User{Login: github.String("emergency-user")}, + ID: github.Ptr[int64](124), + Body: github.Ptr("Emergency bypass - codeowners bypass"), + User: &github.User{Login: github.Ptr("emergency-user")}, }, }, allowedUsers: []string{"emergency-user"}, @@ -1333,9 +1333,9 @@ func TestContainsValidBypassApproval(t *testing.T) { name: "non-admin user with bypass text", reviews: []*github.PullRequestReview{ { - ID: github.Int64(125), - Body: github.String("codeowners bypass"), - User: &github.User{Login: github.String("regular-user")}, + ID: github.Ptr[int64](125), + Body: github.Ptr("codeowners bypass"), + User: &github.User{Login: github.Ptr("regular-user")}, }, }, allowedUsers: []string{}, @@ -1347,9 +1347,9 @@ func TestContainsValidBypassApproval(t *testing.T) { name: "admin user without bypass text", reviews: []*github.PullRequestReview{ { - ID: github.Int64(126), - Body: github.String("LGTM"), - User: &github.User{Login: github.String("admin-user")}, + ID: github.Ptr[int64](126), + Body: github.Ptr("LGTM"), + User: &github.User{Login: github.Ptr("admin-user")}, }, }, allowedUsers: []string{}, @@ -1361,9 +1361,9 @@ func TestContainsValidBypassApproval(t *testing.T) { name: "case insensitive bypass text", reviews: []*github.PullRequestReview{ { - ID: github.Int64(127), - Body: github.String("CODEOWNERS BYPASS"), - User: &github.User{Login: github.String("admin-user")}, + ID: github.Ptr[int64](127), + Body: github.Ptr("CODEOWNERS BYPASS"), + User: &github.User{Login: github.Ptr("admin-user")}, }, }, allowedUsers: []string{}, @@ -1375,14 +1375,14 @@ func TestContainsValidBypassApproval(t *testing.T) { name: "multiple reviews with one bypass", reviews: []*github.PullRequestReview{ { - ID: github.Int64(128), - Body: github.String("LGTM"), - User: &github.User{Login: github.String("regular-user")}, + ID: github.Ptr[int64](128), + Body: github.Ptr("LGTM"), + User: &github.User{Login: github.Ptr("regular-user")}, }, { - ID: github.Int64(129), - Body: github.String("codeowners bypass"), - User: &github.User{Login: github.String("admin-user")}, + ID: github.Ptr[int64](129), + Body: github.Ptr("codeowners bypass"), + User: &github.User{Login: github.Ptr("admin-user")}, }, }, allowedUsers: []string{}, @@ -1405,7 +1405,7 @@ func TestContainsValidBypassApproval(t *testing.T) { mux, server, gh := mockServerAndClient(t) defer server.Close() - gh.pr = &github.PullRequest{Number: github.Int(123)} + gh.pr = &github.PullRequest{Number: github.Ptr(123)} gh.reviews = tc.reviews // Mock the admin permission check