Allow the caller to wait for the mergeable state to change.

This approaches #394 differently. The problem with the original #394 is
that the supposed behaviour is only useful for people waiting for
`getMergeable()` to return non-null in a busy loop, yet it impacts all
the other methods of this object.
This commit is contained in:
Kohsuke Kawaguchi
2018-01-12 21:25:30 -08:00
parent 1e497d2c44
commit 4e31636181

View File

@@ -182,6 +182,13 @@ public class GHPullRequest extends GHIssue {
return maintainer_can_modify;
}
/**
* Is this PR mergeable?
*
* @return
* null if the state has not been determined yet, for example when a PR is newly created.
* Use {@link #refresh()} after some interval to wait until the value is determined.
*/
public Boolean getMergeable() throws IOException {
populate();
return mergeable;
@@ -217,6 +224,13 @@ public class GHPullRequest extends GHIssue {
*/
private void populate() throws IOException {
if (mergeable_state!=null) return; // already populated
refresh();
}
/**
* Repopulates this object.
*/
public void refresh() throws IOException {
if (root.isOffline()) {
return; // cannot populate, will have to live with what we have
}