diff options
author | WGH <wgh@torlan.ru> | 2019-09-09 08:48:21 +0300 |
---|---|---|
committer | Lauris BH <lauris.buksis@zzdats.lv> | 2019-09-09 08:48:21 +0300 |
commit | 6ddd3b0b470d16dfe62caf5fff21011cfff44a76 (patch) | |
tree | 05d4c7fedf8af21b489003890be000f839f69a51 /routers | |
parent | 0118b6aaf8ada3edd67cb975c776f6f124178ad2 (diff) | |
download | gitea-6ddd3b0b470d16dfe62caf5fff21011cfff44a76.tar.gz gitea-6ddd3b0b470d16dfe62caf5fff21011cfff44a76.zip |
Implement webhook branch filter (#7791)
* Fix validate() function to handle errors in embedded anon structs
* Implement webhook branch filter
See #2025, #3998.
Diffstat (limited to 'routers')
-rw-r--r-- | routers/api/v1/utils/hook.go | 2 | ||||
-rw-r--r-- | routers/repo/webhook.go | 1 |
2 files changed, 3 insertions, 0 deletions
diff --git a/routers/api/v1/utils/hook.go b/routers/api/v1/utils/hook.go index 0b00e59ade..7903d58334 100644 --- a/routers/api/v1/utils/hook.go +++ b/routers/api/v1/utils/hook.go @@ -112,6 +112,7 @@ func addHook(ctx *context.APIContext, form *api.CreateHookOption, orgID, repoID Repository: com.IsSliceContainsStr(form.Events, string(models.HookEventRepository)), Release: com.IsSliceContainsStr(form.Events, string(models.HookEventRelease)), }, + BranchFilter: form.BranchFilter, }, IsActive: form.Active, HookTaskType: models.ToHookTaskType(form.Type), @@ -236,6 +237,7 @@ func editHook(ctx *context.APIContext, form *api.EditHookOption, w *models.Webho w.PullRequest = com.IsSliceContainsStr(form.Events, string(models.HookEventPullRequest)) w.Repository = com.IsSliceContainsStr(form.Events, string(models.HookEventRepository)) w.Release = com.IsSliceContainsStr(form.Events, string(models.HookEventRelease)) + w.BranchFilter = form.BranchFilter if err := w.UpdateEvent(); err != nil { ctx.Error(500, "UpdateEvent", err) diff --git a/routers/repo/webhook.go b/routers/repo/webhook.go index d523fd9e87..0711270cb9 100644 --- a/routers/repo/webhook.go +++ b/routers/repo/webhook.go @@ -145,6 +145,7 @@ func ParseHookEvent(form auth.WebhookForm) *models.HookEvent { PullRequest: form.PullRequest, Repository: form.Repository, }, + BranchFilter: form.BranchFilter, } } |