Skip to content

Commit

Permalink
Fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
lunny committed Jan 21, 2025
1 parent 6347528 commit 76dc755
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 2 deletions.
7 changes: 6 additions & 1 deletion models/webhook/webhook.go
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,12 @@ func (w *Webhook) HasEvent(evt webhook_module.HookEventType) bool {
if w.PushOnly {
return evt == webhook_module.HookEventPush
}
return w.HookEvents[evt]
checkEvt := evt
switch evt {
case webhook_module.HookEventPullRequestReviewApproved, webhook_module.HookEventPullRequestReviewRejected, webhook_module.HookEventPullRequestReviewComment:
checkEvt = webhook_module.HookEventPullRequestReview
}
return w.HookEvents[checkEvt]
}

// EventsArray returns an array of hook events
Expand Down
2 changes: 2 additions & 0 deletions modules/webhook/type.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ const (
HookEventStatus HookEventType = "status"
// once a new event added here, please also added to AllEvents() function

// FIXME: This event should be a group of pull_request_review_xxx events
HookEventPullRequestReview HookEventType = "pull_request_review"
// Actions event only
HookEventSchedule HookEventType = "schedule"
)
Expand Down
3 changes: 2 additions & 1 deletion routers/api/v1/utils/hook.go
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,7 @@ func addHook(ctx *context.APIContext, form *api.CreateHookOption, ownerID, repoI
webhook_module.HookEventPullRequestLabel: pullHook(form.Events, string(webhook_module.HookEventPullRequestLabel)),
webhook_module.HookEventPullRequestMilestone: pullHook(form.Events, string(webhook_module.HookEventPullRequestMilestone)),
webhook_module.HookEventPullRequestComment: pullHook(form.Events, string(webhook_module.HookEventPullRequestComment)),
webhook_module.HookEventPullRequestReview: pullHook(form.Events, "pull_request_review"),
webhook_module.HookEventPullRequestReviewRequest: pullHook(form.Events, string(webhook_module.HookEventPullRequestReviewRequest)),
webhook_module.HookEventPullRequestSync: pullHook(form.Events, string(webhook_module.HookEventPullRequestSync)),
webhook_module.HookEventWiki: util.SliceContainsString(form.Events, string(webhook_module.HookEventWiki), true),
Expand Down Expand Up @@ -383,7 +384,7 @@ func editHook(ctx *context.APIContext, form *api.EditHookOption, w *webhook.Webh
w.HookEvents[webhook_module.HookEventPullRequestAssign] = pullHook(form.Events, string(webhook_module.HookEventPullRequestAssign))
w.HookEvents[webhook_module.HookEventPullRequestLabel] = pullHook(form.Events, string(webhook_module.HookEventPullRequestLabel))
w.HookEvents[webhook_module.HookEventPullRequestMilestone] = pullHook(form.Events, string(webhook_module.HookEventPullRequestMilestone))
w.HookEvents[webhook_module.HookEventPullRequestComment] = pullHook(form.Events, string(webhook_module.HookEventPullRequestComment))
w.HookEvents[webhook_module.HookEventPullRequestReview] = pullHook(form.Events, "pull_request_review")
w.HookEvents[webhook_module.HookEventPullRequestReviewRequest] = pullHook(form.Events, string(webhook_module.HookEventPullRequestReviewRequest))
w.HookEvents[webhook_module.HookEventPullRequestSync] = pullHook(form.Events, string(webhook_module.HookEventPullRequestSync))

Expand Down
1 change: 1 addition & 0 deletions routers/web/repo/setting/webhook.go
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,7 @@ func ParseHookEvent(form forms.WebhookForm) *webhook_module.HookEvent {
webhook_module.HookEventPullRequestLabel: form.PullRequestLabel,
webhook_module.HookEventPullRequestMilestone: form.PullRequestMilestone,
webhook_module.HookEventPullRequestComment: form.PullRequestComment,
webhook_module.HookEventPullRequestReview: form.PullRequestReview,
webhook_module.HookEventPullRequestSync: form.PullRequestSync,
webhook_module.HookEventPullRequestReviewRequest: form.PullRequestReviewRequest,
webhook_module.HookEventWiki: form.Wiki,
Expand Down
1 change: 1 addition & 0 deletions services/forms/repo_form.go
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,7 @@ type WebhookForm struct {
PullRequestLabel bool
PullRequestMilestone bool
PullRequestComment bool
PullRequestReview bool
PullRequestSync bool
PullRequestReviewRequest bool
Wiki bool
Expand Down

0 comments on commit 76dc755

Please sign in to comment.