Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 0 additions & 8 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -230,9 +230,7 @@ linters:
- PullRequestReviewRequest
- PullRequestReviewsEnforcementUpdate
- Repository
- RepositoryAddCollaboratorOptions
- RepositoryContentFileOptions
- RepositoryCreateForkOptions
- RequiredStatusChecksRequest
- SCIMUserAttributes
- SourceImportAuthor
Expand All @@ -255,9 +253,7 @@ linters:
- LockIssueOptions
- MaintenanceOptions
- PullRequestBranchUpdateOptions
- RepositoryAddCollaboratorOptions
- RepositoryContentFileOptions
- RepositoryCreateForkOptions
- UpdateCheckRunOptions
- UpdateDefaultSetupConfigurationOptions
- UpdateProjectItemOptions
Expand Down Expand Up @@ -429,10 +425,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
Expand Down
64 changes: 32 additions & 32 deletions github/github-accessors.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

76 changes: 44 additions & 32 deletions github/github-accessors_test.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 4 additions & 5 deletions github/repos_collaborators.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -136,7 +135,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
Expand All @@ -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 {
Expand Down
12 changes: 6 additions & 6 deletions github/repos_collaborators_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -263,15 +263,15 @@ func TestRepositoriesService_AddCollaborator(t *testing.T) {
t.Parallel()
client, mux, _ := setup(t)

opt := &RepositoryAddCollaboratorOptions{Permission: "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)
}
Expand Down Expand Up @@ -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)
}
Expand All @@ -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)
}

Expand Down
13 changes: 6 additions & 7 deletions github/repos_forks.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,13 +50,12 @@ 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"`
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.
Expand All @@ -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)
Expand Down
Loading
Loading