Skip to content

Commit

Permalink
Merge pull request #250 from samoht/webhooks
Browse files Browse the repository at this point in the history
github: fix the webhook server
  • Loading branch information
samoht authored Sep 2, 2016
2 parents 785c3c8 + 51b9edb commit 1d12070
Show file tree
Hide file tree
Showing 3 changed files with 189 additions and 146 deletions.
20 changes: 12 additions & 8 deletions bridge/github/src/datakit_github_api.ml
Original file line number Diff line number Diff line change
Expand Up @@ -103,13 +103,9 @@ module Event = struct

include Event

let of_gh e =
let repo = match String.cut ~sep:"/" e.event_repo.repo_name with
| None -> failwith (e.event_repo.repo_name ^ " is not a valid repo name")
| Some (user, repo) -> { Repo.user; repo }
in
let of_gh_constr repo e =
let other str = Other (repo, str) in
match e.event_payload with
match e with
| `Status s -> Status (Status.of_event repo s)
| `PullRequest pr -> PR (PR.of_event repo pr)
| `Push p -> Ref (Ref.of_event repo p)
Expand All @@ -130,9 +126,17 @@ module Event = struct
| `PullRequestReviewComment _ -> other "pull-request-review-comment"
| `CommitComment _ -> other "commit-comment"


let of_gh e =
let repo = match String.cut ~sep:"/" e.event_repo.repo_name with
| None -> failwith (e.event_repo.repo_name ^ " is not a valid repo name")
| Some (user, repo) -> { Repo.user; repo }
in
of_gh_constr repo e.event_payload

end

let event = Event.of_gh
let event_constr = Event.of_gh_constr

open Rresult
open Lwt.Infix
Expand Down Expand Up @@ -246,5 +250,5 @@ let events token r =

module Webhook = struct
include Datakit_github_webhook
let events t = List.map event (events t)
let events t = List.map (fun (r, e) -> event_constr r e) (events t)
end
Loading

0 comments on commit 1d12070

Please sign in to comment.