aboutsummaryrefslogtreecommitdiff
path: root/mod/mod-ci-github-gh.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'mod/mod-ci-github-gh.cxx')
-rw-r--r--mod/mod-ci-github-gh.cxx114
1 files changed, 108 insertions, 6 deletions
diff --git a/mod/mod-ci-github-gh.cxx b/mod/mod-ci-github-gh.cxx
index 208adbd..6372ef0 100644
--- a/mod/mod-ci-github-gh.cxx
+++ b/mod/mod-ci-github-gh.cxx
@@ -161,16 +161,62 @@ namespace brep
{
p.next_expect (event::begin_object);
- // We always ask for this exact set of fields to be returned in GraphQL
- // requests.
+ bool ni (false), nm (false), st (false);
+
+ // Skip unknown/uninteresting members.
+ //
+ while (p.next_expect (event::name, event::end_object))
+ {
+ auto c = [&p] (bool& v, const char* s)
+ {
+ return p.name () == s ? (v = true) : false;
+ };
+
+ if (c (ni, "node_id")) node_id = p.next_expect_string ();
+ else if (c (nm, "name")) name = p.next_expect_string ();
+ else if (c (st, "status")) status = p.next_expect_string ();
+ else p.next_expect_value_skip ();
+ }
+
+ if (!ni) missing_member (p, "gh_check_run", "node_id");
+ if (!nm) missing_member (p, "gh_check_run", "name");
+ if (!st) missing_member (p, "gh_check_run", "status");
+ }
+
+ // gh_check_run_ex
+ //
+ gh_check_run_ex::
+ gh_check_run_ex (json::parser& p)
+ {
+ p.next_expect (event::begin_object);
+
+ bool ni (false), nm (false), st (false), du (false), cs (false);
+
+ // Skip unknown/uninteresting members.
//
- node_id = p.next_expect_member_string ("id");
- name = p.next_expect_member_string ("name");
- status = p.next_expect_member_string ("status");
+ while (p.next_expect (event::name, event::end_object))
+ {
+ auto c = [&p] (bool& v, const char* s)
+ {
+ return p.name () == s ? (v = true) : false;
+ };
+
+ if (c (ni, "node_id")) node_id = p.next_expect_string ();
+ else if (c (nm, "name")) name = p.next_expect_string ();
+ else if (c (st, "status")) status = p.next_expect_string ();
+ else if (c (du, "details_url")) details_url = p.next_expect_string ();
+ else if (c (cs, "check_suite")) check_suite = gh_check_suite (p);
+ else p.next_expect_value_skip ();
+ }
- p.next_expect (event::end_object);
+ if (!ni) missing_member (p, "gh_check_run", "node_id");
+ if (!nm) missing_member (p, "gh_check_run", "name");
+ if (!st) missing_member (p, "gh_check_run", "status");
+ if (!du) missing_member (p, "gh_check_run", "details_url");
+ if (!cs) missing_member (p, "gh_check_run", "check_suite");
}
+
ostream&
operator<< (ostream& os, const gh_check_run& cr)
{
@@ -181,6 +227,16 @@ namespace brep
return os;
}
+ ostream&
+ operator<< (ostream& os, const gh_check_run_ex& cr)
+ {
+ os << static_cast<const gh_check_run&> (cr)
+ << ", details_url: " << cr.details_url
+ << ", check_suite: { " << cr.check_suite << " }";
+
+ return os;
+ }
+
gh_pull_request::
gh_pull_request (json::parser& p)
{
@@ -404,6 +460,52 @@ namespace brep
return os;
}
+ // gh_check_run_event
+ //
+ gh_check_run_event::
+ gh_check_run_event (json::parser& p)
+ {
+ p.next_expect (event::begin_object);
+
+ bool ac (false), cs (false), rp (false), in (false);
+
+ // Skip unknown/uninteresting members.
+ //
+ while (p.next_expect (event::name, event::end_object))
+ {
+ auto c = [&p] (bool& v, const char* s)
+ {
+ return p.name () == s ? (v = true) : false;
+ };
+
+ // Pass true to gh_check_run() to indicate that the we're parsing a
+ // webhook event or REST API response (in which case more fields are
+ // expected to be present than in a GraphQL response).
+ //
+ if (c (ac, "action")) action = p.next_expect_string ();
+ else if (c (cs, "check_run")) check_run = gh_check_run_ex (p);
+ else if (c (rp, "repository")) repository = gh_repository (p);
+ else if (c (in, "installation")) installation = gh_installation (p);
+ else p.next_expect_value_skip ();
+ }
+
+ if (!ac) missing_member (p, "gh_check_run_event", "action");
+ if (!cs) missing_member (p, "gh_check_run_event", "check_run");
+ if (!rp) missing_member (p, "gh_check_run_event", "repository");
+ if (!in) missing_member (p, "gh_check_run_event", "installation");
+ }
+
+ ostream&
+ operator<< (ostream& os, const gh_check_run_event& cr)
+ {
+ os << "action: " << cr.action;
+ os << ", check_run { " << cr.check_run << " }";
+ os << ", repository { " << cr.repository << " }";
+ os << ", installation { " << cr.installation << " }";
+
+ return os;
+ }
+
// gh_pull_request_event
//
gh_pull_request_event::