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 1225510

Browse filesBrowse files
gildaybitwiseman
andauthored
Add side and start_side Parameters to Create Review Comment (hub4j#2072)
* Add side and start_side Parameters to Create Review Comment Follows existing pattern from line and start_line * Update src/main/java/org/kohsuke/github/GHPullRequestReviewCommentBuilder.java * Update src/main/java/org/kohsuke/github/GHPullRequestReviewCommentBuilder.java --------- Co-authored-by: Liam Newman <bitwiseman@gmail.com>
1 parent 91a8ff3 commit 1225510
Copy full SHA for 1225510

File tree

Expand file treeCollapse file tree

4 files changed

+49
-5
lines changed
Filter options
Expand file treeCollapse file tree

4 files changed

+49
-5
lines changed

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

Copy file name to clipboardExpand all lines: src/main/java/org/kohsuke/github/GHPullRequestReviewCommentBuilder.java
+37Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,43 @@ public GHPullRequestReviewCommentBuilder lines(int startLine, int endLine) {
110110
return this;
111111
}
112112

113+
/**
114+
* The side of the diff in the pull request that the comment applies to.
115+
* <p>
116+
* {@link #side(GHPullRequestReviewComment.Side)} and
117+
* {@link #sides(GHPullRequestReviewComment.Side, GHPullRequestReviewComment.Side)} will overwrite each other's
118+
* values.
119+
*
120+
* @param side
121+
* side of the diff to which the comment applies
122+
* @return the gh pull request review comment builder
123+
*/
124+
public GHPullRequestReviewCommentBuilder side(GHPullRequestReviewComment.Side side) {
125+
builder.with("side", side);
126+
builder.remove("start_side");
127+
return this;
128+
}
129+
130+
/**
131+
* The sides of the diff in the pull request that the comment applies to.
132+
* <p>
133+
* {@link #side(GHPullRequestReviewComment.Side)} and
134+
* {@link #sides(GHPullRequestReviewComment.Side, GHPullRequestReviewComment.Side)} will overwrite each other's
135+
* values.
136+
*
137+
* @param startSide
138+
* side of the diff to which the start of the comment applies
139+
* @param endSide
140+
* side of the diff to which the end of the comment applies
141+
* @return the gh pull request review comment builder
142+
*/
143+
public GHPullRequestReviewCommentBuilder sides(GHPullRequestReviewComment.Side startSide,
144+
GHPullRequestReviewComment.Side endSide) {
145+
builder.with("start_side", startSide);
146+
builder.with("side", endSide);
147+
return this;
148+
}
149+
113150
/**
114151
* Create gh pull request review comment.
115152
*

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

Copy file name to clipboardExpand all lines: src/test/java/org/kohsuke/github/GHPullRequestTest.java
+8-1Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@
2525
import static org.hamcrest.Matchers.not;
2626
import static org.hamcrest.Matchers.notNullValue;
2727
import static org.hamcrest.Matchers.nullValue;
28+
import static org.kohsuke.github.GHPullRequestReviewComment.Side.LEFT;
29+
import static org.kohsuke.github.GHPullRequestReviewComment.Side.RIGHT;
2830

2931
// TODO: Auto-generated Javadoc
3032
/**
@@ -337,12 +339,14 @@ public void pullRequestReviewComments() throws Exception {
337339
.body("A single line review comment")
338340
.path("README.md")
339341
.line(2)
342+
.side(RIGHT)
340343
.create();
341344
p.createReviewComment()
342345
.commitId(p.getHead().getSha())
343346
.body("A multiline review comment")
344347
.path("README.md")
345348
.lines(2, 3)
349+
.sides(RIGHT, RIGHT)
346350
.create();
347351
List<GHPullRequestReviewComment> comments = p.listReviewComments().toList();
348352
assertThat(comments.size(), equalTo(3));
@@ -362,7 +366,7 @@ public void pullRequestReviewComments() throws Exception {
362366
assertThat(comment.getStartSide(), equalTo(GHPullRequestReviewComment.Side.UNKNOWN));
363367
assertThat(comment.getLine(), equalTo(1));
364368
assertThat(comment.getOriginalLine(), equalTo(1));
365-
assertThat(comment.getSide(), equalTo(GHPullRequestReviewComment.Side.LEFT));
369+
assertThat(comment.getSide(), equalTo(LEFT));
366370
assertThat(comment.getPullRequestUrl(), notNullValue());
367371
assertThat(comment.getPullRequestUrl().toString(), containsString("hub4j-test-org/github-api/pulls/"));
368372
assertThat(comment.getBodyHtml(), nullValue());
@@ -375,11 +379,14 @@ public void pullRequestReviewComments() throws Exception {
375379
comment = comments.get(1);
376380
assertThat(comment.getBody(), equalTo("A single line review comment"));
377381
assertThat(comment.getLine(), equalTo(2));
382+
assertThat(comment.getSide(), equalTo(RIGHT));
378383

379384
comment = comments.get(2);
380385
assertThat(comment.getBody(), equalTo("A multiline review comment"));
381386
assertThat(comment.getStartLine(), equalTo(2));
382387
assertThat(comment.getLine(), equalTo(3));
388+
assertThat(comment.getStartSide(), equalTo(RIGHT));
389+
assertThat(comment.getSide(), equalTo(RIGHT));
383390

384391
comment.createReaction(ReactionContent.EYES);
385392
GHReaction toBeRemoved = comment.createReaction(ReactionContent.CONFUSED);

‎src/test/resources/org/kohsuke/github/GHPullRequestTest/wiremock/pullRequestReviewComments/mappings/7-r_h_g_pulls_484_comments.json

Copy file name to clipboardExpand all lines: src/test/resources/org/kohsuke/github/GHPullRequestTest/wiremock/pullRequestReviewComments/mappings/7-r_h_g_pulls_484_comments.json
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
},
1212
"bodyPatterns": [
1313
{
14-
"equalToJson": "{\"path\":\"README.md\",\"line\":2,\"body\":\"A single line review comment\",\"commit_id\":\"07374fe73aff1c2024a8d4114b32406c7a8e89b7\"}",
14+
"equalToJson": "{\"path\":\"README.md\",\"side\":\"right\",\"line\":2,\"body\":\"A single line review comment\",\"commit_id\":\"07374fe73aff1c2024a8d4114b32406c7a8e89b7\"}",
1515
"ignoreArrayOrder": true,
1616
"ignoreExtraElements": false
1717
}
@@ -55,4 +55,4 @@
5555
"uuid": "43f15589-cf59-4ed5-a2b8-8f6b7ebae791",
5656
"persistent": true,
5757
"insertionIndex": 7
58-
}
58+
}

‎src/test/resources/org/kohsuke/github/GHPullRequestTest/wiremock/pullRequestReviewComments/mappings/8-r_h_g_pulls_484_comments.json

Copy file name to clipboardExpand all lines: src/test/resources/org/kohsuke/github/GHPullRequestTest/wiremock/pullRequestReviewComments/mappings/8-r_h_g_pulls_484_comments.json
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
},
1212
"bodyPatterns": [
1313
{
14-
"equalToJson": "{\"path\":\"README.md\",\"line\":3,\"start_line\":2,\"body\":\"A multiline review comment\",\"commit_id\":\"07374fe73aff1c2024a8d4114b32406c7a8e89b7\"}",
14+
"equalToJson": "{\"path\":\"README.md\",\"side\":\"right\",\"start_side\":\"right\",\"line\":3,\"start_line\":2,\"body\":\"A multiline review comment\",\"commit_id\":\"07374fe73aff1c2024a8d4114b32406c7a8e89b7\"}",
1515
"ignoreArrayOrder": true,
1616
"ignoreExtraElements": false
1717
}
@@ -55,4 +55,4 @@
5555
"uuid": "efe94b1b-7f9c-4bba-9af2-0a7a59a498ab",
5656
"persistent": true,
5757
"insertionIndex": 8
58-
}
58+
}

0 commit comments

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