@@ -57,15 +57,24 @@ func IsValidHookContentType(name string) bool {
57
57
58
58
// HookEvents is a set of web hook events
59
59
type HookEvents struct {
60
- Create bool `json:"create"`
61
- Delete bool `json:"delete"`
62
- Fork bool `json:"fork"`
63
- Issues bool `json:"issues"`
64
- IssueComment bool `json:"issue_comment"`
65
- Push bool `json:"push"`
66
- PullRequest bool `json:"pull_request"`
67
- Repository bool `json:"repository"`
68
- Release bool `json:"release"`
60
+ Create bool `json:"create"`
61
+ Delete bool `json:"delete"`
62
+ Fork bool `json:"fork"`
63
+ Issues bool `json:"issues"`
64
+ IssueAssign bool `json:"issue_assign"`
65
+ IssueLabel bool `json:"issue_label"`
66
+ IssueMilestone bool `json:"issue_milestone"`
67
+ IssueComment bool `json:"issue_comment"`
68
+ Push bool `json:"push"`
69
+ PullRequest bool `json:"pull_request"`
70
+ PullRequestAssign bool `json:"pull_request_assign"`
71
+ PullRequestLabel bool `json:"pull_request_label"`
72
+ PullRequestMilestone bool `json:"pull_request_milestone"`
73
+ PullRequestComment bool `json:"pull_request_comment"`
74
+ PullRequestReview bool `json:"pull_request_review"`
75
+ PullRequestSync bool `json:"pull_request_sync"`
76
+ Repository bool `json:"repository"`
77
+ Release bool `json:"release"`
69
78
}
70
79
71
80
// HookEvent represents events that will delivery hook.
@@ -154,6 +163,24 @@ func (w *Webhook) HasIssuesEvent() bool {
154
163
(w .ChooseEvents && w .HookEvents .Issues )
155
164
}
156
165
166
+ // HasIssuesAssignEvent returns true if hook enabled issues assign event.
167
+ func (w * Webhook ) HasIssuesAssignEvent () bool {
168
+ return w .SendEverything ||
169
+ (w .ChooseEvents && w .HookEvents .IssueAssign )
170
+ }
171
+
172
+ // HasIssuesLabelEvent returns true if hook enabled issues label event.
173
+ func (w * Webhook ) HasIssuesLabelEvent () bool {
174
+ return w .SendEverything ||
175
+ (w .ChooseEvents && w .HookEvents .IssueLabel )
176
+ }
177
+
178
+ // HasIssuesMilestoneEvent returns true if hook enabled issues milestone event.
179
+ func (w * Webhook ) HasIssuesMilestoneEvent () bool {
180
+ return w .SendEverything ||
181
+ (w .ChooseEvents && w .HookEvents .IssueMilestone )
182
+ }
183
+
157
184
// HasIssueCommentEvent returns true if hook enabled issue_comment event.
158
185
func (w * Webhook ) HasIssueCommentEvent () bool {
159
186
return w .SendEverything ||
@@ -172,6 +199,54 @@ func (w *Webhook) HasPullRequestEvent() bool {
172
199
(w .ChooseEvents && w .HookEvents .PullRequest )
173
200
}
174
201
202
+ // HasPullRequestAssignEvent returns true if hook enabled pull request assign event.
203
+ func (w * Webhook ) HasPullRequestAssignEvent () bool {
204
+ return w .SendEverything ||
205
+ (w .ChooseEvents && w .HookEvents .PullRequestAssign )
206
+ }
207
+
208
+ // HasPullRequestLabelEvent returns true if hook enabled pull request label event.
209
+ func (w * Webhook ) HasPullRequestLabelEvent () bool {
210
+ return w .SendEverything ||
211
+ (w .ChooseEvents && w .HookEvents .PullRequestLabel )
212
+ }
213
+
214
+ // HasPullRequestMilestoneEvent returns true if hook enabled pull request milestone event.
215
+ func (w * Webhook ) HasPullRequestMilestoneEvent () bool {
216
+ return w .SendEverything ||
217
+ (w .ChooseEvents && w .HookEvents .PullRequestMilestone )
218
+ }
219
+
220
+ // HasPullRequestCommentEvent returns true if hook enabled pull_request_comment event.
221
+ func (w * Webhook ) HasPullRequestCommentEvent () bool {
222
+ return w .SendEverything ||
223
+ (w .ChooseEvents && w .HookEvents .PullRequestComment )
224
+ }
225
+
226
+ // HasPullRequestApprovedEvent returns true if hook enabled pull request review event.
227
+ func (w * Webhook ) HasPullRequestApprovedEvent () bool {
228
+ return w .SendEverything ||
229
+ (w .ChooseEvents && w .HookEvents .PullRequestReview )
230
+ }
231
+
232
+ // HasPullRequestRejectedEvent returns true if hook enabled pull request review event.
233
+ func (w * Webhook ) HasPullRequestRejectedEvent () bool {
234
+ return w .SendEverything ||
235
+ (w .ChooseEvents && w .HookEvents .PullRequestReview )
236
+ }
237
+
238
+ // HasPullRequestReviewCommentEvent returns true if hook enabled pull request review event.
239
+ func (w * Webhook ) HasPullRequestReviewCommentEvent () bool {
240
+ return w .SendEverything ||
241
+ (w .ChooseEvents && w .HookEvents .PullRequestReview )
242
+ }
243
+
244
+ // HasPullRequestSyncEvent returns true if hook enabled pull request sync event.
245
+ func (w * Webhook ) HasPullRequestSyncEvent () bool {
246
+ return w .SendEverything ||
247
+ (w .ChooseEvents && w .HookEvents .PullRequestSync )
248
+ }
249
+
175
250
// HasReleaseEvent returns if hook enabled release event.
176
251
func (w * Webhook ) HasReleaseEvent () bool {
177
252
return w .SendEverything ||
@@ -198,8 +273,19 @@ func (w *Webhook) EventCheckers() []struct {
198
273
{w .HasForkEvent , HookEventFork },
199
274
{w .HasPushEvent , HookEventPush },
200
275
{w .HasIssuesEvent , HookEventIssues },
276
+ {w .HasIssuesAssignEvent , HookEventIssueAssign },
277
+ {w .HasIssuesLabelEvent , HookEventIssueLabel },
278
+ {w .HasIssuesMilestoneEvent , HookEventIssueMilestone },
201
279
{w .HasIssueCommentEvent , HookEventIssueComment },
202
280
{w .HasPullRequestEvent , HookEventPullRequest },
281
+ {w .HasPullRequestAssignEvent , HookEventPullRequestAssign },
282
+ {w .HasPullRequestLabelEvent , HookEventPullRequestLabel },
283
+ {w .HasPullRequestMilestoneEvent , HookEventPullRequestMilestone },
284
+ {w .HasPullRequestCommentEvent , HookEventPullRequestComment },
285
+ {w .HasPullRequestApprovedEvent , HookEventPullRequestReviewApproved },
286
+ {w .HasPullRequestRejectedEvent , HookEventPullRequestReviewRejected },
287
+ {w .HasPullRequestCommentEvent , HookEventPullRequestReviewComment },
288
+ {w .HasPullRequestSyncEvent , HookEventPullRequestSync },
203
289
{w .HasRepositoryEvent , HookEventRepository },
204
290
{w .HasReleaseEvent , HookEventRelease },
205
291
}
@@ -498,20 +584,60 @@ type HookEventType string
498
584
499
585
// Types of hook events
500
586
const (
501
- HookEventCreate HookEventType = "create"
502
- HookEventDelete HookEventType = "delete"
503
- HookEventFork HookEventType = "fork"
504
- HookEventPush HookEventType = "push"
505
- HookEventIssues HookEventType = "issues"
506
- HookEventIssueComment HookEventType = "issue_comment"
507
- HookEventPullRequest HookEventType = "pull_request"
508
- HookEventRepository HookEventType = "repository"
509
- HookEventRelease HookEventType = "release"
510
- HookEventPullRequestApproved HookEventType = "pull_request_approved"
511
- HookEventPullRequestRejected HookEventType = "pull_request_rejected"
512
- HookEventPullRequestComment HookEventType = "pull_request_comment"
587
+ HookEventCreate HookEventType = "create"
588
+ HookEventDelete HookEventType = "delete"
589
+ HookEventFork HookEventType = "fork"
590
+ HookEventPush HookEventType = "push"
591
+ HookEventIssues HookEventType = "issues"
592
+ HookEventIssueAssign HookEventType = "issue_assign"
593
+ HookEventIssueLabel HookEventType = "issue_label"
594
+ HookEventIssueMilestone HookEventType = "issue_milestone"
595
+ HookEventIssueComment HookEventType = "issue_comment"
596
+ HookEventPullRequest HookEventType = "pull_request"
597
+ HookEventPullRequestAssign HookEventType = "pull_request_assign"
598
+ HookEventPullRequestLabel HookEventType = "pull_request_label"
599
+ HookEventPullRequestMilestone HookEventType = "pull_request_milestone"
600
+ HookEventPullRequestComment HookEventType = "pull_request_comment"
601
+ HookEventPullRequestReviewApproved HookEventType = "pull_request_review_approved"
602
+ HookEventPullRequestReviewRejected HookEventType = "pull_request_review_rejected"
603
+ HookEventPullRequestReviewComment HookEventType = "pull_request_review_comment"
604
+ HookEventPullRequestSync HookEventType = "pull_request_sync"
605
+ HookEventRepository HookEventType = "repository"
606
+ HookEventRelease HookEventType = "release"
513
607
)
514
608
609
+ // Event returns the HookEventType as an event string
610
+ func (h HookEventType ) Event () string {
611
+ switch h {
612
+ case HookEventCreate :
613
+ return "create"
614
+ case HookEventDelete :
615
+ return "delete"
616
+ case HookEventFork :
617
+ return "fork"
618
+ case HookEventPush :
619
+ return "push"
620
+ case HookEventIssues , HookEventIssueAssign , HookEventIssueLabel , HookEventIssueMilestone :
621
+ return "issues"
622
+ case HookEventPullRequest , HookEventPullRequestAssign , HookEventPullRequestLabel , HookEventPullRequestMilestone ,
623
+ HookEventPullRequestSync :
624
+ return "pull_request"
625
+ case HookEventIssueComment , HookEventPullRequestComment :
626
+ return "issue_comment"
627
+ case HookEventPullRequestReviewApproved :
628
+ return "pull_request_approved"
629
+ case HookEventPullRequestReviewRejected :
630
+ return "pull_request_rejected"
631
+ case HookEventPullRequestReviewComment :
632
+ return "pull_request_comment"
633
+ case HookEventRepository :
634
+ return "repository"
635
+ case HookEventRelease :
636
+ return "release"
637
+ }
638
+ return ""
639
+ }
640
+
515
641
// HookRequest represents hook task request information.
516
642
type HookRequest struct {
517
643
Headers map [string ]string `json:"headers"`
0 commit comments