Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add offline support to the API to make parsing events easier #306

Merged
merged 10 commits into from
Nov 17, 2016
17 changes: 5 additions & 12 deletions src/main/java/org/kohsuke/github/GHCommitComment.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,17 +21,7 @@ public class GHCommitComment extends GHObject {
String body, html_url, commit_id;
Integer line;
String path;
User user;

static class User {
// TODO: what if someone who doesn't have an account on GitHub makes a commit?
@SuppressFBWarnings(value = "UUF_UNUSED_FIELD", justification = "We don't provide it in API now")
String url,avatar_url,gravatar_id;
@SuppressFBWarnings(value = "UUF_UNUSED_FIELD", justification = "We don't provide it in API now")
int id;

String login;
}
GHUser user; // not fully populated. beware.

public GHRepository getOwner() {
return owner;
Expand Down Expand Up @@ -76,7 +66,7 @@ public int getLine() {
* Gets the user who put this comment.
*/
public GHUser getUser() throws IOException {
return owner.root.getUser(user.login);
return owner == null || owner.root.isOffline() ? user : owner.root.getUser(user.login);
}

/**
Expand Down Expand Up @@ -110,6 +100,9 @@ private String getApiTail() {

GHCommitComment wrap(GHRepository owner) {
this.owner = owner;
if (owner.root.isOffline()) {
user.wrapUp(owner.root);
}
return this;
}
}
Loading