diff --git a/applier.go b/applier.go index e9115ff..6d2bddd 100644 --- a/applier.go +++ b/applier.go @@ -13,7 +13,7 @@ import ( "time" "github.com/bluekeyes/go-gitdiff/gitdiff" - "github.com/google/go-github/v74/github" + "github.com/google/go-github/v75/github" ) // DefaultCommitMessage is the commit message used when no message is provided @@ -71,7 +71,7 @@ func (a *Applier) Apply(ctx context.Context, f *gitdiff.File) (*github.TreeEntry } if entry.Content != nil { - blob, _, err := a.client.Git.CreateBlob(ctx, a.owner, a.repo, &github.Blob{ + blob, _, err := a.client.Git.CreateBlob(ctx, a.owner, a.repo, github.Blob{ Content: entry.Content, Encoding: github.String("base64"), }) @@ -262,7 +262,7 @@ func (a *Applier) Commit(ctx context.Context, tmpl *github.Commit, header *gitdi c.Message = github.String("Apply patch with patch2pr") } - commit, _, err := a.client.Git.CreateCommit(ctx, a.owner, a.repo, &c, nil) + commit, _, err := a.client.Git.CreateCommit(ctx, a.owner, a.repo, c, nil) if err != nil { return nil, err } diff --git a/applier_test.go b/applier_test.go index abce3c8..dd0dc04 100644 --- a/applier_test.go +++ b/applier_test.go @@ -15,7 +15,7 @@ import ( "github.com/bluekeyes/go-gitdiff/gitdiff" "github.com/bluekeyes/patch2pr/internal" - "github.com/google/go-github/v74/github" + "github.com/google/go-github/v75/github" "github.com/shurcooL/githubv4" ) @@ -279,7 +279,7 @@ func createBranch(t *testing.T, tctx *TestContext) { if strings.HasSuffix(d.Name(), ".bin") { c := base64.StdEncoding.EncodeToString(content) - blob, _, err := tctx.Client.Git.CreateBlob(tctx, tctx.Repo.Owner, tctx.Repo.Name, &github.Blob{ + blob, _, err := tctx.Client.Git.CreateBlob(tctx, tctx.Repo.Owner, tctx.Repo.Name, github.Blob{ Encoding: github.String("base64"), Content: &c, }) @@ -308,11 +308,12 @@ func createBranch(t *testing.T, tctx *TestContext) { t.Fatalf("error getting recursive tree: %v", err) } - commit := &github.Commit{ + commitToCreate := github.Commit{ Message: github.String("Base commit for test"), Tree: tree, } - commit, _, err = tctx.Client.Git.CreateCommit(tctx, tctx.Repo.Owner, tctx.Repo.Name, commit, nil) + + commit, _, err := tctx.Client.Git.CreateCommit(tctx, tctx.Repo.Owner, tctx.Repo.Name, commitToCreate, nil) if err != nil { t.Fatalf("error creating commit: %v", err) } @@ -320,11 +321,9 @@ func createBranch(t *testing.T, tctx *TestContext) { tctx.BaseCommit = commit tctx.BaseTree = fullTree - if _, _, err := tctx.Client.Git.CreateRef(tctx, tctx.Repo.Owner, tctx.Repo.Name, &github.Reference{ - Ref: github.String(tctx.Branch(BaseBranch)), - Object: &github.GitObject{ - SHA: commit.SHA, - }, + if _, _, err := tctx.Client.Git.CreateRef(tctx, tctx.Repo.Owner, tctx.Repo.Name, github.CreateRef{ + Ref: tctx.Branch(BaseBranch), + SHA: commit.GetSHA(), }); err != nil { t.Fatalf("error creating ref: %v", err) } diff --git a/cmd/patch2pr/main.go b/cmd/patch2pr/main.go index 771eb84..fb9dd31 100644 --- a/cmd/patch2pr/main.go +++ b/cmd/patch2pr/main.go @@ -16,7 +16,7 @@ import ( "time" "github.com/bluekeyes/go-gitdiff/gitdiff" - "github.com/google/go-github/v74/github" + "github.com/google/go-github/v75/github" "github.com/bluekeyes/patch2pr" "github.com/bluekeyes/patch2pr/internal" diff --git a/go.mod b/go.mod index 2d9eb80..10c21c5 100644 --- a/go.mod +++ b/go.mod @@ -1,10 +1,10 @@ module github.com/bluekeyes/patch2pr -go 1.23.0 +go 1.24.0 require ( github.com/bluekeyes/go-gitdiff v0.8.1 - github.com/google/go-github/v74 v74.0.0 + github.com/google/go-github/v75 v75.0.0 github.com/shurcooL/githubv4 v0.0.0-20210922025249-6831e00d857f ) diff --git a/go.sum b/go.sum index 748d39f..9b32386 100644 --- a/go.sum +++ b/go.sum @@ -3,8 +3,8 @@ github.com/bluekeyes/go-gitdiff v0.8.1/go.mod h1:WWAk1Mc6EgWarCrPFO+xeYlujPu98Vu github.com/google/go-cmp v0.5.2/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= 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/v74 v74.0.0 h1:yZcddTUn8DPbj11GxnMrNiAnXH14gNs559AsUpNpPgM= -github.com/google/go-github/v74 v74.0.0/go.mod h1:ubn/YdyftV80VPSI26nSJvaEsTOnsjrxG3o9kJhcyak= +github.com/google/go-github/v75 v75.0.0 h1:k7q8Bvg+W5KxRl9Tjq16a9XEgVY1pwuiG5sIL7435Ic= +github.com/google/go-github/v75 v75.0.0/go.mod h1:H3LUJEA1TCrzuUqtdAQniBNwuKiQIqdGKgBo1/M/uqI= 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/shurcooL/githubv4 v0.0.0-20210922025249-6831e00d857f h1:q4b8/GCL8Ksl+okhFKSd8DVBQNc0XExjxTO68nK0c3Y= diff --git a/graphql_applier.go b/graphql_applier.go index 1069ccb..e7c6f53 100644 --- a/graphql_applier.go +++ b/graphql_applier.go @@ -11,7 +11,7 @@ import ( "path" "github.com/bluekeyes/go-gitdiff/gitdiff" - "github.com/google/go-github/v74/github" + "github.com/google/go-github/v75/github" "github.com/shurcooL/githubv4" ) diff --git a/reference.go b/reference.go index 9da72a3..29bf9af 100644 --- a/reference.go +++ b/reference.go @@ -5,7 +5,7 @@ import ( "fmt" "strings" - "github.com/google/go-github/v74/github" + "github.com/google/go-github/v75/github" ) // Reference is a named reference in a repository. @@ -48,20 +48,16 @@ func (r *Reference) Set(ctx context.Context, sha string, force bool) error { } if exists { - if _, _, err := r.client.Git.UpdateRef(ctx, r.owner, r.repo, &github.Reference{ - Ref: github.String(r.ref), - Object: &github.GitObject{ - SHA: github.String(sha), - }, - }, force); err != nil { + if _, _, err := r.client.Git.UpdateRef(ctx, r.owner, r.repo, r.ref, github.UpdateRef{ + SHA: sha, + Force: github.Ptr(force), + }); err != nil { return fmt.Errorf("update ref failed: %w", err) } } else { - if _, _, err := r.client.Git.CreateRef(ctx, r.owner, r.repo, &github.Reference{ - Ref: github.String(r.ref), - Object: &github.GitObject{ - SHA: github.String(sha), - }, + if _, _, err := r.client.Git.CreateRef(ctx, r.owner, r.repo, github.CreateRef{ + Ref: r.ref, + SHA: sha, }); err != nil { return fmt.Errorf("create ref failed: %w", err) }