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 f5499af

Browse filesBrowse files
committed
code changes to fix hub4j#1243
1 parent d46bca7 commit f5499af
Copy full SHA for f5499af

File tree

Expand file treeCollapse file tree

5 files changed

+859
-0
lines changed
Filter options
Expand file treeCollapse file tree

5 files changed

+859
-0
lines changed
+40Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
package org.kohsuke.github;
2+
3+
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
4+
5+
/**
6+
* Wrapper for changes on issue and pull request review comments action="edited"
7+
*
8+
* @see GHEventPayload.IssueComment
9+
* @see GHEventPayload.PullRequestReviewComment
10+
*/
11+
@SuppressFBWarnings(value = "UWF_UNWRITTEN_FIELD", justification = "JSON API")
12+
public class GHCommentChanges {
13+
14+
private GHFrom body;
15+
16+
/**
17+
* Gets the previous comment body.
18+
*
19+
* @return previous comment body (or null if not changed)
20+
*/
21+
public GHFrom getBody() {
22+
return body;
23+
}
24+
25+
/**
26+
* Wrapper for changed values.
27+
*/
28+
public static class GHFrom {
29+
private String from;
30+
31+
/**
32+
* Previous comment value that was changed.
33+
*
34+
* @return previous value
35+
*/
36+
public String getFrom() {
37+
return from;
38+
}
39+
}
40+
}

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

