Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
57 changes: 57 additions & 0 deletions src/main/java/org/kohsuke/github/GHEventPayload.java
Original file line number Diff line number Diff line change
Expand Up @@ -462,6 +462,43 @@ void lateBind() {
}
}

/**
* Wrapper for changes on issue and pull request review comments action="edited"
*
* @see GHEventPayload.IssueComment
* @see GHEventPayload.PullRequestReviewComment
*/
@SuppressFBWarnings(value = "UWF_UNWRITTEN_FIELD", justification = "JSON API")
public static class CommentChanges {

private GHFrom body;

/**
* Gets the previous comment body.
*
* @return previous comment body (or null if not changed)
*/
public GHFrom getBody() {
return body;
}

/**
* Wrapper for changed values.
*/
public static class GHFrom {
private String from;

/**
* Previous comment value that was changed.
*
* @return previous value
*/
public String getFrom() {
return from;
}
}
}

/**
* A review comment was added to a pull request
*
Expand All @@ -473,6 +510,7 @@ void lateBind() {
public static class PullRequestReviewComment extends GHEventPayload {
private GHPullRequestReviewComment comment;
private GHPullRequest pullRequest;
private CommentChanges changes;

/**
* Gets comment.
Expand All @@ -484,6 +522,15 @@ public GHPullRequestReviewComment getComment() {
return comment;
}

/**
* Get changes (for action="edited")
*
* @return changes
*/
public CommentChanges getChanges() {
return changes;
}

/**
* Gets pull request.
*
Expand Down Expand Up @@ -587,6 +634,7 @@ void lateBind() {
public static class IssueComment extends GHEventPayload {
private GHIssueComment comment;
private GHIssue issue;
private CommentChanges changes;

/**
* Gets comment.
Expand All @@ -598,6 +646,15 @@ public GHIssueComment getComment() {
return comment;
}

/**
* Get changes (for action="edited")
*
* @return changes
*/
public CommentChanges getChanges() {
return changes;
}

