Skip to content

Commit 9197199

Browse files
committed
Use issues endpoint to react on pull requests
Pull requests are sorta issues and for reactions, you need to use the issues API to react. Fixes #1749
1 parent 22d4154 commit 9197199

16 files changed

+1341
-3
lines changed

src/main/java/org/kohsuke/github/GHIssue.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -590,7 +590,7 @@ public GHReaction createReaction(ReactionContent content) throws IOException {
590590
.method("POST")
591591
.withPreview(SQUIRREL_GIRL)
592592
.with("content", content.getContent())
593-
.withUrlPath(getApiRoute() + "/reactions")
593+
.withUrlPath(getIssuesApiRoute() + "/reactions")
594594
.fetch(GHReaction.class);
595595
}
596596

@@ -606,7 +606,7 @@ public void deleteReaction(GHReaction reaction) throws IOException {
606606
owner.root()
607607
.createRequest()
608608
.method("DELETE")
609-
.withUrlPath(getApiRoute(), "reactions", String.valueOf(reaction.getId()))
609+
.withUrlPath(getIssuesApiRoute(), "reactions", String.valueOf(reaction.getId()))
610610
.send();
611611
}
612612

@@ -619,7 +619,7 @@ public void deleteReaction(GHReaction reaction) throws IOException {
619619
public PagedIterable<GHReaction> listReactions() {
620620
return root().createRequest()
621621
.withPreview(SQUIRREL_GIRL)
622-
.withUrlPath(getApiRoute() + "/reactions")
622+
.withUrlPath(getIssuesApiRoute() + "/reactions")
623623
.toIterable(GHReaction[].class, null);
624624
}
625625

src/test/java/org/kohsuke/github/GHPullRequestTest.java

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -883,6 +883,26 @@ public void checkPullRequestReviewer() throws IOException {
883883
assertThat(reviewer, notNullValue());
884884
}
885885

886+
/**
887+
* Create/Delete reaction for pull requests.
888+
*
889+
* @throws Exception
890+
* the exception
891+
*/
892+
@Test
893+
public void reactions() throws Exception {
894+
String name = "createPullRequest";
895+
GHRepository repo = getRepository();
896+
GHPullRequest p = repo.createPullRequest(name, "test/stable", "main", "## test");
897+
898+
assertThat(p.listReactions().toList(), hasSize(0));
899+
GHReaction reaction = p.createReaction(ReactionContent.CONFUSED);
900+
assertThat(p.listReactions().toList(), hasSize(1));
901+
902+
p.deleteReaction(reaction);
903+
assertThat(p.listReactions().toList(), hasSize(0));
904+
}
905+
886906
/**
887907
* Gets the repository.
888908
*
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
{
2+
"login": "hub4j-test-org",
3+
"id": 7544739,
4+
"node_id": "MDEyOk9yZ2FuaXphdGlvbjc1NDQ3Mzk=",
5+
"url": "https://api.github.com/orgs/hub4j-test-org",
6+
"repos_url": "https://api.github.com/orgs/hub4j-test-org/repos",
7+
"events_url": "https://api.github.com/orgs/hub4j-test-org/events",
8+
"hooks_url": "https://api.github.com/orgs/hub4j-test-org/hooks",
9+
"issues_url": "https://api.github.com/orgs/hub4j-test-org/issues",
10+
"members_url": "https://api.github.com/orgs/hub4j-test-org/members{/member}",
11+
"public_members_url": "https://api.github.com/orgs/hub4j-test-org/public_members{/member}",
12+
"avatar_url": "https://avatars.githubusercontent.com/u/7544739?v=4",
13+
"description": "Hub4j Test Org Description (this could be null or blank too)",
14+
"name": "Hub4j Test Org Name (this could be null or blank too)",
15+
"company": null,
16+
"blog": "https://hub4j.url.io/could/be/null",
17+
"location": "Hub4j Test Org Location (this could be null or blank too)",
18+
"email": "[email protected]",
19+
"twitter_username": null,
20+
"is_verified": false,
21+
"has_organization_projects": true,
22+
"has_repository_projects": true,
23+
"public_repos": 26,
24+
"public_gists": 0,
25+
"followers": 2,
26+
"following": 0,
27+
"html_url": "https://github.com/hub4j-test-org",
28+
"created_at": "2014-05-10T19:39:11Z",
29+
"updated_at": "2020-06-04T05:56:10Z",
30+
"archived_at": null,
31+
"type": "Organization",
32+
"total_private_repos": 6,
33+
"owned_private_repos": 6,
34+
"private_gists": 0,
35+
"disk_usage": 12014,
36+
"collaborators": 1,
37+
"billing_email": "[email protected]",
38+
"default_repository_permission": "none",
39+
"members_can_create_repositories": false,
40+
"two_factor_requirement_enabled": false,
41+
"members_allowed_repository_creation_type": "none",
42+
"members_can_create_public_repositories": false,
43+
"members_can_create_private_repositories": false,
44+
"members_can_create_internal_repositories": false,
45+
"members_can_create_pages": true,
46+
"members_can_fork_private_repositories": false,
47+
"web_commit_signoff_required": false,
48+
"members_can_create_public_pages": true,
49+
"members_can_create_private_pages": true,
50+
"plan": {
51+
"name": "free",
52+
"space": 976562499,
53+
"private_repos": 10000,
54+
"filled_seats": 50,
55+
"seats": 3
56+
},
57+
"advanced_security_enabled_for_new_repositories": false,
58+
"dependabot_alerts_enabled_for_new_repositories": false,
59+
"dependabot_security_updates_enabled_for_new_repositories": false,
60+
"dependency_graph_enabled_for_new_repositories": false,
61+
"secret_scanning_enabled_for_new_repositories": false,
62+
"secret_scanning_push_protection_enabled_for_new_repositories": false,
63+
"secret_scanning_push_protection_custom_link_enabled": false,
64+
"secret_scanning_push_protection_custom_link": null,
65+
"secret_scanning_validity_checks_enabled": false
66+
}

0 commit comments

Comments
 (0)