Skip to content

Commit

Permalink
Merge pull request #306 from stephenc/offline-support
Browse files Browse the repository at this point in the history
Add offline support to the API to make parsing events easier
  • Loading branch information
kohsuke committed Nov 17, 2016
2 parents 24f48f6 + e544c7a commit d1378a0
Show file tree
Hide file tree
Showing 36 changed files with 5,116 additions and 37 deletions.
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

0 comments on commit d1378a0

Please sign in to comment.