diff options
Diffstat (limited to 'mod/mod-ci-github-gh.cxx')
-rw-r--r-- | mod/mod-ci-github-gh.cxx | 69 |
1 files changed, 49 insertions, 20 deletions
diff --git a/mod/mod-ci-github-gh.cxx b/mod/mod-ci-github-gh.cxx index 4ad8d32..dcea563 100644 --- a/mod/mod-ci-github-gh.cxx +++ b/mod/mod-ci-github-gh.cxx @@ -129,9 +129,14 @@ namespace brep return p.name () == s ? (v = true) : false; }; - if (c (ni, "node_id")) node_id = p.next_expect_string (); - else if (c (hb, "head_branch")) head_branch = p.next_expect_string (); - else if (c (hs, "head_sha")) head_sha = p.next_expect_string (); + if (c (ni, "node_id")) node_id = p.next_expect_string (); + else if (c (hb, "head_branch")) + { + string* v (p.next_expect_string_null ()); + if (v != nullptr) + head_branch = *v; + } + else if (c (hs, "head_sha")) head_sha = p.next_expect_string (); else p.next_expect_value_skip (); } @@ -144,7 +149,7 @@ namespace brep operator<< (ostream& os, const gh_check_suite& cs) { os << "node_id: " << cs.node_id - << ", head_branch: " << cs.head_branch + << ", head_branch: " << (cs.head_branch ? *cs.head_branch : "null") << ", head_sha: " << cs.head_sha; return os; @@ -208,37 +213,61 @@ namespace brep { p.next_expect (event::begin_object); - bool l (false), r (false), s (false); + bool r (false), s (false), rp (false), fn (false); while (p.next_expect (event::name, event::end_object)) { - if (c (l, "label")) base_label = p.next_expect_string (); - else if (c (r, "ref")) base_ref = p.next_expect_string (); + if (c (r, "ref")) base_ref = p.next_expect_string (); else if (c (s, "sha")) base_sha = p.next_expect_string (); + else if (c (rp, "repo")) + { + p.next_expect (event::begin_object); + + while (p.next_expect (event::name, event::end_object)) + { + if (c (fn, "full_name")) + base_path = p.next_expect_string (); + else + p.next_expect_value_skip (); + } + } else p.next_expect_value_skip (); } - if (!l) missing_member (p, "gh_pull_request.base", "label"); - if (!r) missing_member (p, "gh_pull_request.base", "ref"); - if (!s) missing_member (p, "gh_pull_request.base", "sha"); + if (!r) missing_member (p, "gh_pull_request.base", "ref"); + if (!s) missing_member (p, "gh_pull_request.base", "sha"); + if (!rp) missing_member (p, "gh_pull_request.base", "repo"); + if (!fn) missing_member (p, "gh_pull_request.base.repo", "full_name"); } else if (c (hd, "head")) { p.next_expect (event::begin_object); - bool l (false), r (false), s (false); + bool r (false), s (false), rp (false), fn (false); while (p.next_expect (event::name, event::end_object)) { - if (c (l, "label")) head_label = p.next_expect_string (); - else if (c (r, "ref")) head_ref = p.next_expect_string (); + if (c (r, "ref")) head_ref = p.next_expect_string (); else if (c (s, "sha")) head_sha = p.next_expect_string (); + else if (c (rp, "repo")) + { + p.next_expect (event::begin_object); + + while (p.next_expect (event::name, event::end_object)) + { + if (c (fn, "full_name")) + head_path = p.next_expect_string (); + else + p.next_expect_value_skip (); + } + } else p.next_expect_value_skip (); } - if (!l) missing_member (p, "gh_pull_request.head", "label"); - if (!r) missing_member (p, "gh_pull_request.head", "ref"); - if (!s) missing_member (p, "gh_pull_request.head", "sha"); + if (!r) missing_member (p, "gh_pull_request.head", "ref"); + if (!s) missing_member (p, "gh_pull_request.head", "sha"); + if (!rp) missing_member (p, "gh_pull_request.head", "repo"); + if (!fn) missing_member (p, "gh_pull_request.head.repo", "full_name"); } else p.next_expect_value_skip (); } @@ -265,12 +294,12 @@ namespace brep : "null") << ", merge_commit_sha:" << pr.merge_commit_sha << ", base: { " - << "label: " << pr.base_label + << "path: " << pr.base_path << ", ref: " << pr.base_ref << ", sha: " << pr.base_sha << " }" << ", head: { " - << "label: " << pr.head_label + << "path: " << pr.head_path << ", ref: " << pr.head_ref << ", sha: " << pr.head_sha << " }"; @@ -298,7 +327,7 @@ namespace brep if (c (ni, "node_id")) node_id = p.next_expect_string (); else if (c (nm, "name")) name = p.next_expect_string (); - else if (c (fn, "full_name")) full_name = p.next_expect_string (); + else if (c (fn, "full_name")) path = p.next_expect_string (); else if (c (db, "default_branch")) default_branch = p.next_expect_string (); else if (c (cu, "clone_url")) clone_url = p.next_expect_string (); else p.next_expect_value_skip (); @@ -316,7 +345,7 @@ namespace brep { os << "node_id: " << rep.node_id << ", name: " << rep.name - << ", full_name: " << rep.full_name + << ", path: " << rep.path << ", default_branch: " << rep.default_branch << ", clone_url: " << rep.clone_url; |