From 287578dcbc7f04a1b3129387cb3965525d6c275c Mon Sep 17 00:00:00 2001 From: Yarden Shoham Date: Sat, 19 Aug 2023 16:23:59 +0000 Subject: [PATCH 1/2] Add `branch_filter` to hooks API endpoints We now include the branch filler in the response. Signed-off-by: Yarden Shoham --- modules/structs/hook.go | 1 + services/webhook/general.go | 1 + templates/swagger/v1_json.tmpl | 4 ++++ 3 files changed, 6 insertions(+) diff --git a/modules/structs/hook.go b/modules/structs/hook.go index cd91d4bc462a..64bf68a20fe1 100644 --- a/modules/structs/hook.go +++ b/modules/structs/hook.go @@ -19,6 +19,7 @@ var ErrInvalidReceiveHook = errors.New("Invalid JSON payload received over webho type Hook struct { ID int64 `json:"id"` Type string `json:"type"` + BranchFilter string `json:"branch_filter" binding:"GlobPattern"` URL string `json:"-"` Config map[string]string `json:"config"` Events []string `json:"events"` diff --git a/services/webhook/general.go b/services/webhook/general.go index f53ea31ffad7..b9cc3dc8457b 100644 --- a/services/webhook/general.go +++ b/services/webhook/general.go @@ -260,5 +260,6 @@ func ToHook(repoLink string, w *webhook_model.Webhook) (*api.Hook, error) { AuthorizationHeader: authorizationHeader, Updated: w.UpdatedUnix.AsTime(), Created: w.CreatedUnix.AsTime(), + BranchFilter: w.BranchFilter, }, nil } diff --git a/templates/swagger/v1_json.tmpl b/templates/swagger/v1_json.tmpl index da43c530af1f..734a73bc0c53 100644 --- a/templates/swagger/v1_json.tmpl +++ b/templates/swagger/v1_json.tmpl @@ -19137,6 +19137,10 @@ "type": "string", "x-go-name": "AuthorizationHeader" }, + "branch_filter": { + "type": "string", + "x-go-name": "BranchFilter" + }, "config": { "type": "object", "additionalProperties": { From 8a8d6b2c04a197d1cd027b16992876bbe47096b2 Mon Sep 17 00:00:00 2001 From: Yarden Shoham Date: Sun, 20 Aug 2023 18:45:36 +0300 Subject: [PATCH 2/2] Remove binding --- modules/structs/hook.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/structs/hook.go b/modules/structs/hook.go index 64bf68a20fe1..0babe844101a 100644 --- a/modules/structs/hook.go +++ b/modules/structs/hook.go @@ -19,7 +19,7 @@ var ErrInvalidReceiveHook = errors.New("Invalid JSON payload received over webho type Hook struct { ID int64 `json:"id"` Type string `json:"type"` - BranchFilter string `json:"branch_filter" binding:"GlobPattern"` + BranchFilter string `json:"branch_filter"` URL string `json:"-"` Config map[string]string `json:"config"` Events []string `json:"events"`