Merge pull request #1092 from gsmet/attach-check-runs

Properly wrap the check runs with the repository when listing them
This commit is contained in:
Liam Newman
2021-04-12 10:00:01 -07:00
committed by GitHub
4 changed files with 13 additions and 8 deletions

View File

@@ -8,13 +8,13 @@ import javax.annotation.Nonnull;
* Iterable for check-runs listing.
*/
class GHCheckRunsIterable extends PagedIterable<GHCheckRun> {
private final transient GitHub root;
private final GHRepository owner;
private final GitHubRequest request;
private GHCheckRunsPage result;
public GHCheckRunsIterable(GitHub root, GitHubRequest request) {
this.root = root;
public GHCheckRunsIterable(GHRepository owner, GitHubRequest request) {
this.owner = owner;
this.request = request;
}
@@ -22,7 +22,7 @@ class GHCheckRunsIterable extends PagedIterable<GHCheckRun> {
@Override
public PagedIterator<GHCheckRun> _iterator(int pageSize) {
return new PagedIterator<>(
adapt(GitHubPageIterator.create(root.getClient(), GHCheckRunsPage.class, request, pageSize)),
adapt(GitHubPageIterator.create(owner.getRoot().getClient(), GHCheckRunsPage.class, request, pageSize)),
null);
}
@@ -37,7 +37,7 @@ class GHCheckRunsIterable extends PagedIterable<GHCheckRun> {
if (result == null) {
result = v;
}
return v.getCheckRuns(root);
return v.getCheckRuns(owner);
}
};
}

View File

@@ -11,9 +11,9 @@ class GHCheckRunsPage {
return total_count;
}
GHCheckRun[] getCheckRuns(GitHub root) {
GHCheckRun[] getCheckRuns(GHRepository owner) {
for (GHCheckRun check_run : check_runs) {
check_run.wrap(root);
check_run.wrap(owner);
}
return check_runs;
}

View File

@@ -2010,7 +2010,7 @@ public class GHRepository extends GHObject {
.withUrlPath(String.format("/repos/%s/%s/commits/%s/check-runs", getOwnerName(), name, ref))
.withPreview(ANTIOPE)
.build();
return new GHCheckRunsIterable(root, request);
return new GHCheckRunsIterable(this, request);
}
/**

View File

@@ -773,6 +773,11 @@ public class GHRepositoryTest extends AbstractGitHubWireMockTest {
checkRunsCount++;
}
assertThat(checkRunsCount, equalTo(expectedCount));
// Check that we can call update on the results
for (GHCheckRun checkRun : checkRuns) {
checkRun.update();
}
}
@Test