Skip to content

Commit 2d35bc2

Browse files
committed
feat: Add additional PR field in CheckRunResponse and CheckSuite
1 parent ccd8ca9 commit 2d35bc2

File tree

6 files changed

+81
-29
lines changed

6 files changed

+81
-29
lines changed

src/main/java/com/spotify/github/v3/checks/CheckRunResponse.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,11 @@
2222

2323
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
2424
import com.spotify.github.GithubStyle;
25+
26+
import java.util.List;
2527
import java.util.Optional;
28+
29+
import com.spotify.github.v3.prs.PartialPullRequestItem;
2630
import org.immutables.value.Value;
2731

2832
/** The CheckRun response resource. */
@@ -73,4 +77,10 @@ public interface CheckRunResponse extends CheckRunBase {
7377
* @return the optional
7478
*/
7579
Optional<App> app();
80+
81+
/**
82+
* Pull Requests where this check is applied.
83+
* @return the list of pull requests
84+
*/
85+
List<PartialPullRequestItem> pullRequests();
7686
}

src/main/java/com/spotify/github/v3/checks/CheckSuite.java

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@
77
* Licensed under the Apache License, Version 2.0 (the "License");
88
* you may not use this file except in compliance with the License.
99
* You may obtain a copy of the License at
10-
*
10+
*
1111
* http://www.apache.org/licenses/LICENSE-2.0
12-
*
12+
*
1313
* Unless required by applicable law or agreed to in writing, software
1414
* distributed under the License is distributed on an "AS IS" BASIS,
1515
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -22,23 +22,34 @@
2222

2323
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
2424
import com.spotify.github.GithubStyle;
25+
26+
import java.util.List;
2527
import java.util.Optional;
28+
29+
import com.spotify.github.v3.prs.PartialPullRequestItem;
2630
import org.immutables.value.Value;
2731

28-
/** Github CheckSuite */
32+
/** GitHub CheckSuite */
2933
@Value.Immutable
3034
@GithubStyle
3135
@JsonDeserialize(as = ImmutableCheckSuite.class)
3236
public interface CheckSuite {
3337

3438
/**
35-
* The Check Suite Id.
39+
* The Check Suite id.
3640
*
37-
* @return the integer
41+
* @return the long id
3842
*/
3943
Long id();
4044

4145
Optional<App> app();
4246

4347
Optional<String> headBranch();
48+
49+
/**
50+
* Pull Requests where this check suite is applied.
51+
*
52+
* @return the list of pull requests
53+
*/
54+
List<PartialPullRequestItem> pullRequests();
4455
}
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
/*-
2+
* -\-\-
3+
* github-api
4+
* --
5+
* Copyright (C) 2016 - 2020 Spotify AB
6+
* --
7+
* Licensed under the Apache License, Version 2.0 (the "License");
8+
* you may not use this file except in compliance with the License.
9+
* You may obtain a copy of the License at
10+
*
11+
* http://www.apache.org/licenses/LICENSE-2.0
12+
*
13+
* Unless required by applicable law or agreed to in writing, software
14+
* distributed under the License is distributed on an "AS IS" BASIS,
15+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16+
* See the License for the specific language governing permissions and
17+
* limitations under the License.
18+
* -/-/-
19+
*/
20+
package com.spotify.github.v3.prs;
21+
22+
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
23+
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
24+
import com.spotify.github.CloseTracking;
25+
import com.spotify.github.GithubStyle;
26+
import org.immutables.value.Value;
27+
28+
import javax.annotation.Nullable;
29+
import java.net.URI;
30+
31+
@Value.Immutable
32+
@GithubStyle
33+
@JsonSerialize(as = ImmutablePartialPullRequestItem.class)
34+
@JsonDeserialize(as = ImmutablePartialPullRequestItem.class)
35+
public interface PartialPullRequestItem extends CloseTracking {
36+
/** ID. */
37+
Long id();
38+
39+
/** URL. */
40+
URI url();
41+
42+
/** Number. */
43+
Long number();
44+
45+
/** Head reference. */
46+
@Nullable
47+
PullRequestRef head();
48+
49+
/** Base reference. */
50+
@Nullable
51+
PullRequestRef base();
52+
}

src/main/java/com/spotify/github/v3/prs/PullRequestItem.java

Lines changed: 1 addition & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@
2323
import com.fasterxml.jackson.annotation.JsonProperty;
2424
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
2525
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
26-
import com.spotify.github.CloseTracking;
2726
import com.spotify.github.GitHubInstant;
2827
import com.spotify.github.GithubStyle;
2928
import com.spotify.github.v3.Milestone;
@@ -39,15 +38,7 @@
3938
@GithubStyle
4039
@JsonSerialize(as = ImmutablePullRequestItem.class)
4140
@JsonDeserialize(as = ImmutablePullRequestItem.class)
42-
public interface PullRequestItem extends CloseTracking {
43-
44-
/** ID. */
45-
@Nullable
46-
Long id();
47-
48-
/** URL. */
49-
@Nullable
50-
URI url();
41+
public interface PullRequestItem extends PartialPullRequestItem {
5142

5243
/** HTML URL. */
5344
@Nullable
@@ -69,10 +60,6 @@ public interface PullRequestItem extends CloseTracking {
6960
@Nullable
7061
URI commitsUrl();
7162

72-
/** Number. */
73-
@Nullable
74-
Integer number();
75-
7663
/** Either open, closed, or all to filter by state. Default: open. */
7764
@Nullable
7865
String state();
@@ -100,14 +87,6 @@ public interface PullRequestItem extends CloseTracking {
10087
/** Merged date. */
10188
Optional<GitHubInstant> mergedAt();
10289

103-
/** Head reference. */
104-
@Nullable
105-
PullRequestRef head();
106-
107-
/** Base reference. */
108-
@Nullable
109-
PullRequestRef base();
110-
11190
/** User. */
11291
@Nullable
11392
User user();

src/test/java/com/spotify/github/v3/activity/events/PullRequestReviewEventTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ public void testDeserialization() throws IOException {
4040
final PullRequestReviewEvent statusEvent =
4141
Json.create().fromJson(fixture, PullRequestReviewEvent.class);
4242
assertThat(statusEvent.action(), is("submitted"));
43-
assertThat(statusEvent.pullRequest().number(), is(8));
43+
assertThat(statusEvent.pullRequest().number(), is(8L));
4444
assertThat(statusEvent.review().state(), is(ReviewState.APPROVED));
4545
}
4646
}

src/test/java/com/spotify/github/v3/clients/RepositoryClientTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -286,7 +286,7 @@ public void listPullRequestsForCommit() throws Exception {
286286
.thenReturn(fixture);
287287
final List<PullRequestItem> prs = repoClient.listPullRequestsForCommit("thesha").get();
288288
assertThat(prs.size(), is(1));
289-
assertThat(prs.get(0).number(), is(1347));
289+
assertThat(prs.get(0).number(), is(1347L));
290290
}
291291

292292
@Test

0 commit comments

Comments
 (0)