X-Git-Url: http://nitlanguage.org diff --git a/lib/github/api.nit b/lib/github/api.nit index 782d598..ea516fa 100644 --- a/lib/github/api.nit +++ b/lib/github/api.nit @@ -344,6 +344,9 @@ abstract class GithubEntity end redef fun to_s do return json.to_json + + # Github page url. + fun html_url: String do return json["html_url"].to_s end # A Github user. @@ -365,9 +368,6 @@ class User self.json = json end - # Github User page url. - fun html_url: String do return json["html_url"].to_s - # Avatar image url for this user. fun avatar_url: String do return json["avatar_url"].to_s end @@ -394,9 +394,6 @@ class Repo # Repo short name on Github. fun name: String do return json["name"].to_s - # Github User page url. - fun html_url: String do return json["html_url"].to_s - # Get the repo owner. fun owner: User do return new User.from_json(api, json["owner"].as(JsonObject)) @@ -431,6 +428,27 @@ class Repo return res end + # Search issues in this repo form an advanced query. + # + # Example: + # + # ~~~nitish + # var issues = repo.search_issues("is:open label:need_review") + # ~~~ + # + # See . + fun search_issues(query: String): nullable Array[Issue] do + query = "search/issues?q={query} repo:{full_name}" + var response = api.get(query) + if api.was_error then return null + var arr = response.as(JsonObject)["items"].as(JsonArray) + var res = new Array[Issue] + for obj in arr do + res.add new Issue.from_json(api, self, obj.as(JsonObject)) + end + return res + end + # Get the last published issue. fun last_issue: nullable Issue do var array = api.get("repos/{full_name}/issues") @@ -678,6 +696,7 @@ class Issue # List of labels on this issue associated to their names. fun labels: Map[String, Label] do var res = new HashMap[String, Label] + if not json.has_key("labels") then return res for obj in json["labels"].as(JsonArray) do if not obj isa JsonObject then continue var name = obj["name"].to_s