Compare commits

..

8 Commits

Author SHA1 Message Date
Kohsuke Kawaguchi
dcaf926a95 [maven-release-plugin] prepare release github-api-1.31 2012-08-28 11:02:59 -07:00
Honza Brázdil
587278f282 we need to maintain the binary compatibility, so I reverted getComments and added listComments that exposes PagedIterable.
inspired by 8f95c4f179
2012-08-28 19:09:18 +02:00
Honza Brázdil
cc3793cbcd Comments are paged 2012-08-28 18:59:09 +02:00
Honza Brázdil
c268a5dd07 removed unused throws statement 2012-08-28 18:59:09 +02:00
Honza Brázdil
58d10df5e3 Fix GHIssue.getState() No enum constant 2012-08-28 18:59:09 +02:00
Honza Brázdil
ae2d01a878 fix GHPullRequest.getLabels() NPE 2012-08-28 18:59:09 +02:00
Honza Brázdil
dbc5b0b742 user is not just username; added url 2012-08-28 18:59:09 +02:00
Kohsuke Kawaguchi
6af12c2335 [maven-release-plugin] prepare for next development iteration 2012-08-28 09:43:22 -07:00
4 changed files with 39 additions and 12 deletions

View File

@@ -7,7 +7,7 @@
</parent>
<artifactId>github-api</artifactId>
<version>1.30</version>
<version>1.31</version>
<name>GitHub API for Java</name>
<url>http://github-api.kohsuke.org/</url>
<description>GitHub API for Java</description>

View File

@@ -31,6 +31,7 @@ import java.util.Collection;
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 class GHIssue {
}
public GHIssueState getState() {
return Enum.valueOf(GHIssueState.class, state);
return Enum.valueOf(GHIssueState.class, state.toUpperCase(Locale.ENGLISH));
}
public Collection<String> getLabels() {
if(labels == null){
return Collections.EMPTY_LIST;
}
return Collections.unmodifiableList(labels);
}
@@ -152,12 +156,27 @@ public class GHIssue {
/**
* Obtains all the comments associated with this issue.
*
* @see #listComments()
*/
public List<GHIssueComment> getComments() throws IOException {
GHIssueComment[] r = root.retrieve(getApiRoute() + "/comments", GHIssueComment[].class);
for (GHIssueComment c : r)
c.wrapUp(this);
return Arrays.asList(r);
public List<GHIssueComment> getComments() throws IOException {
return listComments().asList();
}
/**
* Obtains all the comments associated with this issue.
*/
public PagedIterable<GHIssueComment> listComments() throws IOException {
return new PagedIterable<GHIssueComment>() {
public PagedIterator<GHIssueComment> iterator() {
return new PagedIterator<GHIssueComment>(root.retrievePaged(getApiRoute() + "/comments",GHIssueComment[].class,false)) {
protected void wrapUp(GHIssueComment[] page) {
for (GHIssueComment c : page)
c.wrapUp(GHIssue.this);
}
};
}
};
}
private String getApiRoute() {

View File

@@ -24,6 +24,7 @@
package org.kohsuke.github;
import java.io.IOException;
import java.net.URL;
import java.util.Date;
/**
@@ -34,8 +35,10 @@ import java.util.Date;
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 class GHIssueComment {
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());
}
}

View File

@@ -129,11 +129,11 @@ public class GitHub {
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);
}