11package org .kohsuke .github ;
22
3+ import com .fasterxml .jackson .annotation .JsonProperty ;
34import edu .umd .cs .findbugs .annotations .SuppressFBWarnings ;
45
56import java .io .IOException ;
67import java .net .URL ;
8+ import java .util .Arrays ;
9+ import java .util .Collections ;
710import java .util .Date ;
11+ import java .util .List ;
812
913/**
1014 * Represents a check run.
1418@ SuppressFBWarnings (value = { "UWF_UNWRITTEN_FIELD" , "NP_UNWRITTEN_FIELD" , "URF_UNREAD_FIELD" },
1519 justification = "JSON API" )
1620public class GHCheckRun extends GHObject {
21+
22+ @ JsonProperty ("repository" )
1723 GHRepository owner ;
1824 GitHub root ;
1925
@@ -34,15 +40,32 @@ public class GHCheckRun extends GHObject {
3440
3541 GHCheckRun wrap (GHRepository owner ) {
3642 this .owner = owner ;
37- this . root = owner .root ;
43+ wrap ( owner .root ) ;
3844 return this ;
3945 }
4046
4147 GHCheckRun wrap (GitHub root ) {
4248 this .root = root ;
4349 if (owner != null ) {
4450 owner .wrap (root );
51+ if (pullRequests != null && pullRequests .length != 0 ) {
52+ for (GHPullRequest singlePull : pullRequests ) {
53+ singlePull .wrap (owner );
54+ }
55+ }
56+
57+ }
58+ if (checkSuite != null ) {
59+ if (owner != null ) {
60+ checkSuite .wrap (owner );
61+ } else {
62+ checkSuite .wrap (root );
63+ }
4564 }
65+ if (app != null ) {
66+ app .wrapUp (root );
67+ }
68+
4669 return this ;
4770 }
4871
@@ -105,15 +128,22 @@ public String getHeadSha() {
105128 /**
106129 * Gets the pull requests participated in this check run.
107130 *
108- * @return Pull requests of this check run
131+ * Note this field is only populated for events. When getting a {@link GHCheckRun} outside of an event, this is
132+ * always empty.
133+ *
134+ * @return the list of {@link GHPullRequest}s for this check run. Only populated for events.
135+ * @throws IOException
136+ * the io exception
109137 */
110- GHPullRequest [] getPullRequests () throws IOException {
138+ public List < GHPullRequest > getPullRequests () throws IOException {
111139 if (pullRequests != null && pullRequests .length != 0 ) {
112140 for (GHPullRequest singlePull : pullRequests ) {
113- singlePull .refresh ();
141+ // Only refresh if we haven't do so before
142+ singlePull .refresh (singlePull .getTitle ());
114143 }
144+ return Collections .unmodifiableList (Arrays .asList (pullRequests ));
115145 }
116- return pullRequests ;
146+ return Collections . emptyList () ;
117147 }
118148
119149 /**
0 commit comments