Skip to content

Commit ea6efba

Browse files
authored
Granular webhook events in editHook (#19251)
Signed-off-by: jolheiser <[email protected]>
1 parent 97625b4 commit ea6efba

File tree

1 file changed

+16
-5
lines changed

1 file changed

+16
-5
lines changed

routers/api/v1/utils/hook.go

+16-5
Original file line numberDiff line numberDiff line change
@@ -245,18 +245,29 @@ func editHook(ctx *context.APIContext, form *api.EditHookOption, w *webhook.Webh
245245
w.ChooseEvents = true
246246
w.Create = util.IsStringInSlice(string(webhook.HookEventCreate), form.Events, true)
247247
w.Push = util.IsStringInSlice(string(webhook.HookEventPush), form.Events, true)
248-
w.PullRequest = util.IsStringInSlice(string(webhook.HookEventPullRequest), form.Events, true)
249248
w.Create = util.IsStringInSlice(string(webhook.HookEventCreate), form.Events, true)
250249
w.Delete = util.IsStringInSlice(string(webhook.HookEventDelete), form.Events, true)
251250
w.Fork = util.IsStringInSlice(string(webhook.HookEventFork), form.Events, true)
252-
w.Issues = util.IsStringInSlice(string(webhook.HookEventIssues), form.Events, true)
253-
w.IssueComment = util.IsStringInSlice(string(webhook.HookEventIssueComment), form.Events, true)
254-
w.Push = util.IsStringInSlice(string(webhook.HookEventPush), form.Events, true)
255-
w.PullRequest = util.IsStringInSlice(string(webhook.HookEventPullRequest), form.Events, true)
256251
w.Repository = util.IsStringInSlice(string(webhook.HookEventRepository), form.Events, true)
257252
w.Release = util.IsStringInSlice(string(webhook.HookEventRelease), form.Events, true)
258253
w.BranchFilter = form.BranchFilter
259254

255+
// Issues
256+
w.Issues = issuesHook(form.Events, "issues_only")
257+
w.IssueAssign = issuesHook(form.Events, string(webhook.HookEventIssueAssign))
258+
w.IssueLabel = issuesHook(form.Events, string(webhook.HookEventIssueLabel))
259+
w.IssueMilestone = issuesHook(form.Events, string(webhook.HookEventIssueMilestone))
260+
w.IssueComment = issuesHook(form.Events, string(webhook.HookEventIssueComment))
261+
262+
// Pull requests
263+
w.PullRequest = pullHook(form.Events, "pull_request_only")
264+
w.PullRequestAssign = pullHook(form.Events, string(webhook.HookEventPullRequestAssign))
265+
w.PullRequestLabel = pullHook(form.Events, string(webhook.HookEventPullRequestLabel))
266+
w.PullRequestMilestone = pullHook(form.Events, string(webhook.HookEventPullRequestMilestone))
267+
w.PullRequestComment = pullHook(form.Events, string(webhook.HookEventPullRequestComment))
268+
w.PullRequestReview = pullHook(form.Events, "pull_request_review")
269+
w.PullRequestSync = pullHook(form.Events, string(webhook.HookEventPullRequestSync))
270+
260271
if err := w.UpdateEvent(); err != nil {
261272
ctx.Error(http.StatusInternalServerError, "UpdateEvent", err)
262273
return false

0 commit comments

Comments
 (0)