Skip to content

Commit

Permalink
Fetch PRs using the head hash, as the source ref may not be present. …
Browse files Browse the repository at this point in the history
…Speed up move on failure.
  • Loading branch information
Robin Westberg committed Feb 10, 2020
1 parent 8a48b2c commit 3fbb06e
Showing 1 changed file with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ private Repository cloneSeeded(Path path) throws IOException {
}

private NewClone fetchRef(Repository repository) throws IOException {
var fetchHead = repository.fetch(hostedRepository.url(), "+" + ref + ":" + ref);
var fetchHead = repository.fetch(hostedRepository.url(), "+" + ref + ":hostedrepositorypool");
return new NewClone(repository, fetchHead);
}

Expand All @@ -112,7 +112,7 @@ private NewClone materializeClone(Path path) throws IOException {
if (!localRepoInstance.isHealthy()) {
var preserveUnhealthy = seed.resolveSibling(seed.getFileName().toString() + "-unhealthy-" + UUID.randomUUID());
log.severe("Unhealthy local repository detected - preserved in: " + preserveUnhealthy);
Files.move(localRepoInstance.root(), preserveUnhealthy);
Files.move(path, preserveUnhealthy);
return fetchRef(cloneSeeded(path));
} else {
try {
Expand All @@ -121,7 +121,7 @@ private NewClone materializeClone(Path path) throws IOException {
} catch (IOException e) {
var preserveUnclean = seed.resolveSibling(seed.getFileName().toString() + "-unclean-" + UUID.randomUUID());
log.severe("Uncleanable local repository detected - preserved in: " + preserveUnclean);
Files.move(localRepoInstance.root(), preserveUnclean);
Files.move(path, preserveUnclean);
return fetchRef(cloneSeeded(path));
}
}
Expand Down Expand Up @@ -158,6 +158,6 @@ public Repository checkout(HostedRepository hostedRepository, String ref, Path p
}

public Repository checkout(PullRequest pr, Path path) throws IOException {
return checkout(pr.repository(), pr.sourceRef(), path);
return checkout(pr.repository(), pr.headHash().hex(), path);
}
}

0 comments on commit 3fbb06e

Please sign in to comment.