Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 4daf6ba

Browse filesBrowse files
committed
Add offline support to the API to make parsing events easier
- When we receive events from a webhook, it is non-trivial to determine which GitHub instance the event came from or for that matter even if the event actually came from GitHub or GitHub Enterprise. - In order to ensure that the logic for parsing events does not get replicated in clients, we need to be able to call GitHub.parseEventPayload(Reader,Class) without knowing which GitHub the event originates from and without the resulting objects triggering API calls back to a GitHub - Thus we add GitHub.offline() to provide an off-line connection - Thus we modify some of the object classes to return best-effort objects when off-line - Add support for more of the event types into GHEventPayload - Add tests of the event payload and accessing critical fields when using GitHub.offline()
1 parent fa3d088 commit 4daf6ba
Copy full SHA for 4daf6ba
Expand file treeCollapse file tree

36 files changed

+5022
-8
lines changed

‎src/main/java/org/kohsuke/github/GHCommitComment.java

Copy file name to clipboardExpand all lines: src/main/java/org/kohsuke/github/GHCommitComment.java
+5-2Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ public class GHCommitComment extends GHObject {
2121
String body, html_url, commit_id;
2222
Integer line;
2323
String path;
24-
User user;
24+
GHUser user; // not fully populated. beware.
2525

2626
static class User {
2727
// TODO: what if someone who doesn't have an account on GitHub makes a commit?
@@ -76,7 +76,7 @@ public int getLine() {
7676
* Gets the user who put this comment.
7777
*/
7878
public GHUser getUser() throws IOException {
79-
return owner.root.getUser(user.login);
79+
return owner == null || owner.root.isOffline() ? user : owner.root.getUser(user.login);
8080
}
8181

8282
/**
@@ -110,6 +110,9 @@ private String getApiTail() {
110110

111111
GHCommitComment wrap(GHRepository owner) {
112112
this.owner = owner;
113+
if (owner.root.isOffline()) {
114+
user.wrapUp(owner.root);
115+
}
113116
return this;
114117
}
115118
}

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.