diff --git a/go.mod b/go.mod index 5ff4ce24c..3364128c3 100644 --- a/go.mod +++ b/go.mod @@ -30,7 +30,7 @@ require ( github.com/go-sql-driver/mysql v1.8.1 github.com/go-viper/mapstructure/v2 v2.2.1 github.com/golang-jwt/jwt/v5 v5.2.1 - github.com/google/go-github/v67 v67.0.0 + github.com/google/go-github/v68 v68.0.0 github.com/google/tink/go v1.7.0 github.com/gorilla/securecookie v1.1.2 github.com/hashicorp/go-hclog v1.6.3 diff --git a/go.sum b/go.sum index 37f7948c1..15ff0fbd0 100644 --- a/go.sum +++ b/go.sum @@ -235,8 +235,8 @@ github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/ github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= 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/v67 v67.0.0 h1:g11NDAmfaBaCO8qYdI9fsmbaRipHNWRIU/2YGvlh4rg= -github.com/google/go-github/v67 v67.0.0/go.mod h1:zH3K7BxjFndr9QSeFibx4lTKkYS3K9nDanoI1NjaOtY= +github.com/google/go-github/v68 v68.0.0 h1:ZW57zeNZiXTdQ16qrDiZ0k6XucrxZ2CGmoTvcCyQG6s= +github.com/google/go-github/v68 v68.0.0/go.mod h1:K9HAUBovM2sLwM408A18h+wd9vqdLOEqTUCbnRIcx68= 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/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= diff --git a/server/forge/github/convert.go b/server/forge/github/convert.go index 536c715aa..d76002ab3 100644 --- a/server/forge/github/convert.go +++ b/server/forge/github/convert.go @@ -18,7 +18,7 @@ package github import ( "fmt" - "github.com/google/go-github/v67/github" + "github.com/google/go-github/v68/github" "go.woodpecker-ci.org/woodpecker/v3/server/model" ) diff --git a/server/forge/github/convert_test.go b/server/forge/github/convert_test.go index 0a740194a..2b4998bb5 100644 --- a/server/forge/github/convert_test.go +++ b/server/forge/github/convert_test.go @@ -19,7 +19,7 @@ import ( "testing" "github.com/franela/goblin" - "github.com/google/go-github/v67/github" + "github.com/google/go-github/v68/github" "go.woodpecker-ci.org/woodpecker/v3/server/model" ) @@ -66,15 +66,15 @@ func Test_helper(t *testing.T) { g.It("should convert repository list", func() { from := []*github.Repository{ { - Private: github.Bool(false), - FullName: github.String("octocat/hello-world"), - Name: github.String("hello-world"), + Private: github.Ptr(false), + FullName: github.Ptr("octocat/hello-world"), + Name: github.Ptr("hello-world"), Owner: &github.User{ - AvatarURL: github.String("http://..."), - Login: github.String("octocat"), + AvatarURL: github.Ptr("http://..."), + Login: github.Ptr("octocat"), }, - HTMLURL: github.String("https://github.com/octocat/hello-world"), - CloneURL: github.String("https://github.com/octocat/hello-world.git"), + HTMLURL: github.Ptr("https://github.com/octocat/hello-world"), + CloneURL: github.Ptr("https://github.com/octocat/hello-world.git"), Permissions: map[string]bool{ "push": true, "pull": true, @@ -92,15 +92,15 @@ func Test_helper(t *testing.T) { g.It("should convert repository", func() { from := github.Repository{ - FullName: github.String("octocat/hello-world"), - Name: github.String("hello-world"), - HTMLURL: github.String("https://github.com/octocat/hello-world"), - CloneURL: github.String("https://github.com/octocat/hello-world.git"), - DefaultBranch: github.String("develop"), - Private: github.Bool(true), + FullName: github.Ptr("octocat/hello-world"), + Name: github.Ptr("hello-world"), + HTMLURL: github.Ptr("https://github.com/octocat/hello-world"), + CloneURL: github.Ptr("https://github.com/octocat/hello-world.git"), + DefaultBranch: github.Ptr("develop"), + Private: github.Ptr(true), Owner: &github.User{ - AvatarURL: github.String("http://..."), - Login: github.String("octocat"), + AvatarURL: github.Ptr("http://..."), + Login: github.Ptr("octocat"), }, Permissions: map[string]bool{ "push": true, @@ -137,8 +137,8 @@ func Test_helper(t *testing.T) { g.It("should convert team", func() { from := &github.Organization{ - Login: github.String("octocat"), - AvatarURL: github.String("http://..."), + Login: github.Ptr("octocat"), + AvatarURL: github.Ptr("http://..."), } to := convertTeam(from) g.Assert(to.Login).Equal("octocat") @@ -148,8 +148,8 @@ func Test_helper(t *testing.T) { g.It("should convert team list", func() { from := []*github.Organization{ { - Login: github.String("octocat"), - AvatarURL: github.String("http://..."), + Login: github.Ptr("octocat"), + AvatarURL: github.Ptr("http://..."), }, } to := convertTeamList(from) @@ -159,14 +159,14 @@ func Test_helper(t *testing.T) { g.It("should convert a repository from webhook", func() { from := &github.PushEventRepository{Owner: &github.User{}} - from.Owner.Login = github.String("octocat") - from.Owner.Name = github.String("octocat") - from.Name = github.String("hello-world") - from.FullName = github.String("octocat/hello-world") - from.Private = github.Bool(true) - from.HTMLURL = github.String("https://github.com/octocat/hello-world") - from.CloneURL = github.String("https://github.com/octocat/hello-world.git") - from.DefaultBranch = github.String("develop") + from.Owner.Login = github.Ptr("octocat") + from.Owner.Name = github.Ptr("octocat") + from.Name = github.Ptr("hello-world") + from.FullName = github.Ptr("octocat/hello-world") + from.Private = github.Ptr(true) + from.HTMLURL = github.Ptr("https://github.com/octocat/hello-world") + from.CloneURL = github.Ptr("https://github.com/octocat/hello-world.git") + from.DefaultBranch = github.Ptr("develop") repo := convertRepoHook(from) g.Assert(repo.Owner).Equal(*from.Owner.Login) @@ -180,28 +180,28 @@ func Test_helper(t *testing.T) { g.It("should convert a pull request from webhook", func() { from := &github.PullRequestEvent{ - Action: github.String(actionOpen), + Action: github.Ptr(actionOpen), PullRequest: &github.PullRequest{ - State: github.String(stateOpen), - HTMLURL: github.String("https://github.com/octocat/hello-world/pulls/42"), - Number: github.Int(42), - Title: github.String("Updated README.md"), + State: github.Ptr(stateOpen), + HTMLURL: github.Ptr("https://github.com/octocat/hello-world/pulls/42"), + Number: github.Ptr(42), + Title: github.Ptr("Updated README.md"), Base: &github.PullRequestBranch{ - Ref: github.String("main"), + Ref: github.Ptr("main"), }, Head: &github.PullRequestBranch{ - Ref: github.String("changes"), - SHA: github.String("f72fc19"), + Ref: github.Ptr("changes"), + SHA: github.Ptr("f72fc19"), Repo: &github.Repository{ - CloneURL: github.String("https://github.com/octocat/hello-world-fork"), + CloneURL: github.Ptr("https://github.com/octocat/hello-world-fork"), }, }, User: &github.User{ - Login: github.String("octocat"), - AvatarURL: github.String("https://avatars1.githubusercontent.com/u/583231"), + Login: github.Ptr("octocat"), + AvatarURL: github.Ptr("https://avatars1.githubusercontent.com/u/583231"), }, }, Sender: &github.User{ - Login: github.String("octocat"), + Login: github.Ptr("octocat"), }, } pull, _, pipeline, err := parsePullHook(from, true) @@ -221,15 +221,15 @@ func Test_helper(t *testing.T) { g.It("should convert a deployment from webhook", func() { from := &github.DeploymentEvent{Deployment: &github.Deployment{}, Sender: &github.User{}} - from.Deployment.Description = github.String(":shipit:") - from.Deployment.Environment = github.String("production") - from.Deployment.Task = github.String("deploy") - from.Deployment.ID = github.Int64(42) - from.Deployment.Ref = github.String("main") - from.Deployment.SHA = github.String("f72fc19") - from.Deployment.URL = github.String("https://github.com/octocat/hello-world") - from.Sender.Login = github.String("octocat") - from.Sender.AvatarURL = github.String("https://avatars1.githubusercontent.com/u/583231") + from.Deployment.Description = github.Ptr(":shipit:") + from.Deployment.Environment = github.Ptr("production") + from.Deployment.Task = github.Ptr("deploy") + from.Deployment.ID = github.Ptr(int64(42)) + from.Deployment.Ref = github.Ptr("main") + from.Deployment.SHA = github.Ptr("f72fc19") + from.Deployment.URL = github.Ptr("https://github.com/octocat/hello-world") + from.Sender.Login = github.Ptr("octocat") + from.Sender.AvatarURL = github.Ptr("https://avatars1.githubusercontent.com/u/583231") _, pipeline := parseDeployHook(from) g.Assert(pipeline.Event).Equal(model.EventDeploy) @@ -244,14 +244,14 @@ func Test_helper(t *testing.T) { g.It("should convert a push from webhook", func() { from := &github.PushEvent{Sender: &github.User{}, Repo: &github.PushEventRepository{}, HeadCommit: &github.HeadCommit{Author: &github.CommitAuthor{}}} - from.Sender.Login = github.String("octocat") - from.Sender.AvatarURL = github.String("https://avatars1.githubusercontent.com/u/583231") - from.Repo.CloneURL = github.String("https://github.com/octocat/hello-world.git") - from.HeadCommit.Author.Email = github.String("github.String(octocat@github.com") - from.HeadCommit.Message = github.String("updated README.md") - from.HeadCommit.URL = github.String("https://github.com/octocat/hello-world") - from.HeadCommit.ID = github.String("f72fc19") - from.Ref = github.String("refs/heads/main") + from.Sender.Login = github.Ptr("octocat") + from.Sender.AvatarURL = github.Ptr("https://avatars1.githubusercontent.com/u/583231") + from.Repo.CloneURL = github.Ptr("https://github.com/octocat/hello-world.git") + from.HeadCommit.Author.Email = github.Ptr("github.Ptr(octocat@github.com") + from.HeadCommit.Message = github.Ptr("updated README.md") + from.HeadCommit.URL = github.Ptr("https://github.com/octocat/hello-world") + from.HeadCommit.ID = github.Ptr("f72fc19") + from.Ref = github.Ptr("refs/heads/main") _, pipeline := parsePushHook(from) g.Assert(pipeline.Event).Equal(model.EventPush) @@ -267,7 +267,7 @@ func Test_helper(t *testing.T) { g.It("should convert a tag from webhook", func() { from := &github.PushEvent{} - from.Ref = github.String("refs/tags/v1.0.0") + from.Ref = github.Ptr("refs/tags/v1.0.0") _, pipeline := parsePushHook(from) g.Assert(pipeline.Event).Equal(model.EventTag) @@ -276,8 +276,8 @@ func Test_helper(t *testing.T) { g.It("should convert tag's base branch from webhook to pipeline's branch ", func() { from := &github.PushEvent{} - from.Ref = github.String("refs/tags/v1.0.0") - from.BaseRef = github.String("refs/heads/main") + from.Ref = github.Ptr("refs/tags/v1.0.0") + from.BaseRef = github.Ptr("refs/heads/main") _, pipeline := parsePushHook(from) g.Assert(pipeline.Event).Equal(model.EventTag) @@ -286,8 +286,8 @@ func Test_helper(t *testing.T) { g.It("should not convert tag's base_ref from webhook if not prefixed with 'ref/heads/'", func() { from := &github.PushEvent{} - from.Ref = github.String("refs/tags/v1.0.0") - from.BaseRef = github.String("refs/refs/main") + from.Ref = github.Ptr("refs/tags/v1.0.0") + from.BaseRef = github.Ptr("refs/refs/main") _, pipeline := parsePushHook(from) g.Assert(pipeline.Event).Equal(model.EventTag) diff --git a/server/forge/github/github.go b/server/forge/github/github.go index 750d0fdf5..31ad44c3a 100644 --- a/server/forge/github/github.go +++ b/server/forge/github/github.go @@ -27,7 +27,7 @@ import ( "strings" "time" - "github.com/google/go-github/v67/github" + "github.com/google/go-github/v68/github" "github.com/rs/zerolog/log" "golang.org/x/oauth2" @@ -529,18 +529,18 @@ func (c *client) Status(ctx context.Context, user *model.User, repo *model.Repo, id, _ := strconv.Atoi(matches[1]) _, _, err := client.Repositories.CreateDeploymentStatus(ctx, repo.Owner, repo.Name, int64(id), &github.DeploymentStatusRequest{ - State: github.String(convertStatus(pipeline.Status)), - Description: github.String(common.GetPipelineStatusDescription(pipeline.Status)), - LogURL: github.String(common.GetPipelineStatusURL(repo, pipeline, nil)), + State: github.Ptr(convertStatus(pipeline.Status)), + Description: github.Ptr(common.GetPipelineStatusDescription(pipeline.Status)), + LogURL: github.Ptr(common.GetPipelineStatusURL(repo, pipeline, nil)), }) return err } _, _, err := client.Repositories.CreateStatus(ctx, repo.Owner, repo.Name, pipeline.Commit, &github.RepoStatus{ - Context: github.String(common.GetPipelineStatusContext(repo, pipeline, workflow)), - State: github.String(convertStatus(workflow.State)), - Description: github.String(common.GetPipelineStatusDescription(workflow.State)), - TargetURL: github.String(common.GetPipelineStatusURL(repo, pipeline, workflow)), + Context: github.Ptr(common.GetPipelineStatusContext(repo, pipeline, workflow)), + State: github.Ptr(convertStatus(workflow.State)), + Description: github.Ptr(common.GetPipelineStatusDescription(workflow.State)), + TargetURL: github.Ptr(common.GetPipelineStatusURL(repo, pipeline, workflow)), }) return err } @@ -553,7 +553,7 @@ func (c *client) Activate(ctx context.Context, u *model.User, r *model.Repo, lin } client := c.newClientToken(ctx, u.AccessToken) hook := &github.Hook{ - Name: github.String("web"), + Name: github.Ptr("web"), Events: []string{ "push", "pull_request", @@ -561,7 +561,7 @@ func (c *client) Activate(ctx context.Context, u *model.User, r *model.Repo, lin }, Config: &github.HookConfig{ URL: &link, - ContentType: github.String("form"), + ContentType: github.Ptr("form"), }, } _, _, err := client.Repositories.CreateHook(ctx, r.Owner, r.Name, hook) diff --git a/server/forge/github/parse.go b/server/forge/github/parse.go index e6c68f528..7df728984 100644 --- a/server/forge/github/parse.go +++ b/server/forge/github/parse.go @@ -22,7 +22,7 @@ import ( "net/http" "strings" - "github.com/google/go-github/v67/github" + "github.com/google/go-github/v68/github" "go.woodpecker-ci.org/woodpecker/v3/server/forge/types" "go.woodpecker-ci.org/woodpecker/v3/server/model"