Skip to content

Commit 4e31636

Browse files
committed
Allow the caller to wait for the mergeable state to change.
This approaches hub4j#394 differently. The problem with the original hub4j#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.
1 parent 1e497d2 commit 4e31636

1 file changed

Lines changed: 14 additions & 0 deletions

File tree

src/main/java/org/kohsuke/github/GHPullRequest.java

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,13 @@ public boolean canMaintainerModify() throws IOException {
182182
return maintainer_can_modify;
183183
}
184184

185+
/**
186+
* Is this PR mergeable?
187+
*
188+
* @return
189+
* null if the state has not been determined yet, for example when a PR is newly created.
190+
* Use {@link #refresh()} after some interval to wait until the value is determined.
191+
*/
185192
public Boolean getMergeable() throws IOException {
186193
populate();
187194
return mergeable;
@@ -217,6 +224,13 @@ public String getMergeCommitSha() throws IOException {
217224
*/
218225
private void populate() throws IOException {
219226
if (mergeable_state!=null) return; // already populated
227+
refresh();
228+
}
229+
230+
/**
231+
* Repopulates this object.
232+
*/
233+
public void refresh() throws IOException {
220234
if (root.isOffline()) {
221235
return; // cannot populate, will have to live with what we have
222236
}

0 commit comments

Comments
 (0)