Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit dee28e7

Browse filesBrowse files
committed
Doc says this is asynchronous
1 parent c8f46a3 commit dee28e7
Copy full SHA for dee28e7

File tree

Expand file treeCollapse file tree

1 file changed

+13
-1
lines changed
Filter options
Expand file treeCollapse file tree

1 file changed

+13
-1
lines changed

‎src/main/java/org/kohsuke/github/GHRepository.java

Copy file name to clipboardExpand all lines: src/main/java/org/kohsuke/github/GHRepository.java
+13-1Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
import com.infradna.tool.bridge_method_injector.WithBridgeMethods;
3333

3434
import java.io.IOException;
35+
import java.io.InterruptedIOException;
3536
import java.net.URL;
3637
import java.util.AbstractSet;
3738
import java.util.ArrayList;
@@ -336,7 +337,18 @@ public GHRepository fork() throws IOException {
336337
*/
337338
public GHRepository forkTo(GHOrganization org) throws IOException {
338339
new Poster(root).withCredential().to(String.format("/repos/%s/%s/forks?org=%s",owner.login,name,org.getLogin()));
339-
return org.getRepository(name);
340+
341+
// this API is asynchronous. we need to wait for a bit
342+
for (int i=0; i<10; i++) {
343+
GHRepository r = org.getRepository(name);
344+
if (r!=null) return r;
345+
try {
346+
Thread.sleep(3000);
347+
} catch (InterruptedException e) {
348+
throw (IOException)new InterruptedIOException().initCause(e);
349+
}
350+
}
351+
throw new IOException(this+" was forked into "+org.getLogin()+" but can't find the new repository");
340352
}
341353

342354
/**

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.