File tree Expand file tree Collapse file tree 2 files changed +45
-2
lines changed Expand file tree Collapse file tree 2 files changed +45
-2
lines changed Original file line number Diff line number Diff line change @@ -177,10 +177,21 @@ func (w *Webhook) HasEvent(evt webhook_module.HookEventType) bool {
177177 return w .HookEvents [evt ]
178178}
179179
180- // EventsArray returns an array of hook events
180+ // EventsArray returns an array of hook events,
181181func (w * Webhook ) EventsArray () []string {
182- events := make ([]string , 0 , 7 )
182+ if w .SendEverything {
183+ events := make ([]string , 0 , len (webhook_module .AllEvents ()))
184+ for _ , evt := range webhook_module .AllEvents () {
185+ events = append (events , string (evt ))
186+ }
187+ return events
188+ }
189+
190+ if w .PushOnly {
191+ return []string {string (webhook_module .HookEventPush )}
192+ }
183193
194+ events := make ([]string , 0 , len (w .HookEvents ))
184195 for event , enabled := range w .HookEvents {
185196 if enabled {
186197 events = append (events , string (event ))
Original file line number Diff line number Diff line change @@ -34,8 +34,40 @@ const (
3434 HookEventPackage HookEventType = "package"
3535 HookEventSchedule HookEventType = "schedule"
3636 HookEventStatus HookEventType = "status"
37+ // once a new event added here, please also added to AllEvents() function
3738)
3839
40+ func AllEvents () []HookEventType {
41+ return []HookEventType {
42+ HookEventCreate ,
43+ HookEventDelete ,
44+ HookEventFork ,
45+ HookEventPush ,
46+ HookEventIssues ,
47+ HookEventIssueAssign ,
48+ HookEventIssueLabel ,
49+ HookEventIssueMilestone ,
50+ HookEventIssueComment ,
51+ HookEventPullRequest ,
52+ HookEventPullRequestAssign ,
53+ HookEventPullRequestLabel ,
54+ HookEventPullRequestMilestone ,
55+ HookEventPullRequestComment ,
56+ HookEventPullRequestReview ,
57+ HookEventPullRequestReviewApproved ,
58+ HookEventPullRequestReviewRejected ,
59+ HookEventPullRequestReviewComment ,
60+ HookEventPullRequestSync ,
61+ HookEventPullRequestReviewRequest ,
62+ HookEventWiki ,
63+ HookEventRepository ,
64+ HookEventRelease ,
65+ HookEventPackage ,
66+ HookEventSchedule ,
67+ HookEventStatus ,
68+ }
69+ }
70+
3971// Event returns the HookEventType as an event string
4072func (h HookEventType ) Event () string {
4173 switch h {
You can’t perform that action at this time.
0 commit comments