Skip to content
This repository was archived by the owner on Jul 31, 2025. It is now read-only.

Commit 492ff58

Browse files
committed
Fix invalid URL for pull request comments update/delete
1 parent dd3e739 commit 492ff58

2 files changed

Lines changed: 36 additions & 3 deletions

File tree

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ public URL getHtmlUrl() {
8686
}
8787

8888
protected String getApiRoute() {
89-
return "/repos/"+owner.getRepository().getFullName()+"/comments/"+id;
89+
return "/repos/"+owner.getRepository().getFullName()+"/pulls/comments/"+id;
9090
}
9191

9292
/**

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

Lines changed: 35 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55

66
import java.io.IOException;
77
import java.util.Collection;
8+
import java.util.List;
89

910
/**
1011
* @author Kohsuke Kawaguchi
@@ -18,7 +19,38 @@ public void createPullRequest() throws Exception {
1819
assertEquals(name, p.getTitle());
1920
}
2021

21-
@Test // Requires push access to the test repo to pass
22+
@Test
23+
public void createPullRequestComment() throws Exception {
24+
String name = rnd.next();
25+
GHPullRequest p = getRepository().createPullRequest(name, "stable", "master", "## test");
26+
p.comment("Some comment");
27+
}
28+
29+
@Test
30+
public void testPullRequestReviewComments() throws Exception {
31+
String name = rnd.next();
32+
GHPullRequest p = getRepository().createPullRequest(name, "stable", "master", "## test");
33+
System.out.println(p.getUrl());
34+
assertTrue(p.listReviewComments().asList().isEmpty());
35+
p.createReviewComment("Sample review comment", p.getHead().getSha(), "cli/pom.xml", 5);
36+
List<GHPullRequestReviewComment> comments = p.listReviewComments().asList();
37+
assertEquals(1, comments.size());
38+
GHPullRequestReviewComment comment = comments.get(0);
39+
assertEquals("Sample review comment", comment.getBody());
40+
41+
comment.update("Updated review comment");
42+
comments = p.listReviewComments().asList();
43+
assertEquals(1, comments.size());
44+
comment = comments.get(0);
45+
assertEquals("Updated review comment", comment.getBody());
46+
47+
comment.delete();
48+
comments = p.listReviewComments().asList();
49+
assertTrue(comments.isEmpty());
50+
}
51+
52+
@Test
53+
// Requires push access to the test repo to pass
2254
public void setLabels() throws Exception {
2355
GHPullRequest p = getRepository().createPullRequest(rnd.next(), "stable", "master", "## test");
2456
String label = rnd.next();
@@ -29,7 +61,8 @@ public void setLabels() throws Exception {
2961
assertEquals(label, labels.iterator().next().getName());
3062
}
3163

32-
@Test // Requires push access to the test repo to pass
64+
@Test
65+
// Requires push access to the test repo to pass
3366
public void setAssignee() throws Exception {
3467
GHPullRequest p = getRepository().createPullRequest(rnd.next(), "stable", "master", "## test");
3568
GHMyself user = gitHub.getMyself();

0 commit comments

Comments
 (0)