Skip to content

Commit 9091e05

Browse files
Merge branch 'main' into feature/enableLock
2 parents 7ae4073 + 3ecd46e commit 9091e05

69 files changed

Lines changed: 14544 additions & 105 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/maven-build.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ jobs:
3636
env:
3737
MAVEN_OPTS: ${{ env.JAVA_11_PLUS_MAVEN_OPTS }}
3838
run: mvn -B clean install -DskipTests --file pom.xml
39-
- uses: actions/upload-artifact@v6
39+
- uses: actions/upload-artifact@v7
4040
with:
4141
name: maven-target-directory
4242
path: target/
@@ -110,7 +110,7 @@ jobs:
110110
run: mvn -B clean install -D enable-ci --file pom.xml "-Dsurefire.argLine=--add-opens java.base/java.net=ALL-UNNAMED"
111111
- name: Save coverage data
112112
if: matrix.os == 'ubuntu' && matrix.java == '17'
113-
uses: actions/upload-artifact@v6
113+
uses: actions/upload-artifact@v7
114114
with:
115115
name: maven-test-target-directory
116116
path: target/
@@ -121,7 +121,7 @@ jobs:
121121
runs-on: ubuntu-latest
122122
steps:
123123
- uses: actions/checkout@v6
124-
- uses: actions/download-artifact@v7
124+
- uses: actions/download-artifact@v8
125125
with:
126126
name: maven-test-target-directory
127127
path: target
@@ -139,7 +139,7 @@ jobs:
139139
runs-on: ubuntu-latest
140140
steps:
141141
- uses: actions/checkout@v6
142-
- uses: actions/download-artifact@v7
142+
- uses: actions/download-artifact@v8
143143
with:
144144
name: maven-target-directory
145145
path: target

.github/workflows/publish_release_branch.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ jobs:
2525
MAVEN_OPTS: ${{ env.JAVA_11_PLUS_MAVEN_OPTS }}
2626
run: mvn -B clean install site -D enable-ci --file pom.xml "-Dsurefire.argLine=--add-opens java.base/java.net=ALL-UNNAMED"
2727

28-
- uses: actions/upload-artifact@v6
28+
- uses: actions/upload-artifact@v7
2929
with:
3030
name: maven-release-target-directory
3131
path: target/
@@ -78,7 +78,7 @@ jobs:
7878
run: |
7979
echo "version=$(mvn -B help:evaluate -Dexpression=project.version -q -DforceStdout)" >> $GITHUB_OUTPUT
8080
81-
- uses: actions/download-artifact@v7
81+
- uses: actions/download-artifact@v8
8282
with:
8383
name: maven-release-target-directory
8484
path: target

pom.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -348,7 +348,7 @@
348348
</plugin>
349349
<plugin>
350350
<artifactId>maven-surefire-plugin</artifactId>
351-
<version>3.5.3</version>
351+
<version>3.5.5</version>
352352
<configuration>
353353
<!-- SUREFIRE-1226 workaround -->
354354
<trimStackTrace>false</trimStackTrace>
@@ -619,7 +619,7 @@
619619
<dependency>
620620
<groupId>org.apache.bcel</groupId>
621621
<artifactId>bcel</artifactId>
622-
<version>6.10.0</version>
622+
<version>6.12.0</version>
623623
</dependency>
624624
</dependencies>
625625
</plugin>

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
package org.kohsuke.github;
22

3-
import com.fasterxml.jackson.databind.node.ObjectNode;
43
import com.infradna.tool.bridge_method_injector.WithBridgeMethods;
54
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
65

