added support to set pull_request event from api (#3513)
This commit is contained in:
parent
0b273ac4d5
commit
67fb0fe6a5
|
@ -165,13 +165,16 @@ func (w *Webhook) HasPullRequestEvent() bool {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (w *Webhook) EventsArray() []string {
|
func (w *Webhook) EventsArray() []string {
|
||||||
events := make([]string, 0, 2)
|
events := make([]string, 0, 3)
|
||||||
if w.HasCreateEvent() {
|
if w.HasCreateEvent() {
|
||||||
events = append(events, "create")
|
events = append(events, "create")
|
||||||
}
|
}
|
||||||
if w.HasPushEvent() {
|
if w.HasPushEvent() {
|
||||||
events = append(events, "push")
|
events = append(events, "push")
|
||||||
}
|
}
|
||||||
|
if w.HasPullRequestEvent() {
|
||||||
|
events = append(events, "pull_request")
|
||||||
|
}
|
||||||
return events
|
return events
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -59,8 +59,9 @@ func CreateHook(ctx *context.APIContext, form api.CreateHookOption) {
|
||||||
HookEvent: &models.HookEvent{
|
HookEvent: &models.HookEvent{
|
||||||
ChooseEvents: true,
|
ChooseEvents: true,
|
||||||
HookEvents: models.HookEvents{
|
HookEvents: models.HookEvents{
|
||||||
Create: com.IsSliceContainsStr(form.Events, string(models.HOOK_EVENT_CREATE)),
|
Create: com.IsSliceContainsStr(form.Events, string(models.HOOK_EVENT_CREATE)),
|
||||||
Push: com.IsSliceContainsStr(form.Events, string(models.HOOK_EVENT_PUSH)),
|
Push: com.IsSliceContainsStr(form.Events, string(models.HOOK_EVENT_PUSH)),
|
||||||
|
PullRequest: com.IsSliceContainsStr(form.Events, string(models.HOOK_EVENT_PULL_REQUEST)),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
IsActive: form.Active,
|
IsActive: form.Active,
|
||||||
|
@ -146,6 +147,7 @@ func EditHook(ctx *context.APIContext, form api.EditHookOption) {
|
||||||
w.ChooseEvents = true
|
w.ChooseEvents = true
|
||||||
w.Create = com.IsSliceContainsStr(form.Events, string(models.HOOK_EVENT_CREATE))
|
w.Create = com.IsSliceContainsStr(form.Events, string(models.HOOK_EVENT_CREATE))
|
||||||
w.Push = com.IsSliceContainsStr(form.Events, string(models.HOOK_EVENT_PUSH))
|
w.Push = com.IsSliceContainsStr(form.Events, string(models.HOOK_EVENT_PUSH))
|
||||||
|
w.PullRequest = com.IsSliceContainsStr(form.Events, string(models.HOOK_EVENT_PULL_REQUEST))
|
||||||
if err = w.UpdateEvent(); err != nil {
|
if err = w.UpdateEvent(); err != nil {
|
||||||
ctx.Error(500, "UpdateEvent", err)
|
ctx.Error(500, "UpdateEvent", err)
|
||||||
return
|
return
|
||||||
|
|
Loading…
Reference in New Issue
Block a user