|
|
@ -68,8 +68,8 @@ type HookEvents struct { |
|
|
|
Fork bool `json:"fork"` |
|
|
|
Fork bool `json:"fork"` |
|
|
|
Push bool `json:"push"` |
|
|
|
Push bool `json:"push"` |
|
|
|
Issues bool `json:"issues"` |
|
|
|
Issues bool `json:"issues"` |
|
|
|
IssueComment bool `json:"issue_comment"` |
|
|
|
|
|
|
|
PullRequest bool `json:"pull_request"` |
|
|
|
PullRequest bool `json:"pull_request"` |
|
|
|
|
|
|
|
IssueComment bool `json:"issue_comment"` |
|
|
|
Release bool `json:"release"` |
|
|
|
Release bool `json:"release"` |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -186,18 +186,18 @@ func (w *Webhook) HasIssuesEvent() bool { |
|
|
|
(w.ChooseEvents && w.HookEvents.Issues) |
|
|
|
(w.ChooseEvents && w.HookEvents.Issues) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// HasIssueCommentEvent returns true if hook enabled issue comment event.
|
|
|
|
|
|
|
|
func (w *Webhook) HasIssueCommentEvent() bool { |
|
|
|
|
|
|
|
return w.SendEverything || |
|
|
|
|
|
|
|
(w.ChooseEvents && w.HookEvents.IssueComment) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// HasPullRequestEvent returns true if hook enabled pull request event.
|
|
|
|
// HasPullRequestEvent returns true if hook enabled pull request event.
|
|
|
|
func (w *Webhook) HasPullRequestEvent() bool { |
|
|
|
func (w *Webhook) HasPullRequestEvent() bool { |
|
|
|
return w.SendEverything || |
|
|
|
return w.SendEverything || |
|
|
|
(w.ChooseEvents && w.HookEvents.PullRequest) |
|
|
|
(w.ChooseEvents && w.HookEvents.PullRequest) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// HasIssueCommentEvent returns true if hook enabled issue comment event.
|
|
|
|
|
|
|
|
func (w *Webhook) HasIssueCommentEvent() bool { |
|
|
|
|
|
|
|
return w.SendEverything || |
|
|
|
|
|
|
|
(w.ChooseEvents && w.HookEvents.IssueComment) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// HasReleaseEvent returns true if hook enabled release event.
|
|
|
|
// HasReleaseEvent returns true if hook enabled release event.
|
|
|
|
func (w *Webhook) HasReleaseEvent() bool { |
|
|
|
func (w *Webhook) HasReleaseEvent() bool { |
|
|
|
return w.SendEverything || |
|
|
|
return w.SendEverything || |
|
|
@ -210,15 +210,15 @@ type eventChecker struct { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
func (w *Webhook) EventsArray() []string { |
|
|
|
func (w *Webhook) EventsArray() []string { |
|
|
|
events := make([]string, 0, 7) |
|
|
|
events := make([]string, 0, 8) |
|
|
|
eventCheckers := []eventChecker{ |
|
|
|
eventCheckers := []eventChecker{ |
|
|
|
{w.HasCreateEvent, HOOK_EVENT_CREATE}, |
|
|
|
{w.HasCreateEvent, HOOK_EVENT_CREATE}, |
|
|
|
{w.HasDeleteEvent, HOOK_EVENT_DELETE}, |
|
|
|
{w.HasDeleteEvent, HOOK_EVENT_DELETE}, |
|
|
|
{w.HasForkEvent, HOOK_EVENT_FORK}, |
|
|
|
{w.HasForkEvent, HOOK_EVENT_FORK}, |
|
|
|
{w.HasPushEvent, HOOK_EVENT_PUSH}, |
|
|
|
{w.HasPushEvent, HOOK_EVENT_PUSH}, |
|
|
|
{w.HasIssuesEvent, HOOK_EVENT_ISSUES}, |
|
|
|
{w.HasIssuesEvent, HOOK_EVENT_ISSUES}, |
|
|
|
{w.HasIssueCommentEvent, HOOK_EVENT_ISSUE_COMMENT}, |
|
|
|
|
|
|
|
{w.HasPullRequestEvent, HOOK_EVENT_PULL_REQUEST}, |
|
|
|
{w.HasPullRequestEvent, HOOK_EVENT_PULL_REQUEST}, |
|
|
|
|
|
|
|
{w.HasIssueCommentEvent, HOOK_EVENT_ISSUE_COMMENT}, |
|
|
|
{w.HasReleaseEvent, HOOK_EVENT_RELEASE}, |
|
|
|
{w.HasReleaseEvent, HOOK_EVENT_RELEASE}, |
|
|
|
} |
|
|
|
} |
|
|
|
for _, c := range eventCheckers { |
|
|
|
for _, c := range eventCheckers { |
|
|
@ -392,8 +392,8 @@ const ( |
|
|
|
HOOK_EVENT_FORK HookEventType = "fork" |
|
|
|
HOOK_EVENT_FORK HookEventType = "fork" |
|
|
|
HOOK_EVENT_PUSH HookEventType = "push" |
|
|
|
HOOK_EVENT_PUSH HookEventType = "push" |
|
|
|
HOOK_EVENT_ISSUES HookEventType = "issues" |
|
|
|
HOOK_EVENT_ISSUES HookEventType = "issues" |
|
|
|
HOOK_EVENT_ISSUE_COMMENT HookEventType = "issue_comment" |
|
|
|
|
|
|
|
HOOK_EVENT_PULL_REQUEST HookEventType = "pull_request" |
|
|
|
HOOK_EVENT_PULL_REQUEST HookEventType = "pull_request" |
|
|
|
|
|
|
|
HOOK_EVENT_ISSUE_COMMENT HookEventType = "issue_comment" |
|
|
|
HOOK_EVENT_RELEASE HookEventType = "release" |
|
|
|
HOOK_EVENT_RELEASE HookEventType = "release" |
|
|
|
) |
|
|
|
) |
|
|
|
|
|
|
|
|
|
|
@ -549,14 +549,14 @@ func prepareHookTasks(e Engine, repo *Repository, event HookEventType, p api.Pay |
|
|
|
if !w.HasIssuesEvent() { |
|
|
|
if !w.HasIssuesEvent() { |
|
|
|
continue |
|
|
|
continue |
|
|
|
} |
|
|
|
} |
|
|
|
case HOOK_EVENT_ISSUE_COMMENT: |
|
|
|
|
|
|
|
if !w.HasIssueCommentEvent() { |
|
|
|
|
|
|
|
continue |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
case HOOK_EVENT_PULL_REQUEST: |
|
|
|
case HOOK_EVENT_PULL_REQUEST: |
|
|
|
if !w.HasPullRequestEvent() { |
|
|
|
if !w.HasPullRequestEvent() { |
|
|
|
continue |
|
|
|
continue |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
case HOOK_EVENT_ISSUE_COMMENT: |
|
|
|
|
|
|
|
if !w.HasIssueCommentEvent() { |
|
|
|
|
|
|
|
continue |
|
|
|
|
|
|
|
} |
|
|
|
case HOOK_EVENT_RELEASE: |
|
|
|
case HOOK_EVENT_RELEASE: |
|
|
|
if !w.HasReleaseEvent() { |
|
|
|
if !w.HasReleaseEvent() { |
|
|
|
continue |
|
|
|
continue |
|
|
|