@@ -84,8 +83,7 @@ static GHEvent transformTypeToGHEvent(String type) {
8483
private long id;
8584
private GHOrganization org;
8685

87-
// we don't want to expose Jackson dependency to the user. This needs databinding
88-
private ObjectNode payload;
86+
private Object payload;
8987

9088
// these are all shallow objects
9189
private GHEventRepository repo;
@@ -174,7 +172,9 @@ public GHOrganization getOrganization() throws IOException {
174172
* if payload cannot be parsed
175173
*/
176174
public <T extends GHEventPayload> T getPayload(Class<T> type) throws IOException {
177-
T v = GitHubClient.getMappingObjectReader(root()).forType(type).readValue(payload);
175+
T v = GitHubClient.getMappingObjectReader(root())
176+
.forType(type)
177+
.readValue(GitHubClient.getMappingObjectWriter().writeValueAsString(payload));
178178
v.lateBind();
179179
return v;
180180
}

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

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,16 @@ public GHIssueSearchBuilder isClosed() {
5757
return q("is:closed");
5858
}
5959

60+
/**
61+
* Filters results to only include issues (excludes pull requests).
62+
*
63+
* @return the gh issue search builder
64+
*/
65+
public GHIssueSearchBuilder isIssue() {
66+
terms.removeIf("is:pr"::equals);
67+
return q("is:issue");
68+
}
69+
6070
/**
6171
* Is merged gh issue search builder.
6272
*
@@ -75,6 +85,16 @@ public GHIssueSearchBuilder isOpen() {
7585
return q("is:open");
7686
}
7787

88+
/**
89+
* Filters results to only include pull requests (excludes issues).
90+
*
91+
* @return the gh issue search builder
92+
*/
93+
public GHIssueSearchBuilder isPullRequest() {
94+
terms.removeIf("is:issue"::equals);
95+
return q("is:pr");
96+
}
97+
7898
/**
7999
* Mentions gh issue search builder.
80100
*
@@ -121,6 +141,19 @@ public GHIssueSearchBuilder q(String term) {
121141
return this;
122142
}
123143

144+
/**
145+
* Filters results to a specific repository.
146+
*
147+
* @param owner
148+
* the repository owner
149+
* @param name
150+
* the repository name
151+
* @return the gh issue search builder
152+
*/
153+
public GHIssueSearchBuilder repo(String owner, String name) {
154+
return q("repo:" + owner + "/" + name);
155+
}
156+
124157
/**
125158
* Sort gh issue search builder.
126159
*

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -530,7 +530,13 @@ public PagedIterable<GHPullRequestFileDetail> listFiles() {
530530
/**
531531
* Obtains all the review comments associated with this pull request.
532532
*
533+
* <p>
534+
* Unlike {@link GHPullRequestReview#listReviewComments()}, this method returns full
535+
* {@link GHPullRequestReviewComment} objects including line-related fields such as
536+
* {@link GHPullRequestReviewComment#getLine() line}, {@link GHPullRequestReviewComment#getSide() side}, etc.
537+
*
533538
* @return the paged iterable
539+
* @see GHPullRequestReview#listReviewComments()
534540
*/
535541
public PagedIterable<GHPullRequestReviewComment> listReviewComments() {
536542
return root().createRequest()

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

Lines changed: 194 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,190 @@
4343
@SuppressFBWarnings(value = { "UWF_UNWRITTEN_FIELD" }, justification = "JSON API")
4444
public class GHPullRequestReview extends GHObject {
4545

46+
/**
47+
* Represents a review comment as returned by the review comments endpoint. This is a limited view that does not
48+
* include line-related fields such as {@code line}, {@code originalLine}, {@code side}, etc.
49+
*
50+
* <p>
51+
* To obtain the full {@link GHPullRequestReviewComment} with all fields, call
52+
* {@link #readPullRequestReviewComment()}.
53+
*
54+
* @see GHPullRequest#listReviewComments()
55+
*/
56+
@SuppressFBWarnings(value = { "UWF_UNWRITTEN_FIELD" }, justification = "JSON API")
57+
public static class ReviewComment extends GHObject {
58+
59+
private GHCommentAuthorAssociation authorAssociation;
60+
private String body;
61+
private String commitId;
62+
private String diffHunk;
63+
private String htmlUrl;
64+
private String originalCommitId;
65+
private int originalPosition = -1;
66+
private String path;
67+
private int position = -1;
68+
private Long pullRequestReviewId = -1L;
69+
private String pullRequestUrl;
70+
private GHPullRequestReviewCommentReactions reactions;
71+
private GHUser user;
72+
73+
GHPullRequest owner;
74+
75+
/**
76+
* Create default ReviewComment instance
77+
*/
78+
public ReviewComment() {
79+
}
80+
81+
/**
82+
* Gets the author association to the project.
83+
*
84+
* @return the author association to the project
85+
*/
86+
public GHCommentAuthorAssociation getAuthorAssociation() {
87+
return authorAssociation;
88+
}
89+
90+
/**
91+
* The comment itself.
92+
*
93+
* @return the body
94+
*/
95+
public String getBody() {
96+
return body;
97+
}
98+
99+
/**
100+
* Gets commit id.
101+
*
102+
* @return the commit id
103+
*/
104+
public String getCommitId() {
105+
return commitId;
106+
}
107+
108+
/**
109+
* Gets diff hunk.
110+
*
111+
* @return the diff hunk
112+
*/
113+
public String getDiffHunk() {
114+
return diffHunk;
115+
}
116+
117+
/**
118+
* Gets the html url.
119+
*
120+
* @return the html url
121+
*/
122+
public URL getHtmlUrl() {
123+
return GitHubClient.parseURL(htmlUrl);
124+
}
125+
126+
/**
127+
* Gets commit id.
128+
*
129+
* @return the original commit id
130+
*/
131+
public String getOriginalCommitId() {
132+
return originalCommitId;
133+
}
134+
135+
/**
136+
* Gets original position.
137+
*
138+
* @return the original position
139+
*/
140+
public int getOriginalPosition() {
141+
return originalPosition;
142+
}
143+
144+
/**
145+
* Gets path.
146+
*
147+
* @return the path
148+
*/
149+
public String getPath() {
150+
return path;
151+
}
152+
153+
/**
154+
* Gets position.
155+
*
156+
* @return the position
157+
*/
158+
public int getPosition() {
159+
return position;
160+
}
161+
162+
/**
163+
* Gets The ID of the pull request review to which the comment belongs.
164+
*
165+
* @return {@link Long} the ID of the pull request review
166+
*/
167+
public Long getPullRequestReviewId() {
168+
return pullRequestReviewId != null ? pullRequestReviewId : -1;
169+
}
170+
171+
/**
172+
* Gets URL for the pull request that the review comment belongs to.
173+
*
174+
* @return {@link URL} the URL of the pull request
175+
*/
176+
public URL getPullRequestUrl() {
177+
return GitHubClient.parseURL(pullRequestUrl);
178+
}
179+
180+
/**
181+
* Gets the Reaction Rollup.
182+
*
183+
* @return {@link GHPullRequestReviewCommentReactions} the reaction rollup
184+
*/
185+
public GHPullRequestReviewCommentReactions getReactions() {
186+
return reactions;
187+
}
188+
189+
/**
190+
* Gets the user who posted this comment.
191+
*
192+
* @return the user
193+
* @throws IOException
194+
* the io exception
195+
*/
196+
public GHUser getUser() throws IOException {
197+
return owner.root().getUser(user.getLogin());
198+
}
199+
200+
/**
201+
* Fetches the full {@link GHPullRequestReviewComment} from the API, which includes all fields such as
202+
* {@link GHPullRequestReviewComment#getLine() line}, {@link GHPullRequestReviewComment#getOriginalLine()
203+
* originalLine}, {@link GHPullRequestReviewComment#getSide() side}, etc.
204+
*
205+
* @return the full {@link GHPullRequestReviewComment}
206+
* @throws IOException
207+
* if an I/O error occurs
208+
*/
209+
public GHPullRequestReviewComment readPullRequestReviewComment() throws IOException {
210+
return owner.root()
211+
.createRequest()
212+
.withUrlPath("/repos/" + owner.getRepository().getFullName() + "/pulls/comments/" + getId())
213+
.fetch(GHPullRequestReviewComment.class)
214+
.wrapUp(owner);
215+
}
216+
217+
/**
218+
* Wrap up.
219+
*
220+
* @param owner
221+
* the owner
222+
* @return the review comment
223+
*/
224+
ReviewComment wrapUp(GHPullRequest owner) {
225+
this.owner = owner;
226+
return this;
227+
}
228+
}
229+
46230
private String body;
47231

48232
private String commitId;
@@ -171,13 +355,20 @@ public GHUser getUser() throws IOException {
171355
/**
172356
* Obtains all the review comments associated with this pull request review.
173357
*
174-
* @return the paged iterable
358+
* <p>
359+
* The GitHub API endpoint used by this method returns a limited set of fields. To obtain full comment data
360+
* including line numbers, use {@link ReviewComment#readPullRequestReviewComment()} on individual comments, or use
361+
* {@link GHPullRequest#listReviewComments()} instead.
362+
*
363+
* @return the paged iterable of {@link ReviewComment} objects
364+
* @see GHPullRequest#listReviewComments()
365+
* @see ReviewComment#readPullRequestReviewComment()
175366
*/
176-
public PagedIterable<GHPullRequestReviewComment> listReviewComments() {
367+
public PagedIterable<ReviewComment> listReviewComments() {
177368
return owner.root()
178369
.createRequest()
179370
.withUrlPath(getApiRoute() + "/comments")
180-
.toIterable(GHPullRequestReviewComment[].class, item -> item.wrapUp(owner));
371+
.toIterable(ReviewComment[].class, item -> item.wrapUp(owner));
181372
}
182373

183374
/**

0 commit comments

Comments
 (0)