diff --git a/pom.xml b/pom.xml index 965f1b2294..7d5af32649 100644 --- a/pom.xml +++ b/pom.xml @@ -7,7 +7,7 @@ github-api - 1.30 + 1.31 GitHub API for Java http://github-api.kohsuke.org/ GitHub API for Java diff --git a/src/main/java/org/kohsuke/github/GHIssue.java b/src/main/java/org/kohsuke/github/GHIssue.java index 961f27edca..3224e76f29 100644 --- a/src/main/java/org/kohsuke/github/GHIssue.java +++ b/src/main/java/org/kohsuke/github/GHIssue.java @@ -31,6 +31,7 @@ import java.util.Collections; import java.util.Date; import java.util.List; +import java.util.Locale; /** * Represents an issue on GitHub. @@ -93,10 +94,13 @@ public String getTitle() { } public GHIssueState getState() { - return Enum.valueOf(GHIssueState.class, state); + return Enum.valueOf(GHIssueState.class, state.toUpperCase(Locale.ENGLISH)); } public Collection getLabels() { + if(labels == null){ + return Collections.EMPTY_LIST; + } return Collections.unmodifiableList(labels); } @@ -152,12 +156,27 @@ public void setLabels(String... labels) throws IOException { /** * Obtains all the comments associated with this issue. + * + * @see #listComments() */ - public List getComments() throws IOException { - GHIssueComment[] r = root.retrieve(getApiRoute() + "/comments", GHIssueComment[].class); - for (GHIssueComment c : r) - c.wrapUp(this); - return Arrays.asList(r); + public List getComments() throws IOException { + return listComments().asList(); + } + + /** + * Obtains all the comments associated with this issue. + */ + public PagedIterable listComments() throws IOException { + return new PagedIterable() { + public PagedIterator iterator() { + return new PagedIterator(root.retrievePaged(getApiRoute() + "/comments",GHIssueComment[].class,false)) { + protected void wrapUp(GHIssueComment[] page) { + for (GHIssueComment c : page) + c.wrapUp(GHIssue.this); + } + }; + } + }; } private String getApiRoute() { diff --git a/src/main/java/org/kohsuke/github/GHIssueComment.java b/src/main/java/org/kohsuke/github/GHIssueComment.java index 9dd96896a1..e8a700cdfb 100644 --- a/src/main/java/org/kohsuke/github/GHIssueComment.java +++ b/src/main/java/org/kohsuke/github/GHIssueComment.java @@ -24,6 +24,7 @@ package org.kohsuke.github; import java.io.IOException; +import java.net.URL; import java.util.Date; /** @@ -34,8 +35,10 @@ public class GHIssueComment { GHIssue owner; - private String body, gravatar_id, user, created_at, updated_at; + private String body, gravatar_id, created_at, updated_at; + private URL url; private int id; + private GHUser user; /*package*/ GHIssueComment wrapUp(GHIssue owner) { this.owner = owner; @@ -68,17 +71,22 @@ public int getId() { return id; } + public URL getUrl() { + return url; + } + /** * Gets the ID of the user who posted this comment. */ + @Deprecated public String getUserName() { - return user; + return user.getLogin(); } /** * Gets the user who posted this comment. */ public GHUser getUser() throws IOException { - return owner.root.getUser(user); + return owner.root.getUser(user.getLogin()); } } diff --git a/src/main/java/org/kohsuke/github/GitHub.java b/src/main/java/org/kohsuke/github/GitHub.java index 9f8d1df240..5893de9c41 100644 --- a/src/main/java/org/kohsuke/github/GitHub.java +++ b/src/main/java/org/kohsuke/github/GitHub.java @@ -129,11 +129,11 @@ public static GitHub connect() throws IOException { return new GitHub(props.getProperty("login"),props.getProperty("token"),props.getProperty("password")); } - public static GitHub connect(String login, String apiToken) throws IOException { + public static GitHub connect(String login, String apiToken){ return new GitHub(login,apiToken,null); } - public static GitHub connect(String login, String apiToken, String password) throws IOException { + public static GitHub connect(String login, String apiToken, String password){ return new GitHub(login,apiToken,password); }