From fa217f752da66f7dc054e2c0bdc2bcc3d3e680e1 Mon Sep 17 00:00:00 2001 From: Jean Privat Date: Thu, 25 Aug 2016 21:33:05 -0400 Subject: [PATCH] github_merge: use combined status (and be more useful) Signed-off-by: Jean Privat --- contrib/github_merge.nit | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/contrib/github_merge.nit b/contrib/github_merge.nit index e71409f..89127cf 100644 --- a/contrib/github_merge.nit +++ b/contrib/github_merge.nit @@ -36,7 +36,8 @@ redef class GithubCurl var pr = get_and_check("https://api.github.com/repos/{repo}/pulls/{number}") var prm = pr.json_as_map var sha = prm["head"].json_as_map["sha"].to_s - var statuses = get_and_check("https://api.github.com/repos/{repo}/statuses/{sha}") + var statuses = get_and_check("https://api.github.com/repos/{repo}/commits/{sha}/status") + statuses = statuses.json_as_map prm["statuses"] = statuses print "{prm["title"].to_s}: by {prm["user"].json_as_map["login"].to_s} (# {prm["number"].to_s})" var mergeable = prm["mergeable"] @@ -45,11 +46,18 @@ redef class GithubCurl else print "\tmergeable: unknown" end - var st = prm["statuses"].json_as_a - if not st.is_empty then - print "\tstatus: {st[0].json_as_map["state"].to_s}" - else + var state = statuses["state"] + if state == null then print "\tstatus: not tested" + else + print "\tstatus: {state}" + var sts = statuses["statuses"].json_as_a + for st in sts do + st = st.json_as_map + var ctx = st["context"].to_s + state = st["state"].to_s + print "\tstatus {ctx}: {state}" + end end return prm end -- 1.7.9.5