lib/github: fix deserialization of empty branch arrays
authorAlexandre Terrasa <alexandre@moz-code.org>
Mon, 20 Feb 2017 18:49:31 +0000 (13:49 -0500)
committerAlexandre Terrasa <alexandre@moz-code.org>
Mon, 20 Feb 2017 18:50:17 +0000 (13:50 -0500)
Signed-off-by: Alexandre Terrasa <alexandre@moz-code.org>

lib/github/api.nit

index c94031e..17de935 100644 (file)
@@ -200,7 +200,9 @@ class GithubAPI
                var array = get("/repos/{repo.full_name}/branches")
                var res = new Array[Branch]
                if not array isa JsonArray then return res
-               return deserialize(array.to_json).as(Array[Branch])
+               var deser = deserialize(array.to_json)
+               if deser isa Array[Object] then return res # empty array
+               return deser.as(Array[Branch])
        end
 
        # List of issues associated with their ids.