use of git4idea.checkout.GitCloneDialog in project intellij-community by JetBrains.
the class GithubCheckoutProvider method doCheckout.
@Override
public void doCheckout(@NotNull final Project project, @Nullable final Listener listener) {
if (!GithubUtil.testGitExecutable(project)) {
return;
}
BasicAction.saveAll();
List<GithubRepo> availableRepos;
try {
availableRepos = GithubUtil.computeValueInModalIO(project, "Access to GitHub", indicator -> GithubUtil.runTask(project, GithubAuthDataHolder.createFromSettings(), indicator, connection -> GithubApiUtil.getAvailableRepos(connection)));
} catch (IOException e) {
GithubNotifications.showError(project, "Couldn't get the list of GitHub repositories", e);
return;
}
Collections.sort(availableRepos, (r1, r2) -> {
final int comparedOwners = r1.getUserName().compareTo(r2.getUserName());
return comparedOwners != 0 ? comparedOwners : r1.getName().compareTo(r2.getName());
});
final GitCloneDialog dialog = new GitCloneDialog(project);
// Add predefined repositories to history
dialog.prependToHistory("-----------------------------------------------");
for (int i = availableRepos.size() - 1; i >= 0; i--) {
dialog.prependToHistory(GithubUrlUtil.getCloneUrl(availableRepos.get(i).getFullPath()));
}
if (!dialog.showAndGet()) {
return;
}
dialog.rememberSettings();
final VirtualFile destinationParent = LocalFileSystem.getInstance().findFileByIoFile(new File(dialog.getParentDirectory()));
if (destinationParent == null) {
return;
}
final String sourceRepositoryURL = dialog.getSourceRepositoryURL();
final String directoryName = dialog.getDirectoryName();
final String parentDirectory = dialog.getParentDirectory();
Git git = ServiceManager.getService(Git.class);
GitCheckoutProvider.clone(project, git, listener, destinationParent, sourceRepositoryURL, directoryName, parentDirectory);
}
Aggregations