diff --git a/applier.go b/applier.go index c8a731c..4730d70 100644 --- a/applier.go +++ b/applier.go @@ -13,7 +13,7 @@ import ( "time" "github.com/bluekeyes/go-gitdiff/gitdiff" - "github.com/google/go-github/v85/github" + "github.com/google/go-github/v88/github" ) // DefaultCommitMessage is the commit message used when no message is provided diff --git a/applier_test.go b/applier_test.go index d5ed379..775abdb 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/v85/github" + "github.com/google/go-github/v88/github" "github.com/shurcooL/githubv4" ) @@ -238,11 +238,16 @@ func prepareTestContext(t *testing.T) *TestContext { ctx := context.Background() httpClient := internal.NewTokenClient(token) + client, err := github.NewClient(github.WithHTTPClient(httpClient)) + if err != nil { + t.Fatalf("Error creating GitHub client: %v", err) + } + tctx := TestContext{ Context: ctx, ID: id, Repo: repo, - Client: github.NewClient(httpClient), + Client: client, V4Client: githubv4.NewClient(httpClient), } return &tctx diff --git a/cmd/patch2pr/main.go b/cmd/patch2pr/main.go index 0b162c9..66b7781 100644 --- a/cmd/patch2pr/main.go +++ b/cmd/patch2pr/main.go @@ -10,13 +10,12 @@ import ( "io" "io/ioutil" "net/http" - "net/url" "os" "strings" "time" "github.com/bluekeyes/go-gitdiff/gitdiff" - "github.com/google/go-github/v85/github" + "github.com/google/go-github/v88/github" "github.com/bluekeyes/patch2pr" "github.com/bluekeyes/patch2pr/internal" @@ -56,14 +55,12 @@ type Options struct { PullTitle string Repository *patch2pr.Repository GitHubToken string - GitHubURL *url.URL + GitHubURL string PullBody string } func main() { - opts := Options{ - GitHubURL: &url.URL{Scheme: "https", Host: "api.github.com", Path: "/"}, - } + var opts Options fs := flag.NewFlagSet(os.Args[0], flag.ContinueOnError) fs.SetOutput(ioutil.Discard) @@ -83,7 +80,7 @@ func main() { fs.StringVar(&opts.PullTitle, "pull-title", "", "pull-title") fs.Var(RepositoryValue{&opts.Repository}, "repository", "repository") fs.StringVar(&opts.GitHubToken, "token", "", "token") - fs.Var(URLValue{&opts.GitHubURL}, "url", "url") + fs.StringVar(&opts.GitHubURL, "url", "https://api.github.com/", "url") var printVersion bool fs.BoolVar(&printVersion, "v", false, "version") @@ -116,8 +113,13 @@ func main() { ctx := context.Background() tc := internal.NewTokenClient(opts.GitHubToken) - client := github.NewClient(tc) - client.BaseURL = opts.GitHubURL + client, err := github.NewClient( + github.WithHTTPClient(tc), + github.WithURLs(&opts.GitHubURL, nil), + ) + if err != nil { + die(1, fmt.Errorf("creating GitHub client failed: %w", err)) + } var patchFiles []string if fs.NArg() == 0 { diff --git a/cmd/patch2pr/values.go b/cmd/patch2pr/values.go index 0a9838c..2b3b3cc 100644 --- a/cmd/patch2pr/values.go +++ b/cmd/patch2pr/values.go @@ -1,9 +1,6 @@ package main import ( - "net/url" - "strings" - "github.com/bluekeyes/patch2pr" ) @@ -27,29 +24,6 @@ func (v RepositoryValue) Set(s string) error { return nil } -type URLValue struct { - u **url.URL -} - -func (v URLValue) String() string { - if v.u == nil || *v.u == nil { - return "" - } - return (*v.u).String() -} - -func (v URLValue) Set(s string) error { - u, err := url.Parse(s) - if err != nil { - return err - } - if !strings.HasSuffix(u.Path, "/") { - u.Path += "/" - } - *v.u = u - return nil -} - type ForkValue struct { RepositoryValue enabled *bool diff --git a/go.mod b/go.mod index bb1a324..cefe459 100644 --- a/go.mod +++ b/go.mod @@ -4,7 +4,7 @@ go 1.25.0 require ( github.com/bluekeyes/go-gitdiff v0.8.1 - github.com/google/go-github/v85 v85.0.0 + github.com/google/go-github/v88 v88.0.0 github.com/shurcooL/githubv4 v0.0.0-20260209031235-2402fdf4a9ed ) diff --git a/go.sum b/go.sum index f8e3c91..b57ac69 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.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/v85 v85.0.0 h1:1+TLFX/akTFXK7o9Z9uAloQGufOn4ySa5DItUM1VWT4= -github.com/google/go-github/v85 v85.0.0/go.mod h1:jYkBnqN+SzR2A2fGKYfbt6DEEQAyxeK0Q2XpPV9ZFsU= +github.com/google/go-github/v88 v88.0.0 h1:dZA9IKkPK1eXZj4ypngnpRj5FwdpTv4whix2PrQMP7M= +github.com/google/go-github/v88 v88.0.0/go.mod h1:rufTDgn2N45wjhukLTyxmvc9nilSp3mr3Rgtt6b1MPw= 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/shurcooL/githubv4 v0.0.0-20260209031235-2402fdf4a9ed h1:KT7hI8vYXgU0s2qaMkrfq9tCA1w/iEPgfredVP+4Tzw= diff --git a/graphql_applier.go b/graphql_applier.go index dd930ca..fc4474c 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/v85/github" + "github.com/google/go-github/v88/github" "github.com/shurcooL/githubv4" ) diff --git a/reference.go b/reference.go index 383a86b..dbc0813 100644 --- a/reference.go +++ b/reference.go @@ -5,7 +5,7 @@ import ( "fmt" "strings" - "github.com/google/go-github/v85/github" + "github.com/google/go-github/v88/github" ) // Reference is a named reference in a repository.