/**
* Sets comment.
*
Expand Down
19 changes: 19 additions & 0 deletions src/test/java/org/kohsuke/github/GHEventPayloadTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,15 @@ public void issue_comment() throws Exception {
assertThrows(RuntimeException.class, () -> event.setIssue(null));
}

@Test
public void issue_comment_edited() throws Exception {
final GHEventPayload.IssueComment event = GitHub.offline()
.parseEventPayload(payload.asReader(), GHEventPayload.IssueComment.class);
assertThat(event.getAction(), is("edited"));
assertThat(event.getComment().getBody(), is("This is the issue comment AFTER edit."));
assertThat(event.getChanges().getBody().getFrom(), is("This is the issue comment BEFORE edit."));
}

@Test
public void issues() throws Exception {
final GHEventPayload.Issue event = GitHub.offline()
Expand Down Expand Up @@ -426,6 +435,16 @@ public void pull_request_review_comment() throws Exception {
assertThat(event.getComment().getParent(), sameInstance(event.getPullRequest()));
}

@Test
public void pull_request_review_comment_edited() throws Exception {
final GHEventPayload.PullRequestReviewComment event = GitHub.offline()
.parseEventPayload(payload.asReader(), GHEventPayload.PullRequestReviewComment.class);
assertThat(event.getAction(), is("edited"));
assertThat(event.getPullRequest().getNumber(), is(4));
assertThat(event.getComment().getBody(), is("This is the pull request review comment AFTER edit."));
assertThat(event.getChanges().getBody().getFrom(), is("This is the pull request review comment BEFORE edit."));
}

@Test
public void push() throws Exception {
final GHEventPayload.Push event = GitHub.offline()
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,235 @@
{
"action": "edited",
"changes": {
"body": {
"from": "This is the issue comment BEFORE edit."
}
},
"issue": {
"url": "https://api.github.com/repos/willtsai/githubapi-testrepo/issues/1",
"repository_url": "https://api.github.com/repos/willtsai/githubapi-testrepo",
"labels_url": "https://api.github.com/repos/willtsai/githubapi-testrepo/issues/1/labels{/name}",
"comments_url": "https://api.github.com/repos/willtsai/githubapi-testrepo/issues/1/comments",
"events_url": "https://api.github.com/repos/willtsai/githubapi-testrepo/issues/1/events",
"html_url": "https://github.com/willtsai/githubapi-testrepo/issues/1",
"id": 1058100040,
"node_id": "I_kwDOGZwfHs4_EVNI",
"number": 1,
"title": "Test Issue 1",
"user": {
"login": "willtsai",
"id": 28876888,
"node_id": "MDQ6VXNlcjI4ODc2ODg4",
"avatar_url": "https://avatars.githubusercontent.com/u/28876888?v=4",
"gravatar_id": "",
"url": "https://api.github.com/users/willtsai",
"html_url": "https://github.com/willtsai",
"followers_url": "https://api.github.com/users/willtsai/followers",
"following_url": "https://api.github.com/users/willtsai/following{/other_user}",
"gists_url": "https://api.github.com/users/willtsai/gists{/gist_id}",
"starred_url": "https://api.github.com/users/willtsai/starred{/owner}{/repo}",
"subscriptions_url": "https://api.github.com/users/willtsai/subscriptions",
"organizations_url": "https://api.github.com/users/willtsai/orgs",
"repos_url": "https://api.github.com/users/willtsai/repos",
"events_url": "https://api.github.com/users/willtsai/events{/privacy}",
"received_events_url": "https://api.github.com/users/willtsai/received_events",
"type": "User",
"site_admin": false
},
"labels": [

],
"state": "open",
"locked": false,
"assignee": null,
"assignees": [

],
"milestone": null,
"comments": 1,
"created_at": "2021-11-19T03:49:50Z",
"updated_at": "2021-11-22T18:22:45Z",
"closed_at": null,
"author_association": "OWNER",
"active_lock_reason": null,
"body": "Test issue for solving https://github.com/hub4j/github-api/issues/1243",
"reactions": {
"url": "https://api.github.com/repos/willtsai/githubapi-testrepo/issues/1/reactions",
"total_count": 0,
"+1": 0,
"-1": 0,
"laugh": 0,
"hooray": 0,
"confused": 0,
"heart": 0,
"rocket": 0,
"eyes": 0
},
"timeline_url": "https://api.github.com/repos/willtsai/githubapi-testrepo/issues/1/timeline",
"performed_via_github_app": null
},
"comment": {
"url": "https://api.github.com/repos/willtsai/githubapi-testrepo/issues/comments/973709263",
"html_url": "https://github.com/willtsai/githubapi-testrepo/issues/1#issuecomment-973709263",
"issue_url": "https://api.github.com/repos/willtsai/githubapi-testrepo/issues/1",
"id": 973709263,
"node_id": "IC_kwDOGZwfHs46CZ_P",
"user": {
"login": "willtsai",
"id": 28876888,
"node_id": "MDQ6VXNlcjI4ODc2ODg4",
"avatar_url": "https://avatars.githubusercontent.com/u/28876888?v=4",
"gravatar_id": "",
"url": "https://api.github.com/users/willtsai",
"html_url": "https://github.com/willtsai",
"followers_url": "https://api.github.com/users/willtsai/followers",
"following_url": "https://api.github.com/users/willtsai/following{/other_user}",
"gists_url": "https://api.github.com/users/willtsai/gists{/gist_id}",
"starred_url": "https://api.github.com/users/willtsai/starred{/owner}{/repo}",
"subscriptions_url": "https://api.github.com/users/willtsai/subscriptions",
"organizations_url": "https://api.github.com/users/willtsai/orgs",
"repos_url": "https://api.github.com/users/willtsai/repos",
"events_url": "https://api.github.com/users/willtsai/events{/privacy}",
"received_events_url": "https://api.github.com/users/willtsai/received_events",
"type": "User",
"site_admin": false
},
"created_at": "2021-11-19T03:50:11Z",
"updated_at": "2021-11-22T18:22:45Z",
"author_association": "OWNER",
"body": "This is the issue comment AFTER edit.",
"reactions": {
"url": "https://api.github.com/repos/willtsai/githubapi-testrepo/issues/comments/973709263/reactions",
"total_count": 0,
"+1": 0,
"-1": 0,
"laugh": 0,
"hooray": 0,
"confused": 0,
"heart": 0,
"rocket": 0,
"eyes": 0
},
"performed_via_github_app": null
},
"repository": {
"id": 429661982,
"node_id": "R_kgDOGZwfHg",
"name": "githubapi-testrepo",
"full_name": "willtsai/githubapi-testrepo",
"private": false,
"owner": {
"login": "willtsai",
"id": 28876888,
"node_id": "MDQ6VXNlcjI4ODc2ODg4",
"avatar_url": "https://avatars.githubusercontent.com/u/28876888?v=4",
"gravatar_id": "",
"url": "https://api.github.com/users/willtsai",
"html_url": "https://github.com/willtsai",
"followers_url": "https://api.github.com/users/willtsai/followers",
"following_url": "https://api.github.com/users/willtsai/following{/other_user}",
"gists_url": "https://api.github.com/users/willtsai/gists{/gist_id}",
"starred_url": "https://api.github.com/users/willtsai/starred{/owner}{/repo}",
"subscriptions_url": "https://api.github.com/users/willtsai/subscriptions",
"organizations_url": "https://api.github.com/users/willtsai/orgs",
"repos_url": "https://api.github.com/users/willtsai/repos",
"events_url": "https://api.github.com/users/willtsai/events{/privacy}",
"received_events_url": "https://api.github.com/users/willtsai/received_events",
"type": "User",
"site_admin": false
},
"html_url": "https://github.com/willtsai/githubapi-testrepo",
"description": null,
"fork": false,
"url": "https://api.github.com/repos/willtsai/githubapi-testrepo",
"forks_url": "https://api.github.com/repos/willtsai/githubapi-testrepo/forks",
"keys_url": "https://api.github.com/repos/willtsai/githubapi-testrepo/keys{/key_id}",
"collaborators_url": "https://api.github.com/repos/willtsai/githubapi-testrepo/collaborators{/collaborator}",
"teams_url": "https://api.github.com/repos/willtsai/githubapi-testrepo/teams",
"hooks_url": "https://api.github.com/repos/willtsai/githubapi-testrepo/hooks",
"issue_events_url": "https://api.github.com/repos/willtsai/githubapi-testrepo/issues/events{/number}",
"events_url": "https://api.github.com/repos/willtsai/githubapi-testrepo/events",
"assignees_url": "https://api.github.com/repos/willtsai/githubapi-testrepo/assignees{/user}",
"branches_url": "https://api.github.com/repos/willtsai/githubapi-testrepo/branches{/branch}",
"tags_url": "https://api.github.com/repos/willtsai/githubapi-testrepo/tags",
"blobs_url": "https://api.github.com/repos/willtsai/githubapi-testrepo/git/blobs{/sha}",
"git_tags_url": "https://api.github.com/repos/willtsai/githubapi-testrepo/git/tags{/sha}",
"git_refs_url": "https://api.github.com/repos/willtsai/githubapi-testrepo/git/refs{/sha}",
"trees_url": "https://api.github.com/repos/willtsai/githubapi-testrepo/git/trees{/sha}",
"statuses_url": "https://api.github.com/repos/willtsai/githubapi-testrepo/statuses/{sha}",
"languages_url": "https://api.github.com/repos/willtsai/githubapi-testrepo/languages",
"stargazers_url": "https://api.github.com/repos/willtsai/githubapi-testrepo/stargazers",
"contributors_url": "https://api.github.com/repos/willtsai/githubapi-testrepo/contributors",
"subscribers_url": "https://api.github.com/repos/willtsai/githubapi-testrepo/subscribers",
"subscription_url": "https://api.github.com/repos/willtsai/githubapi-testrepo/subscription",
"commits_url": "https://api.github.com/repos/willtsai/githubapi-testrepo/commits{/sha}",
"git_commits_url": "https://api.github.com/repos/willtsai/githubapi-testrepo/git/commits{/sha}",
"comments_url": "https://api.github.com/repos/willtsai/githubapi-testrepo/comments{/number}",
"issue_comment_url": "https://api.github.com/repos/willtsai/githubapi-testrepo/issues/comments{/number}",
"contents_url": "https://api.github.com/repos/willtsai/githubapi-testrepo/contents/{+path}",
"compare_url": "https://api.github.com/repos/willtsai/githubapi-testrepo/compare/{base}...{head}",
"merges_url": "https://api.github.com/repos/willtsai/githubapi-testrepo/merges",
"archive_url": "https://api.github.com/repos/willtsai/githubapi-testrepo/{archive_format}{/ref}",
"downloads_url": "https://api.github.com/repos/willtsai/githubapi-testrepo/downloads",
"issues_url": "https://api.github.com/repos/willtsai/githubapi-testrepo/issues{/number}",
"pulls_url": "https://api.github.com/repos/willtsai/githubapi-testrepo/pulls{/number}",
"milestones_url": "https://api.github.com/repos/willtsai/githubapi-testrepo/milestones{/number}",
"notifications_url": "https://api.github.com/repos/willtsai/githubapi-testrepo/notifications{?since,all,participating}",
"labels_url": "https://api.github.com/repos/willtsai/githubapi-testrepo/labels{/name}",
"releases_url": "https://api.github.com/repos/willtsai/githubapi-testrepo/releases{/id}",
"deployments_url": "https://api.github.com/repos/willtsai/githubapi-testrepo/deployments",
"created_at": "2021-11-19T03:48:57Z",
"updated_at": "2021-11-19T03:48:57Z",
"pushed_at": "2021-11-19T03:48:58Z",
"git_url": "git://github.com/willtsai/githubapi-testrepo.git",
"ssh_url": "[email protected]:willtsai/githubapi-testrepo.git",
"clone_url": "https://github.com/willtsai/githubapi-testrepo.git",
"svn_url": "https://github.com/willtsai/githubapi-testrepo",
"homepage": null,
"size": 0,
"stargazers_count": 0,
"watchers_count": 0,
"language": null,
"has_issues": true,
"has_projects": true,
"has_downloads": true,
"has_wiki": true,
"has_pages": false,
"forks_count": 0,
"mirror_url": null,
"archived": false,
"disabled": false,
"open_issues_count": 2,
"license": null,
"allow_forking": true,
"is_template": false,
"topics": [

],
"visibility": "public",
"forks": 0,
"open_issues": 2,
"watchers": 0,
"default_branch": "main"
},
"sender": {
"login": "willtsai",
"id": 28876888,
"node_id": "MDQ6VXNlcjI4ODc2ODg4",
"avatar_url": "https://avatars.githubusercontent.com/u/28876888?v=4",
"gravatar_id": "",
"url": "https://api.github.com/users/willtsai",
"html_url": "https://github.com/willtsai",
"followers_url": "https://api.github.com/users/willtsai/followers",
"following_url": "https://api.github.com/users/willtsai/following{/other_user}",
"gists_url": "https://api.github.com/users/willtsai/gists{/gist_id}",
"starred_url": "https://api.github.com/users/willtsai/starred{/owner}{/repo}",
"subscriptions_url": "https://api.github.com/users/willtsai/subscriptions",
"organizations_url": "https://api.github.com/users/willtsai/orgs",
"repos_url": "https://api.github.com/users/willtsai/repos",
"events_url": "https://api.github.com/users/willtsai/events{/privacy}",
"received_events_url": "https://api.github.com/users/willtsai/received_events",
"type": "User",
"site_admin": false
}
}
Loading