Skip to content

Commit

Permalink
support parsing unknown event types
Browse files Browse the repository at this point in the history
  • Loading branch information
bradrydzewski committed Dec 1, 2020
1 parent ff8ad5b commit ffa46d9
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
3 changes: 2 additions & 1 deletion scm/const.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ type Action int

// Action values.
const (
ActionCreate Action = iota + 1
ActionUnknown Action = iota
ActionCreate
ActionUpdate
ActionDelete
// issues
Expand Down
10 changes: 8 additions & 2 deletions scm/driver/github/webhook.go
Original file line number Diff line number Diff line change
Expand Up @@ -125,8 +125,6 @@ func (s *webhookService) parsePullRequestHook(data []byte) (scm.Webhook, error)
}
dst := convertPullRequestHook(src)
switch src.Action {
case "assigned", "unassigned", "review_requested", "review_request_removed":
return nil, nil
case "labeled":
dst.Action = scm.ActionLabel
case "unlabeled":
Expand All @@ -136,13 +134,21 @@ func (s *webhookService) parsePullRequestHook(data []byte) (scm.Webhook, error)
case "edited":
dst.Action = scm.ActionUpdate
case "closed":
// TODO(bradrydzewski) github does not provide a merged action,
// but this is provided by gitlab and bitbucket. Is it possible
// to emulate the merge action?

// if merged == true
// dst.Action = scm.ActionMerge
dst.Action = scm.ActionClose
case "reopened":
dst.Action = scm.ActionReopen
case "synchronize":
dst.Action = scm.ActionSync
case "assigned", "unassigned", "review_requested", "review_request_removed", "ready_for_review", "locked", "unlocked":
dst.Action = scm.ActionUnknown
default:
dst.Action = scm.ActionUnknown
}
return dst, nil
}
Expand Down

0 comments on commit ffa46d9

Please sign in to comment.