Copy file name to clipboardExpand all lines: src/main/java/org/kohsuke/github/GHEventPayload.java
+20Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -473,6 +473,7 @@ void lateBind() {
473473
public static class PullRequestReviewComment extends GHEventPayload {
474474
private GHPullRequestReviewComment comment;
475475
private GHPullRequest pullRequest;
476+
private GHCommentChanges changes;
476477

477478
/**
478479
* Gets comment.
@@ -484,6 +485,15 @@ public GHPullRequestReviewComment getComment() {
484485
return comment;
485486
}
486487

488+
/**
489+
* Get changes (for action="edited")
490+
*
491+
* @return changes
492+
*/
493+
public GHCommentChanges getChanges() {
494+
return changes;
495+
}
496+
487497
/**
488498
* Gets pull request.
489499
*
@@ -587,6 +597,7 @@ void lateBind() {
587597
public static class IssueComment extends GHEventPayload {
588598
private GHIssueComment comment;
589599
private GHIssue issue;
600+
private GHCommentChanges changes;
590601

591602
/**
592603
* Gets comment.
@@ -598,6 +609,15 @@ public GHIssueComment getComment() {
598609
return comment;
599610
}
600611

612+
/**
613+
* Get changes (for action="edited")
614+
*
615+
* @return changes
616+
*/
617+
public GHCommentChanges getChanges() {
618+
return changes;
619+
}
620+
601621
/**
602622
* Sets comment.
603623
*

‎src/test/java/org/kohsuke/github/GHEventPayloadTest.java

Copy file name to clipboardExpand all lines: src/test/java/org/kohsuke/github/GHEventPayloadTest.java
+19Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,15 @@ public void issue_comment() throws Exception {
156156
assertThrows(RuntimeException.class, () -> event.setIssue(null));
157157
}
158158

159+
@Test
160+
public void issue_comment_edited() throws Exception {
161+
final GHEventPayload.IssueComment event = GitHub.offline()
162+
.parseEventPayload(payload.asReader(), GHEventPayload.IssueComment.class);
163+
assertThat(event.getAction(), is("edited"));
164+
assertThat(event.getComment().getBody(), is("This is the issue comment AFTER edit."));
165+
assertThat(event.getChanges().getBody().getFrom(), is("This is the issue comment BEFORE edit."));
166+
}
167+
159168
@Test
160169
public void issues() throws Exception {
161170
final GHEventPayload.Issue event = GitHub.offline()
@@ -426,6 +435,16 @@ public void pull_request_review_comment() throws Exception {
426435
assertThat(event.getComment().getParent(), sameInstance(event.getPullRequest()));
427436
}
428437

438+
@Test
439+
public void pull_request_review_comment_edited() throws Exception {
440+
final GHEventPayload.PullRequestReviewComment event = GitHub.offline()
441+
.parseEventPayload(payload.asReader(), GHEventPayload.PullRequestReviewComment.class);
442+
assertThat(event.getAction(), is("edited"));
443+
assertThat(event.getPullRequest().getNumber(), is(4));
444+
assertThat(event.getComment().getBody(), is("This is the pull request review comment AFTER edit."));
445+
assertThat(event.getChanges().getBody().getFrom(), is("This is the pull request review comment BEFORE edit."));
446+
}
447+
429448
@Test
430449
public void push() throws Exception {
431450
final GHEventPayload.Push event = GitHub.offline()
+235Lines changed: 235 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,235 @@
1+
{
2+
"action": "edited",
3+
"changes": {
4+
"body": {
5+
"from": "This is the issue comment BEFORE edit."
6+
}
7+
},
8+
"issue": {
9+
"url": "https://api.github.com/repos/willtsai/githubapi-testrepo/issues/1",
10+
"repository_url": "https://api.github.com/repos/willtsai/githubapi-testrepo",
11+
"labels_url": "https://api.github.com/repos/willtsai/githubapi-testrepo/issues/1/labels{/name}",
12+
"comments_url": "https://api.github.com/repos/willtsai/githubapi-testrepo/issues/1/comments",
13+
"events_url": "https://api.github.com/repos/willtsai/githubapi-testrepo/issues/1/events",
14+
"html_url": "https://github.com/willtsai/githubapi-testrepo/issues/1",
15+
"id": 1058100040,
16+
"node_id": "I_kwDOGZwfHs4_EVNI",
17+
"number": 1,
18+
"title": "Test Issue 1",
19+
"user": {
20+
"login": "willtsai",
21+
"id": 28876888,
22+
"node_id": "MDQ6VXNlcjI4ODc2ODg4",
23+
"avatar_url": "https://avatars.githubusercontent.com/u/28876888?v=4",
24+
"gravatar_id": "",
25+
"url": "https://api.github.com/users/willtsai",
26+
"html_url": "https://github.com/willtsai",
27+
"followers_url": "https://api.github.com/users/willtsai/followers",
28+
"following_url": "https://api.github.com/users/willtsai/following{/other_user}",
29+
"gists_url": "https://api.github.com/users/willtsai/gists{/gist_id}",
30+
"starred_url": "https://api.github.com/users/willtsai/starred{/owner}{/repo}",
31+
"subscriptions_url": "https://api.github.com/users/willtsai/subscriptions",
32+
"organizations_url": "https://api.github.com/users/willtsai/orgs",
33+
"repos_url": "https://api.github.com/users/willtsai/repos",
34+
"events_url": "https://api.github.com/users/willtsai/events{/privacy}",
35+
"received_events_url": "https://api.github.com/users/willtsai/received_events",
36+
"type": "User",
37+
"site_admin": false
38+
},
39+
"labels": [
40+
41+
],
42+
"state": "open",
43+
"locked": false,
44+
"assignee": null,
45+
"assignees": [
46+
47+
],
48+
"milestone": null,
49+
"comments": 1,
50+
"created_at": "2021-11-19T03:49:50Z",
51+
"updated_at": "2021-11-22T18:22:45Z",
52+
"closed_at": null,
53+
"author_association": "OWNER",
54+
"active_lock_reason": null,
55+
"body": "Test issue for solving https://github.com/hub4j/github-api/issues/1243",
56+
"reactions": {
57+
"url": "https://api.github.com/repos/willtsai/githubapi-testrepo/issues/1/reactions",
58+
"total_count": 0,
59+
"+1": 0,
60+
"-1": 0,
61+
"laugh": 0,
62+
"hooray": 0,
63+
"confused": 0,
64+
"heart": 0,
65+
"rocket": 0,
66+
"eyes": 0
67+
},
68+
"timeline_url": "https://api.github.com/repos/willtsai/githubapi-testrepo/issues/1/timeline",
69+
"performed_via_github_app": null
70+
},
71+
"comment": {
72+
"url": "https://api.github.com/repos/willtsai/githubapi-testrepo/issues/comments/973709263",
73+
"html_url": "https://github.com/willtsai/githubapi-testrepo/issues/1#issuecomment-973709263",
74+
"issue_url": "https://api.github.com/repos/willtsai/githubapi-testrepo/issues/1",
75+
"id": 973709263,
76+
"node_id": "IC_kwDOGZwfHs46CZ_P",
77+
"user": {
78+
"login": "willtsai",
79+
"id": 28876888,
80+
"node_id": "MDQ6VXNlcjI4ODc2ODg4",
81+
"avatar_url": "https://avatars.githubusercontent.com/u/28876888?v=4",
82+
"gravatar_id": "",
83+
"url": "https://api.github.com/users/willtsai",
84+
"html_url": "https://github.com/willtsai",
85+
"followers_url": "https://api.github.com/users/willtsai/followers",
86+
"following_url": "https://api.github.com/users/willtsai/following{/other_user}",
87+
"gists_url": "https://api.github.com/users/willtsai/gists{/gist_id}",
88+
"starred_url": "https://api.github.com/users/willtsai/starred{/owner}{/repo}",
89+
"subscriptions_url": "https://api.github.com/users/willtsai/subscriptions",
90+
"organizations_url": "https://api.github.com/users/willtsai/orgs",
91+
"repos_url": "https://api.github.com/users/willtsai/repos",
92+
"events_url": "https://api.github.com/users/willtsai/events{/privacy}",
93+
"received_events_url": "https://api.github.com/users/willtsai/received_events",
94+
"type": "User",
95+
"site_admin": false
96+
},
97+
"created_at": "2021-11-19T03:50:11Z",
98+
"updated_at": "2021-11-22T18:22:45Z",
99+
"author_association": "OWNER",
100+
"body": "This is the issue comment AFTER edit.",
101+
"reactions": {
102+
"url": "https://api.github.com/repos/willtsai/githubapi-testrepo/issues/comments/973709263/reactions",
103+
"total_count": 0,
104+
"+1": 0,
105+
"-1": 0,
106+
"laugh": 0,
107+
"hooray": 0,
108+
"confused": 0,
109+
"heart": 0,
110+
"rocket": 0,
111+
"eyes": 0
112+
},
113+
"performed_via_github_app": null
114+
},
115+
"repository": {
116+
"id": 429661982,
117+
"node_id": "R_kgDOGZwfHg",
118+
"name": "githubapi-testrepo",
119+
"full_name": "willtsai/githubapi-testrepo",
120+
"private": false,
121+
"owner": {
122+
"login": "willtsai",
123+
"id": 28876888,
124+
"node_id": "MDQ6VXNlcjI4ODc2ODg4",
125+
"avatar_url": "https://avatars.githubusercontent.com/u/28876888?v=4",
126+
"gravatar_id": "",
127+
"url": "https://api.github.com/users/willtsai",
128+
"html_url": "https://github.com/willtsai",
129+
"followers_url": "https://api.github.com/users/willtsai/followers",
130+
"following_url": "https://api.github.com/users/willtsai/following{/other_user}",
131+
"gists_url": "https://api.github.com/users/willtsai/gists{/gist_id}",
132+
"starred_url": "https://api.github.com/users/willtsai/starred{/owner}{/repo}",
133+
"subscriptions_url": "https://api.github.com/users/willtsai/subscriptions",
134+
"organizations_url": "https://api.github.com/users/willtsai/orgs",
135+
"repos_url": "https://api.github.com/users/willtsai/repos",
136+
"events_url": "https://api.github.com/users/willtsai/events{/privacy}",
137+
"received_events_url": "https://api.github.com/users/willtsai/received_events",
138+
"type": "User",
139+
"site_admin": false
140+
},
141+
"html_url": "https://github.com/willtsai/githubapi-testrepo",
142+
"description": null,
143+
"fork": false,
144+
"url": "https://api.github.com/repos/willtsai/githubapi-testrepo",
145+
"forks_url": "https://api.github.com/repos/willtsai/githubapi-testrepo/forks",
146+
"keys_url": "https://api.github.com/repos/willtsai/githubapi-testrepo/keys{/key_id}",
147+
"collaborators_url": "https://api.github.com/repos/willtsai/githubapi-testrepo/collaborators{/collaborator}",
148+
"teams_url": "https://api.github.com/repos/willtsai/githubapi-testrepo/teams",
149+
"hooks_url": "https://api.github.com/repos/willtsai/githubapi-testrepo/hooks",
150+
"issue_events_url": "https://api.github.com/repos/willtsai/githubapi-testrepo/issues/events{/number}",
151+
"events_url": "https://api.github.com/repos/willtsai/githubapi-testrepo/events",
152+
"assignees_url": "https://api.github.com/repos/willtsai/githubapi-testrepo/assignees{/user}",
153+
"branches_url": "https://api.github.com/repos/willtsai/githubapi-testrepo/branches{/branch}",
154+
"tags_url": "https://api.github.com/repos/willtsai/githubapi-testrepo/tags",
155+
"blobs_url": "https://api.github.com/repos/willtsai/githubapi-testrepo/git/blobs{/sha}",
156+
"git_tags_url": "https://api.github.com/repos/willtsai/githubapi-testrepo/git/tags{/sha}",
157+
"git_refs_url": "https://api.github.com/repos/willtsai/githubapi-testrepo/git/refs{/sha}",
158+
"trees_url": "https://api.github.com/repos/willtsai/githubapi-testrepo/git/trees{/sha}",
159+
"statuses_url": "https://api.github.com/repos/willtsai/githubapi-testrepo/statuses/{sha}",
160+
"languages_url": "https://api.github.com/repos/willtsai/githubapi-testrepo/languages",
161+
"stargazers_url": "https://api.github.com/repos/willtsai/githubapi-testrepo/stargazers",
162+
"contributors_url": "https://api.github.com/repos/willtsai/githubapi-testrepo/contributors",
163+
"subscribers_url": "https://api.github.com/repos/willtsai/githubapi-testrepo/subscribers",
164+
"subscription_url": "https://api.github.com/repos/willtsai/githubapi-testrepo/subscription",
165+
"commits_url": "https://api.github.com/repos/willtsai/githubapi-testrepo/commits{/sha}",
166+
"git_commits_url": "https://api.github.com/repos/willtsai/githubapi-testrepo/git/commits{/sha}",
167+
"comments_url": "https://api.github.com/repos/willtsai/githubapi-testrepo/comments{/number}",
168+
"issue_comment_url": "https://api.github.com/repos/willtsai/githubapi-testrepo/issues/comments{/number}",
169+
"contents_url": "https://api.github.com/repos/willtsai/githubapi-testrepo/contents/{+path}",
170+
"compare_url": "https://api.github.com/repos/willtsai/githubapi-testrepo/compare/{base}...{head}",
171+
"merges_url": "https://api.github.com/repos/willtsai/githubapi-testrepo/merges",
172+
"archive_url": "https://api.github.com/repos/willtsai/githubapi-testrepo/{archive_format}{/ref}",
173+
"downloads_url": "https://api.github.com/repos/willtsai/githubapi-testrepo/downloads",
174+
"issues_url": "https://api.github.com/repos/willtsai/githubapi-testrepo/issues{/number}",
175+
"pulls_url": "https://api.github.com/repos/willtsai/githubapi-testrepo/pulls{/number}",
176+
"milestones_url": "https://api.github.com/repos/willtsai/githubapi-testrepo/milestones{/number}",
177+
"notifications_url": "https://api.github.com/repos/willtsai/githubapi-testrepo/notifications{?since,all,participating}",
178+
"labels_url": "https://api.github.com/repos/willtsai/githubapi-testrepo/labels{/name}",
179+
"releases_url": "https://api.github.com/repos/willtsai/githubapi-testrepo/releases{/id}",
180+
"deployments_url": "https://api.github.com/repos/willtsai/githubapi-testrepo/deployments",
181+
"created_at": "2021-11-19T03:48:57Z",
182+
"updated_at": "2021-11-19T03:48:57Z",
183+
"pushed_at": "2021-11-19T03:48:58Z",
184+
"git_url": "git://github.com/willtsai/githubapi-testrepo.git",
185+
"ssh_url": "git@github.com:willtsai/githubapi-testrepo.git",
186+
"clone_url": "https://github.com/willtsai/githubapi-testrepo.git",
187+
"svn_url": "https://github.com/willtsai/githubapi-testrepo",
188+
"homepage": null,
189+
"size": 0,
190+
"stargazers_count": 0,
191+
"watchers_count": 0,
192+
"language": null,
193+
"has_issues": true,
194+
"has_projects": true,
195+
"has_downloads": true,
196+
"has_wiki": true,
197+
"has_pages": false,
198+
"forks_count": 0,
199+
"mirror_url": null,
200+
"archived": false,
201+
"disabled": false,
202+
"open_issues_count": 2,
203+
"license": null,
204+
"allow_forking": true,
205+
"is_template": false,
206+
"topics": [
207+
208+
],
209+
"visibility": "public",
210+
"forks": 0,
211+
"open_issues": 2,
212+
"watchers": 0,
213+
"default_branch": "main"
214+
},
215+
"sender": {
216+
"login": "willtsai",
217+
"id": 28876888,
218+
"node_id": "MDQ6VXNlcjI4ODc2ODg4",
219+
"avatar_url": "https://avatars.githubusercontent.com/u/28876888?v=4",
220+
"gravatar_id": "",
221+
"url": "https://api.github.com/users/willtsai",
222+
"html_url": "https://github.com/willtsai",
223+
"followers_url": "https://api.github.com/users/willtsai/followers",
224+
"following_url": "https://api.github.com/users/willtsai/following{/other_user}",
225+
"gists_url": "https://api.github.com/users/willtsai/gists{/gist_id}",
226+
"starred_url": "https://api.github.com/users/willtsai/starred{/owner}{/repo}",
227+
"subscriptions_url": "https://api.github.com/users/willtsai/subscriptions",
228+
"organizations_url": "https://api.github.com/users/willtsai/orgs",
229+
"repos_url": "https://api.github.com/users/willtsai/repos",
230+
"events_url": "https://api.github.com/users/willtsai/events{/privacy}",
231+
"received_events_url": "https://api.github.com/users/willtsai/received_events",
232+
"type": "User",
233+
"site_admin": false
234+
}
235+
}

0 commit comments

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