Skip to content

Commit 76dc755

Browse files
committed
Fix tests
1 parent 6347528 commit 76dc755

File tree

5 files changed

+12
-2
lines changed

5 files changed

+12
-2
lines changed

models/webhook/webhook.go

+6-1
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,12 @@ func (w *Webhook) HasEvent(evt webhook_module.HookEventType) bool {
174174
if w.PushOnly {
175175
return evt == webhook_module.HookEventPush
176176
}
177-
return w.HookEvents[evt]
177+
checkEvt := evt
178+
switch evt {
179+
case webhook_module.HookEventPullRequestReviewApproved, webhook_module.HookEventPullRequestReviewRejected, webhook_module.HookEventPullRequestReviewComment:
180+
checkEvt = webhook_module.HookEventPullRequestReview
181+
}
182+
return w.HookEvents[checkEvt]
178183
}
179184

180185
// EventsArray returns an array of hook events

modules/webhook/type.go

+2
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,8 @@ const (
3434
HookEventStatus HookEventType = "status"
3535
// once a new event added here, please also added to AllEvents() function
3636

37+
// FIXME: This event should be a group of pull_request_review_xxx events
38+
HookEventPullRequestReview HookEventType = "pull_request_review"
3739
// Actions event only
3840
HookEventSchedule HookEventType = "schedule"
3941
)

routers/api/v1/utils/hook.go

+2-1
Original file line numberDiff line numberDiff line change
@@ -199,6 +199,7 @@ func addHook(ctx *context.APIContext, form *api.CreateHookOption, ownerID, repoI
199199
webhook_module.HookEventPullRequestLabel: pullHook(form.Events, string(webhook_module.HookEventPullRequestLabel)),
200200
webhook_module.HookEventPullRequestMilestone: pullHook(form.Events, string(webhook_module.HookEventPullRequestMilestone)),
201201
webhook_module.HookEventPullRequestComment: pullHook(form.Events, string(webhook_module.HookEventPullRequestComment)),
202+
webhook_module.HookEventPullRequestReview: pullHook(form.Events, "pull_request_review"),
202203
webhook_module.HookEventPullRequestReviewRequest: pullHook(form.Events, string(webhook_module.HookEventPullRequestReviewRequest)),
203204
webhook_module.HookEventPullRequestSync: pullHook(form.Events, string(webhook_module.HookEventPullRequestSync)),
204205
webhook_module.HookEventWiki: util.SliceContainsString(form.Events, string(webhook_module.HookEventWiki), true),
@@ -383,7 +384,7 @@ func editHook(ctx *context.APIContext, form *api.EditHookOption, w *webhook.Webh
383384
w.HookEvents[webhook_module.HookEventPullRequestAssign] = pullHook(form.Events, string(webhook_module.HookEventPullRequestAssign))
384385
w.HookEvents[webhook_module.HookEventPullRequestLabel] = pullHook(form.Events, string(webhook_module.HookEventPullRequestLabel))
385386
w.HookEvents[webhook_module.HookEventPullRequestMilestone] = pullHook(form.Events, string(webhook_module.HookEventPullRequestMilestone))
386-
w.HookEvents[webhook_module.HookEventPullRequestComment] = pullHook(form.Events, string(webhook_module.HookEventPullRequestComment))
387+
w.HookEvents[webhook_module.HookEventPullRequestReview] = pullHook(form.Events, "pull_request_review")
387388
w.HookEvents[webhook_module.HookEventPullRequestReviewRequest] = pullHook(form.Events, string(webhook_module.HookEventPullRequestReviewRequest))
388389
w.HookEvents[webhook_module.HookEventPullRequestSync] = pullHook(form.Events, string(webhook_module.HookEventPullRequestSync))
389390

routers/web/repo/setting/webhook.go

+1
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,7 @@ func ParseHookEvent(form forms.WebhookForm) *webhook_module.HookEvent {
178178
webhook_module.HookEventPullRequestLabel: form.PullRequestLabel,
179179
webhook_module.HookEventPullRequestMilestone: form.PullRequestMilestone,
180180
webhook_module.HookEventPullRequestComment: form.PullRequestComment,
181+
webhook_module.HookEventPullRequestReview: form.PullRequestReview,
181182
webhook_module.HookEventPullRequestSync: form.PullRequestSync,
182183
webhook_module.HookEventPullRequestReviewRequest: form.PullRequestReviewRequest,
183184
webhook_module.HookEventWiki: form.Wiki,

services/forms/repo_form.go

+1
Original file line numberDiff line numberDiff line change
@@ -236,6 +236,7 @@ type WebhookForm struct {
236236
PullRequestLabel bool
237237
PullRequestMilestone bool
238238
PullRequestComment bool
239+
PullRequestReview bool
239240
PullRequestSync bool
240241
PullRequestReviewRequest bool
241242
Wiki bool

0 commit comments

Comments
 (0)