From 459400c5ba431a360804485dfa00d9eb19d98ca7 Mon Sep 17 00:00:00 2001 From: JamBalaya56562 Date: Wed, 7 Oct 2026 21:00:53 +0900 Subject: [PATCH 1/2] fix!: Make the `RepositoryCreateForkOptions` and `RepositoryAddCollaboratorOptions` fields pointers Updates #3644 --- .golangci.yml | 4 ---- github/github-accessors.go | 24 ++++++++++++------------ github/github-accessors_test.go | 20 ++++++++++++++++---- github/repos_collaborators.go | 2 +- github/repos_collaborators_test.go | 2 +- github/repos_forks.go | 6 +++--- github/repos_forks_test.go | 6 +++--- 7 files changed, 36 insertions(+), 28 deletions(-) diff --git a/.golangci.yml b/.golangci.yml index 8f8bc84de9d..6b0a2916561 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -429,10 +429,6 @@ linters: - PremiumRequestUsageReportOptions.Year - PullRequestListCommentsOptions.Since # TODO: PullRequests - Rate.Resource # TODO: Common - - RepositoryAddCollaboratorOptions.Permission # TODO: Repositories - - RepositoryCreateForkOptions.DefaultBranchOnly # TODO: Repositories - - RepositoryCreateForkOptions.Name # TODO: Repositories - - RepositoryCreateForkOptions.Organization # TODO: Repositories - RepositoryListRulesetsOptions.IncludesParents - RequiredStatusChecks.Checks # TODO: Repositories - RequiredStatusChecks.Contexts # TODO: Repositories diff --git a/github/github-accessors.go b/github/github-accessors.go index 5b1a9010a06..c8f126c525f 100644 --- a/github/github-accessors.go +++ b/github/github-accessors.go @@ -37534,12 +37534,12 @@ func (r *RepositoryActor) GetUserViewType() string { return *r.UserViewType } -// GetPermission returns the Permission field. +// GetPermission returns the Permission field if it's non-nil, zero value otherwise. func (r *RepositoryAddCollaboratorOptions) GetPermission() string { - if r == nil { + if r == nil || r.Permission == nil { return "" } - return r.Permission + return *r.Permission } // GetRepository returns the Repository field. @@ -37934,28 +37934,28 @@ func (r *RepositoryContentResponse) GetContent() *RepositoryContent { return r.Content } -// GetDefaultBranchOnly returns the DefaultBranchOnly field. +// GetDefaultBranchOnly returns the DefaultBranchOnly field if it's non-nil, zero value otherwise. func (r *RepositoryCreateForkOptions) GetDefaultBranchOnly() bool { - if r == nil { + if r == nil || r.DefaultBranchOnly == nil { return false } - return r.DefaultBranchOnly + return *r.DefaultBranchOnly } -// GetName returns the Name field. +// GetName returns the Name field if it's non-nil, zero value otherwise. func (r *RepositoryCreateForkOptions) GetName() string { - if r == nil { + if r == nil || r.Name == nil { return "" } - return r.Name + return *r.Name } -// GetOrganization returns the Organization field. +// GetOrganization returns the Organization field if it's non-nil, zero value otherwise. func (r *RepositoryCreateForkOptions) GetOrganization() string { - if r == nil { + if r == nil || r.Organization == nil { return "" } - return r.Organization + return *r.Organization } // GetAction returns the Action field if it's non-nil, zero value otherwise. diff --git a/github/github-accessors_test.go b/github/github-accessors_test.go index a5af30b0797..b0cebb46674 100644 --- a/github/github-accessors_test.go +++ b/github/github-accessors_test.go @@ -46915,7 +46915,10 @@ func TestRepositoryActor_GetUserViewType(tt *testing.T) { func TestRepositoryAddCollaboratorOptions_GetPermission(tt *testing.T) { tt.Parallel() - r := &RepositoryAddCollaboratorOptions{} + var zeroValue string + r := &RepositoryAddCollaboratorOptions{Permission: &zeroValue} + r.GetPermission() + r = &RepositoryAddCollaboratorOptions{} r.GetPermission() r = nil r.GetPermission() @@ -47426,7 +47429,10 @@ func TestRepositoryContentResponse_GetContent(tt *testing.T) { func TestRepositoryCreateForkOptions_GetDefaultBranchOnly(tt *testing.T) { tt.Parallel() - r := &RepositoryCreateForkOptions{} + var zeroValue bool + r := &RepositoryCreateForkOptions{DefaultBranchOnly: &zeroValue} + r.GetDefaultBranchOnly() + r = &RepositoryCreateForkOptions{} r.GetDefaultBranchOnly() r = nil r.GetDefaultBranchOnly() @@ -47434,7 +47440,10 @@ func TestRepositoryCreateForkOptions_GetDefaultBranchOnly(tt *testing.T) { func TestRepositoryCreateForkOptions_GetName(tt *testing.T) { tt.Parallel() - r := &RepositoryCreateForkOptions{} + var zeroValue string + r := &RepositoryCreateForkOptions{Name: &zeroValue} + r.GetName() + r = &RepositoryCreateForkOptions{} r.GetName() r = nil r.GetName() @@ -47442,7 +47451,10 @@ func TestRepositoryCreateForkOptions_GetName(tt *testing.T) { func TestRepositoryCreateForkOptions_GetOrganization(tt *testing.T) { tt.Parallel() - r := &RepositoryCreateForkOptions{} + var zeroValue string + r := &RepositoryCreateForkOptions{Organization: &zeroValue} + r.GetOrganization() + r = &RepositoryCreateForkOptions{} r.GetOrganization() r = nil r.GetOrganization() diff --git a/github/repos_collaborators.go b/github/repos_collaborators.go index 451381bf47c..1917535c2ef 100644 --- a/github/repos_collaborators.go +++ b/github/repos_collaborators.go @@ -136,7 +136,7 @@ type RepositoryAddCollaboratorOptions struct { // triage - team members can proactively manage issues and pull requests without write access. // // Default value is "push". This option is only valid for organization-owned repositories. - Permission string `json:"permission,omitempty"` + Permission *string `json:"permission,omitempty"` } // AddCollaborator sends an invitation to the specified GitHub user diff --git a/github/repos_collaborators_test.go b/github/repos_collaborators_test.go index d69929da266..536e672212a 100644 --- a/github/repos_collaborators_test.go +++ b/github/repos_collaborators_test.go @@ -263,7 +263,7 @@ func TestRepositoriesService_AddCollaborator(t *testing.T) { t.Parallel() client, mux, _ := setup(t) - opt := &RepositoryAddCollaboratorOptions{Permission: "admin"} + opt := &RepositoryAddCollaboratorOptions{Permission: new("admin")} mux.HandleFunc("/repos/o/r/collaborators/u", func(w http.ResponseWriter, r *http.Request) { testMethod(t, r, "PUT") testJSONBody(t, r, opt) diff --git a/github/repos_forks.go b/github/repos_forks.go index 7d80f0858a6..31af0e5bf7e 100644 --- a/github/repos_forks.go +++ b/github/repos_forks.go @@ -54,9 +54,9 @@ func (s *RepositoriesService) ListForks(ctx context.Context, owner, repo string, // RepositoriesService.CreateFork method. type RepositoryCreateForkOptions struct { // The organization to fork the repository into. - Organization string `json:"organization,omitempty"` - Name string `json:"name,omitempty"` - DefaultBranchOnly bool `json:"default_branch_only,omitempty"` + Organization *string `json:"organization,omitempty"` + Name *string `json:"name,omitempty"` + DefaultBranchOnly *bool `json:"default_branch_only,omitempty"` } // CreateFork creates a fork of the specified repository. diff --git a/github/repos_forks_test.go b/github/repos_forks_test.go index bfcb9cdaada..cf2b50e1ad9 100644 --- a/github/repos_forks_test.go +++ b/github/repos_forks_test.go @@ -71,7 +71,7 @@ func TestRepositoriesService_CreateFork(t *testing.T) { t.Parallel() client, mux, _ := setup(t) - opt := &RepositoryCreateForkOptions{Organization: "o", Name: "n", DefaultBranchOnly: true} + opt := &RepositoryCreateForkOptions{Organization: new("o"), Name: new("n"), DefaultBranchOnly: new(true)} mux.HandleFunc("/repos/o/r/forks", func(w http.ResponseWriter, r *http.Request) { testMethod(t, r, "POST") @@ -109,7 +109,7 @@ func TestRepositoriesService_CreateFork_deferred(t *testing.T) { t.Parallel() client, mux, _ := setup(t) - opt := &RepositoryCreateForkOptions{Organization: "o", Name: "n", DefaultBranchOnly: true} + opt := &RepositoryCreateForkOptions{Organization: new("o"), Name: new("n"), DefaultBranchOnly: new(true)} mux.HandleFunc("/repos/o/r/forks", func(w http.ResponseWriter, r *http.Request) { testMethod(t, r, "POST") @@ -135,7 +135,7 @@ func TestRepositoriesService_CreateFork_deferred_badBody(t *testing.T) { t.Parallel() client, mux, _ := setup(t) - opt := &RepositoryCreateForkOptions{Organization: "o", Name: "n", DefaultBranchOnly: true} + opt := &RepositoryCreateForkOptions{Organization: new("o"), Name: new("n"), DefaultBranchOnly: new(true)} mux.HandleFunc("/repos/o/r/forks", func(w http.ResponseWriter, r *http.Request) { testMethod(t, r, "POST") From 36f265083efcccd4e2e3e3b038e5264dcbf6929b Mon Sep 17 00:00:00 2001 From: JamBalaya56562 Date: Wed, 7 Oct 2026 21:22:10 +0900 Subject: [PATCH 2/2] refactor!: Rename `RepositoryCreateForkOptions` and `RepositoryAddCollaboratorOptions` to `...Request` and pass them by value Updates #3644 --- .golangci.yml | 4 -- github/github-accessors.go | 64 +++++++++++----------- github/github-accessors_test.go | 88 +++++++++++++++--------------- github/repos_collaborators.go | 7 +-- github/repos_collaborators_test.go | 12 ++-- github/repos_forks.go | 7 +-- github/repos_forks_test.go | 24 ++++---- 7 files changed, 100 insertions(+), 106 deletions(-) diff --git a/.golangci.yml b/.golangci.yml index 6b0a2916561..870540610b6 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -230,9 +230,7 @@ linters: - PullRequestReviewRequest - PullRequestReviewsEnforcementUpdate - Repository - - RepositoryAddCollaboratorOptions - RepositoryContentFileOptions - - RepositoryCreateForkOptions - RequiredStatusChecksRequest - SCIMUserAttributes - SourceImportAuthor @@ -255,9 +253,7 @@ linters: - LockIssueOptions - MaintenanceOptions - PullRequestBranchUpdateOptions - - RepositoryAddCollaboratorOptions - RepositoryContentFileOptions - - RepositoryCreateForkOptions - UpdateCheckRunOptions - UpdateDefaultSetupConfigurationOptions - UpdateProjectItemOptions diff --git a/github/github-accessors.go b/github/github-accessors.go index c8f126c525f..9d9c9154b28 100644 --- a/github/github-accessors.go +++ b/github/github-accessors.go @@ -918,6 +918,14 @@ func (a *ActorLocation) GetCountryCode() string { return *a.CountryCode } +// GetPermission returns the Permission field if it's non-nil, zero value otherwise. +func (a *AddCollaboratorRequest) GetPermission() string { + if a == nil || a.Permission == nil { + return "" + } + return *a.Permission +} + // GetID returns the ID field if it's non-nil, zero value otherwise. func (a *AddProjectItemOptions) GetID() int64 { if a == nil || a.ID == nil { @@ -12822,6 +12830,30 @@ func (c *CreateEvent) GetSender() *User { return c.Sender } +// GetDefaultBranchOnly returns the DefaultBranchOnly field if it's non-nil, zero value otherwise. +func (c *CreateForkRequest) GetDefaultBranchOnly() bool { + if c == nil || c.DefaultBranchOnly == nil { + return false + } + return *c.DefaultBranchOnly +} + +// GetName returns the Name field if it's non-nil, zero value otherwise. +func (c *CreateForkRequest) GetName() string { + if c == nil || c.Name == nil { + return "" + } + return *c.Name +} + +// GetOrganization returns the Organization field if it's non-nil, zero value otherwise. +func (c *CreateForkRequest) GetOrganization() string { + if c == nil || c.Organization == nil { + return "" + } + return *c.Organization +} + // GetBody returns the Body field. func (c *CreateGistCommentRequest) GetBody() string { if c == nil { @@ -37534,14 +37566,6 @@ func (r *RepositoryActor) GetUserViewType() string { return *r.UserViewType } -// GetPermission returns the Permission field if it's non-nil, zero value otherwise. -func (r *RepositoryAddCollaboratorOptions) GetPermission() string { - if r == nil || r.Permission == nil { - return "" - } - return *r.Permission -} - // GetRepository returns the Repository field. func (r *RepositoryAttachment) GetRepository() *Repository { if r == nil { @@ -37934,30 +37958,6 @@ func (r *RepositoryContentResponse) GetContent() *RepositoryContent { return r.Content } -// GetDefaultBranchOnly returns the DefaultBranchOnly field if it's non-nil, zero value otherwise. -func (r *RepositoryCreateForkOptions) GetDefaultBranchOnly() bool { - if r == nil || r.DefaultBranchOnly == nil { - return false - } - return *r.DefaultBranchOnly -} - -// GetName returns the Name field if it's non-nil, zero value otherwise. -func (r *RepositoryCreateForkOptions) GetName() string { - if r == nil || r.Name == nil { - return "" - } - return *r.Name -} - -// GetOrganization returns the Organization field if it's non-nil, zero value otherwise. -func (r *RepositoryCreateForkOptions) GetOrganization() string { - if r == nil || r.Organization == nil { - return "" - } - return *r.Organization -} - // GetAction returns the Action field if it's non-nil, zero value otherwise. func (r *RepositoryDispatchEvent) GetAction() string { if r == nil || r.Action == nil { diff --git a/github/github-accessors_test.go b/github/github-accessors_test.go index b0cebb46674..94eba5ce44f 100644 --- a/github/github-accessors_test.go +++ b/github/github-accessors_test.go @@ -1120,6 +1120,17 @@ func TestActorLocation_GetCountryCode(tt *testing.T) { a.GetCountryCode() } +func TestAddCollaboratorRequest_GetPermission(tt *testing.T) { + tt.Parallel() + var zeroValue string + a := &AddCollaboratorRequest{Permission: &zeroValue} + a.GetPermission() + a = &AddCollaboratorRequest{} + a.GetPermission() + a = nil + a.GetPermission() +} + func TestAddProjectItemOptions_GetID(tt *testing.T) { tt.Parallel() var zeroValue int64 @@ -16117,6 +16128,39 @@ func TestCreateEvent_GetSender(tt *testing.T) { c.GetSender() } +func TestCreateForkRequest_GetDefaultBranchOnly(tt *testing.T) { + tt.Parallel() + var zeroValue bool + c := &CreateForkRequest{DefaultBranchOnly: &zeroValue} + c.GetDefaultBranchOnly() + c = &CreateForkRequest{} + c.GetDefaultBranchOnly() + c = nil + c.GetDefaultBranchOnly() +} + +func TestCreateForkRequest_GetName(tt *testing.T) { + tt.Parallel() + var zeroValue string + c := &CreateForkRequest{Name: &zeroValue} + c.GetName() + c = &CreateForkRequest{} + c.GetName() + c = nil + c.GetName() +} + +func TestCreateForkRequest_GetOrganization(tt *testing.T) { + tt.Parallel() + var zeroValue string + c := &CreateForkRequest{Organization: &zeroValue} + c.GetOrganization() + c = &CreateForkRequest{} + c.GetOrganization() + c = nil + c.GetOrganization() +} + func TestCreateGistCommentRequest_GetBody(tt *testing.T) { tt.Parallel() c := &CreateGistCommentRequest{} @@ -46913,17 +46957,6 @@ func TestRepositoryActor_GetUserViewType(tt *testing.T) { r.GetUserViewType() } -func TestRepositoryAddCollaboratorOptions_GetPermission(tt *testing.T) { - tt.Parallel() - var zeroValue string - r := &RepositoryAddCollaboratorOptions{Permission: &zeroValue} - r.GetPermission() - r = &RepositoryAddCollaboratorOptions{} - r.GetPermission() - r = nil - r.GetPermission() -} - func TestRepositoryAttachment_GetRepository(tt *testing.T) { tt.Parallel() r := &RepositoryAttachment{} @@ -47427,39 +47460,6 @@ func TestRepositoryContentResponse_GetContent(tt *testing.T) { r.GetContent() } -func TestRepositoryCreateForkOptions_GetDefaultBranchOnly(tt *testing.T) { - tt.Parallel() - var zeroValue bool - r := &RepositoryCreateForkOptions{DefaultBranchOnly: &zeroValue} - r.GetDefaultBranchOnly() - r = &RepositoryCreateForkOptions{} - r.GetDefaultBranchOnly() - r = nil - r.GetDefaultBranchOnly() -} - -func TestRepositoryCreateForkOptions_GetName(tt *testing.T) { - tt.Parallel() - var zeroValue string - r := &RepositoryCreateForkOptions{Name: &zeroValue} - r.GetName() - r = &RepositoryCreateForkOptions{} - r.GetName() - r = nil - r.GetName() -} - -func TestRepositoryCreateForkOptions_GetOrganization(tt *testing.T) { - tt.Parallel() - var zeroValue string - r := &RepositoryCreateForkOptions{Organization: &zeroValue} - r.GetOrganization() - r = &RepositoryCreateForkOptions{} - r.GetOrganization() - r = nil - r.GetOrganization() -} - func TestRepositoryDispatchEvent_GetAction(tt *testing.T) { tt.Parallel() var zeroValue string diff --git a/github/repos_collaborators.go b/github/repos_collaborators.go index 1917535c2ef..d600d22e54f 100644 --- a/github/repos_collaborators.go +++ b/github/repos_collaborators.go @@ -124,9 +124,8 @@ func (s *RepositoriesService) GetPermissionLevel(ctx context.Context, owner, rep return rpl, resp, nil } -// RepositoryAddCollaboratorOptions specifies the optional parameters to the -// RepositoriesService.AddCollaborator method. -type RepositoryAddCollaboratorOptions struct { +// AddCollaboratorRequest represents a request to add a collaborator to a repository. +type AddCollaboratorRequest struct { // Permission specifies the permission to grant the user on this repository. // Possible values are: // pull - team members can pull, but not push to or administer this repository @@ -145,7 +144,7 @@ type RepositoryAddCollaboratorOptions struct { // GitHub API docs: https://docs.github.com/rest/collaborators/collaborators?apiVersion=2022-11-28#add-a-repository-collaborator // //meta:operation PUT /repos/{owner}/{repo}/collaborators/{username} -func (s *RepositoriesService) AddCollaborator(ctx context.Context, owner, repo, user string, body *RepositoryAddCollaboratorOptions) (*CollaboratorInvitation, *Response, error) { +func (s *RepositoriesService) AddCollaborator(ctx context.Context, owner, repo, user string, body AddCollaboratorRequest) (*CollaboratorInvitation, *Response, error) { u := fmt.Sprintf("repos/%v/%v/collaborators/%v", owner, repo, user) req, err := s.client.NewRequest(ctx, "PUT", u, body) if err != nil { diff --git a/github/repos_collaborators_test.go b/github/repos_collaborators_test.go index 536e672212a..35909c1818f 100644 --- a/github/repos_collaborators_test.go +++ b/github/repos_collaborators_test.go @@ -263,15 +263,15 @@ func TestRepositoriesService_AddCollaborator(t *testing.T) { t.Parallel() client, mux, _ := setup(t) - opt := &RepositoryAddCollaboratorOptions{Permission: new("admin")} + body := AddCollaboratorRequest{Permission: new("admin")} mux.HandleFunc("/repos/o/r/collaborators/u", func(w http.ResponseWriter, r *http.Request) { testMethod(t, r, "PUT") - testJSONBody(t, r, opt) + testJSONBody(t, r, body) w.WriteHeader(http.StatusOK) assertWrite(t, w, []byte(`{"permissions": "write","url": "https://api.github.com/user/repository_invitations/1296269","html_url": "https://github.com/octocat/Hello-World/invitations","id":1,"permissions":"write","repository":{"url":"s","name":"r","id":1},"invitee":{"login":"u"},"inviter":{"login":"o"}}`)) }) ctx := t.Context() - collaboratorInvitation, _, err := client.Repositories.AddCollaborator(ctx, "o", "r", "u", opt) + collaboratorInvitation, _, err := client.Repositories.AddCollaborator(ctx, "o", "r", "u", body) if err != nil { t.Errorf("Repositories.AddCollaborator returned error: %v", err) } @@ -299,12 +299,12 @@ func TestRepositoriesService_AddCollaborator(t *testing.T) { const methodName = "AddCollaborator" testBadOptions(t, methodName, func() (err error) { - _, _, err = client.Repositories.AddCollaborator(ctx, "\n", "\n", "\n", opt) + _, _, err = client.Repositories.AddCollaborator(ctx, "\n", "\n", "\n", body) return err }) testNewRequestAndDoFailure(t, methodName, client, func() (*Response, error) { - got, resp, err := client.Repositories.AddCollaborator(ctx, "o", "r", "u", opt) + got, resp, err := client.Repositories.AddCollaborator(ctx, "o", "r", "u", body) if got != nil { t.Errorf("testNewRequestAndDoFailure %v = %#v, want nil", methodName, got) } @@ -317,7 +317,7 @@ func TestRepositoriesService_AddCollaborator_invalidUser(t *testing.T) { client, _, _ := setup(t) ctx := t.Context() - _, _, err := client.Repositories.AddCollaborator(ctx, "%", "%", "%", nil) + _, _, err := client.Repositories.AddCollaborator(ctx, "%", "%", "%", AddCollaboratorRequest{}) testURLParseError(t, err) } diff --git a/github/repos_forks.go b/github/repos_forks.go index 31af0e5bf7e..3698a14b9f2 100644 --- a/github/repos_forks.go +++ b/github/repos_forks.go @@ -50,9 +50,8 @@ func (s *RepositoriesService) ListForks(ctx context.Context, owner, repo string, return repos, resp, nil } -// RepositoryCreateForkOptions specifies the optional parameters to the -// RepositoriesService.CreateFork method. -type RepositoryCreateForkOptions struct { +// CreateForkRequest represents a request to create a fork of a repository. +type CreateForkRequest struct { // The organization to fork the repository into. Organization *string `json:"organization,omitempty"` Name *string `json:"name,omitempty"` @@ -71,7 +70,7 @@ type RepositoryCreateForkOptions struct { // GitHub API docs: https://docs.github.com/rest/repos/forks?apiVersion=2022-11-28#create-a-fork // //meta:operation POST /repos/{owner}/{repo}/forks -func (s *RepositoriesService) CreateFork(ctx context.Context, owner, repo string, body *RepositoryCreateForkOptions) (*Repository, *Response, error) { +func (s *RepositoriesService) CreateFork(ctx context.Context, owner, repo string, body CreateForkRequest) (*Repository, *Response, error) { u := fmt.Sprintf("repos/%v/%v/forks", owner, repo) req, err := s.client.NewRequest(ctx, "POST", u, body) diff --git a/github/repos_forks_test.go b/github/repos_forks_test.go index cf2b50e1ad9..cb1838fb0a2 100644 --- a/github/repos_forks_test.go +++ b/github/repos_forks_test.go @@ -71,16 +71,16 @@ func TestRepositoriesService_CreateFork(t *testing.T) { t.Parallel() client, mux, _ := setup(t) - opt := &RepositoryCreateForkOptions{Organization: new("o"), Name: new("n"), DefaultBranchOnly: new(true)} + body := CreateForkRequest{Organization: new("o"), Name: new("n"), DefaultBranchOnly: new(true)} mux.HandleFunc("/repos/o/r/forks", func(w http.ResponseWriter, r *http.Request) { testMethod(t, r, "POST") - testJSONBody(t, r, opt) + testJSONBody(t, r, body) fmt.Fprint(w, `{"id":1}`) }) ctx := t.Context() - repo, _, err := client.Repositories.CreateFork(ctx, "o", "r", opt) + repo, _, err := client.Repositories.CreateFork(ctx, "o", "r", body) if err != nil { t.Errorf("Repositories.CreateFork returned error: %v", err) } @@ -92,12 +92,12 @@ func TestRepositoriesService_CreateFork(t *testing.T) { const methodName = "CreateFork" testBadOptions(t, methodName, func() (err error) { - _, _, err = client.Repositories.CreateFork(ctx, "\n", "\n", opt) + _, _, err = client.Repositories.CreateFork(ctx, "\n", "\n", body) return err }) testNewRequestAndDoFailure(t, methodName, client, func() (*Response, error) { - got, resp, err := client.Repositories.CreateFork(ctx, "o", "r", opt) + got, resp, err := client.Repositories.CreateFork(ctx, "o", "r", body) if got != nil { t.Errorf("testNewRequestAndDoFailure %v = %#v, want nil", methodName, got) } @@ -109,18 +109,18 @@ func TestRepositoriesService_CreateFork_deferred(t *testing.T) { t.Parallel() client, mux, _ := setup(t) - opt := &RepositoryCreateForkOptions{Organization: new("o"), Name: new("n"), DefaultBranchOnly: new(true)} + body := CreateForkRequest{Organization: new("o"), Name: new("n"), DefaultBranchOnly: new(true)} mux.HandleFunc("/repos/o/r/forks", func(w http.ResponseWriter, r *http.Request) { testMethod(t, r, "POST") - testJSONBody(t, r, opt) + testJSONBody(t, r, body) // This response indicates the fork will happen asynchronously. w.WriteHeader(http.StatusAccepted) fmt.Fprint(w, `{"id":1}`) }) ctx := t.Context() - repo, _, err := client.Repositories.CreateFork(ctx, "o", "r", opt) + repo, _, err := client.Repositories.CreateFork(ctx, "o", "r", body) if !errors.As(err, new(*AcceptedError)) { t.Errorf("Repositories.CreateFork returned error: %v (want AcceptedError)", err) } @@ -135,17 +135,17 @@ func TestRepositoriesService_CreateFork_deferred_badBody(t *testing.T) { t.Parallel() client, mux, _ := setup(t) - opt := &RepositoryCreateForkOptions{Organization: new("o"), Name: new("n"), DefaultBranchOnly: new(true)} + body := CreateForkRequest{Organization: new("o"), Name: new("n"), DefaultBranchOnly: new(true)} mux.HandleFunc("/repos/o/r/forks", func(w http.ResponseWriter, r *http.Request) { testMethod(t, r, "POST") - testJSONBody(t, r, opt) + testJSONBody(t, r, body) w.WriteHeader(http.StatusAccepted) fmt.Fprint(w, `{invalid json`) }) ctx := t.Context() - repo, _, err := client.Repositories.CreateFork(ctx, "o", "r", opt) + repo, _, err := client.Repositories.CreateFork(ctx, "o", "r", body) if err == nil { t.Fatal("Repositories.CreateFork returned nil error") } @@ -159,6 +159,6 @@ func TestRepositoriesService_CreateFork_invalidOwner(t *testing.T) { client, _, _ := setup(t) ctx := t.Context() - _, _, err := client.Repositories.CreateFork(ctx, "%", "r", nil) + _, _, err := client.Repositories.CreateFork(ctx, "%", "r", CreateForkRequest{}) testURLParseError(t, err) }