Skip to content

Commit

Permalink
Extract StatusPayload from PullRequest
Browse files Browse the repository at this point in the history
  • Loading branch information
Schniz committed Nov 22, 2018
1 parent 66016a2 commit 26f024f
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 34 deletions.
34 changes: 0 additions & 34 deletions src/PullRequest.re
Expand Up @@ -4,40 +4,6 @@ type pull_request = {
statuses_url: string,
};

module StatusPayload = {
type state =
| Pending
| Success;
type t = {
description: string,
context: string,
state,
};
let string_of_state =
fun
| Success => "success"
| Pending => "pending";
let to_json = spp =>
Ezjsonm.(
dict([
("state", string_of_state(spp.state) |> string),
("description", string(spp.description)),
("context", string(spp.context)),
])
);

let success = {
description: "Alright! PR has valid label(s).",
context: "pr/labels",
state: Success,
};
let pending = {
description: "Don't forget to add a PR label!",
context: "pr/labels",
state: Pending,
};
};

let startsWith = (substr, str) =>
Stringext.find_from(~pattern=substr, str) != None;
let isValidLabel = startsWith("PR: ");
Expand Down
31 changes: 31 additions & 0 deletions src/StatusPayload.re
@@ -0,0 +1,31 @@
type state =
| Pending
| Success;
type t = {
description: string,
context: string,
state,
};
let string_of_state =
fun
| Success => "success"
| Pending => "pending";
let to_json = spp =>
Ezjsonm.(
dict([
("state", string_of_state(spp.state) |> string),
("description", string(spp.description)),
("context", string(spp.context)),
])
);

let success = {
description: "Alright! PR has valid label(s).",
context: "pr/labels",
state: Success,
};
let pending = {
description: "Don't forget to add a PR label!",
context: "pr/labels",
state: Pending,
};

0 comments on commit 26f024f

Please sign in to comment.