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 1bfe7dd

Browse filesBrowse files
committed
Issue hub4j#264: wait for the repo to finish forking
1 parent 27e855d commit 1bfe7dd
Copy full SHA for 1bfe7dd

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
@@ -587,7 +587,19 @@ protected void wrapUp(GHRepository[] page) {
587587
* Newly forked repository that belong to you.
588588
*/
589589
public GHRepository fork() throws IOException {
590-
return new Requester(root).method("POST").to(getApiTailUrl("forks"), GHRepository.class).wrap(root);
590+
new Requester(root).method("POST").to(getApiTailUrl("forks"), null);
591+
592+
// this API is asynchronous. we need to wait for a bit
593+
for (int i=0; i<10; i++) {
594+
GHRepository r = root.getMyself().getRepository(name);
595+
if (r!=null) return r;
596+
try {
597+
Thread.sleep(3000);
598+
} catch (InterruptedException e) {
599+
throw (IOException)new InterruptedIOException().initCause(e);
600+
}
601+
}
602+
throw new IOException(this+" was forked but can't find the new repository");
591603
}
592604

593605
/**

0 commit comments

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