From 1d3decd69c4f55bba323ccf59c89f66bf1cd893c Mon Sep 17 00:00:00 2001 From: Christopher Gahlon Date: Wed, 27 Nov 2024 21:36:45 +0000 Subject: [PATCH 1/2] add 'name' and 'description' to project hooks structs GitLab 17.x API now supports 'name' and 'description' fields Added fields and updates tests. --- projects.go | 6 ++++++ projects_test.go | 4 ++++ 2 files changed, 10 insertions(+) diff --git a/projects.go b/projects.go index dabcc8397..693fc996e 100644 --- a/projects.go +++ b/projects.go @@ -1270,6 +1270,8 @@ type HookCustomHeader struct { type ProjectHook struct { ID int `json:"id"` URL string `json:"url"` + Name string `json:"name,omitempty"` + Description string `json:"description,omitempty"` ConfidentialNoteEvents bool `json:"confidential_note_events"` ProjectID int `json:"project_id"` PushEvents bool `json:"push_events"` @@ -1352,6 +1354,8 @@ func (s *ProjectsService) GetProjectHook(pid interface{}, hook int, options ...R // GitLab API docs: // https://docs.gitlab.com/ee/api/projects.html#add-project-hook type AddProjectHookOptions struct { + Name *string `url:"name,omitempty" json:"name,omitempty"` + Description *string `url:"description,omitempty" json:"description,omitempty"` ConfidentialIssuesEvents *bool `url:"confidential_issues_events,omitempty" json:"confidential_issues_events,omitempty"` ConfidentialNoteEvents *bool `url:"confidential_note_events,omitempty" json:"confidential_note_events,omitempty"` DeploymentEvents *bool `url:"deployment_events,omitempty" json:"deployment_events,omitempty"` @@ -1403,6 +1407,8 @@ func (s *ProjectsService) AddProjectHook(pid interface{}, opt *AddProjectHookOpt // GitLab API docs: // https://docs.gitlab.com/ee/api/projects.html#edit-project-hook type EditProjectHookOptions struct { + Name *string `url:"name,omitempty" json:"name,omitempty"` + Description *string `url:"description,omitempty" json:"description,omitempty"` ConfidentialIssuesEvents *bool `url:"confidential_issues_events,omitempty" json:"confidential_issues_events,omitempty"` ConfidentialNoteEvents *bool `url:"confidential_note_events,omitempty" json:"confidential_note_events,omitempty"` DeploymentEvents *bool `url:"deployment_events,omitempty" json:"deployment_events,omitempty"` diff --git a/projects_test.go b/projects_test.go index 26494401c..7335b1656 100644 --- a/projects_test.go +++ b/projects_test.go @@ -1505,6 +1505,8 @@ func TestListProjectHooks(t *testing.T) { { "id": 1, "url": "http://example.com/hook", + "name": "This is the name of an example hook", + "description": "This is the description of an example hook", "confidential_note_events": true, "project_id": 1, "push_events": true, @@ -1541,6 +1543,8 @@ func TestListProjectHooks(t *testing.T) { want := []*ProjectHook{{ ID: 1, URL: "http://example.com/hook", + Name: "This is the name of an example hook", + Description: "This is the description of an example hook", ConfidentialNoteEvents: true, ProjectID: 1, PushEvents: true, From f19511bd936fad81277fc8231a2a2d9cefe3eb1d Mon Sep 17 00:00:00 2001 From: Christopher Gahlon Date: Fri, 29 Nov 2024 00:09:01 +0000 Subject: [PATCH 2/2] remove omitempty from main struct used for reads --- projects.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/projects.go b/projects.go index 693fc996e..0400273bc 100644 --- a/projects.go +++ b/projects.go @@ -1270,8 +1270,8 @@ type HookCustomHeader struct { type ProjectHook struct { ID int `json:"id"` URL string `json:"url"` - Name string `json:"name,omitempty"` - Description string `json:"description,omitempty"` + Name string `json:"name"` + Description string `json:"description"` ConfidentialNoteEvents bool `json:"confidential_note_events"` ProjectID int `json:"project_id"` PushEvents bool `json:"push_events"`