github_merge: do not crash if the mergeable status is unknown
authorJean Privat <jean@pryen.org>
Thu, 5 Feb 2015 06:59:35 +0000 (13:59 +0700)
committerJean Privat <jean@pryen.org>
Thu, 5 Feb 2015 06:59:35 +0000 (13:59 +0700)
Signed-off-by: Jean Privat <jean@pryen.org>

contrib/github_merge.nit

index 712c1e7..30d54f0 100644 (file)
@@ -35,7 +35,12 @@ redef class GithubCurl
                var statuses = get_and_check("https://api.github.com/repos/privat/nit/statuses/{sha}")
                prm["statuses"] = statuses
                print "{prm["title"].to_s}: by {prm["user"].json_as_map["login"].to_s} (# {prm["number"].to_s})"
-               print "\tmergable: {prm["mergeable"].to_s}"
+               var mergeable = prm["mergeable"]
+               if mergeable != null then
+                       print "\tmergeable: {mergeable.to_s}"
+               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}"