mirror of
https://github.com/jlengrand/github-api.git
synced 2026-03-10 08:21:21 +00:00
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:
@@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user