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
1 change: 0 additions & 1 deletion .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,6 @@ linters:
- PagesUpdate
- PagesUpdateWithoutCNAME
- PendingDeploymentsRequest
- PreReceiveHook
- ProtectionRequest
- PublishCodespaceOptions
- PullRequestBranchUpdateOptions
Expand Down
8 changes: 8 additions & 0 deletions github/github-accessors.go

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

11 changes: 11 additions & 0 deletions github/github-accessors_test.go

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

8 changes: 7 additions & 1 deletion github/repos_prereceive_hooks.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,12 @@ func (p PreReceiveHook) String() string {
return Stringify(p)
}

// UpdatePreReceiveHookRequest represents a request to update the enforcement
// of a pre-receive hook for a repository.
type UpdatePreReceiveHookRequest struct {
Enforcement *string `json:"enforcement,omitempty"`
}

// ListPreReceiveHooks lists all pre-receive hooks for the specified repository.
//
// GitHub API docs: https://docs.github.com/enterprise-server@3.21/rest/enterprise-admin/repo-pre-receive-hooks#list-pre-receive-hooks-for-a-repository
Expand Down Expand Up @@ -78,7 +84,7 @@ func (s *RepositoriesService) GetPreReceiveHook(ctx context.Context, owner, repo
// GitHub API docs: https://docs.github.com/enterprise-server@3.21/rest/enterprise-admin/repo-pre-receive-hooks#update-pre-receive-hook-enforcement-for-a-repository
//
//meta:operation PATCH /repos/{owner}/{repo}/pre-receive-hooks/{pre_receive_hook_id}
func (s *RepositoriesService) UpdatePreReceiveHook(ctx context.Context, owner, repo string, id int64, body *PreReceiveHook) (*PreReceiveHook, *Response, error) {
func (s *RepositoriesService) UpdatePreReceiveHook(ctx context.Context, owner, repo string, id int64, body UpdatePreReceiveHookRequest) (*PreReceiveHook, *Response, error) {
u := fmt.Sprintf("repos/%v/%v/pre-receive-hooks/%v", owner, repo, id)
req, err := s.client.NewRequest(ctx, "PATCH", u, body)
if err != nil {
Expand Down
4 changes: 2 additions & 2 deletions github/repos_prereceive_hooks_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ func TestRepositoriesService_UpdatePreReceiveHook(t *testing.T) {
t.Parallel()
client, mux, _ := setup(t)

input := &PreReceiveHook{}
input := UpdatePreReceiveHookRequest{Enforcement: Ptr("enabled")}

mux.HandleFunc("/repos/o/r/pre-receive-hooks/1", func(w http.ResponseWriter, r *http.Request) {
testMethod(t, r, "PATCH")
Expand Down Expand Up @@ -149,7 +149,7 @@ func TestRepositoriesService_PreReceiveHook_invalidOwner(t *testing.T) {
client, _, _ := setup(t)

ctx := t.Context()
_, _, err := client.Repositories.UpdatePreReceiveHook(ctx, "%", "%", 1, nil)
_, _, err := client.Repositories.UpdatePreReceiveHook(ctx, "%", "%", 1, UpdatePreReceiveHookRequest{})
testURLParseError(t, err)
}

Expand Down
Loading