@Override public void doCheckout(@NotNull final Project project, @Nullable final Listener listener) { if (!GerritUtil.testGitExecutable(project)) { return; } BasicAction.saveAll(); List<ProjectInfo> availableProjects = null; try { availableProjects = GerritUtil.getAvailableProjects(project); } catch (IOException e) { LOG.info(e); GerritUtil.notifyError( project, "Couldn't get the list of Gerrit repositories", GerritUtil.getErrorTextFromException(e)); } if (availableProjects == null) { return; } Collections.sort( availableProjects, new Comparator<ProjectInfo>() { @Override public int compare(final ProjectInfo p1, final ProjectInfo p2) { return p1.getId().compareTo(p2.getId()); } }); final GitCloneDialog dialog = new GitCloneDialog(project); // Add predefined repositories to history for (int i = availableProjects.size() - 1; i >= 0; i--) { dialog.prependToHistory( GerritSettings.getInstance().getHost() + '/' + availableProjects.get(i).getId()); } dialog.show(); if (!dialog.isOK()) { 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); }
@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.computeValueInModal( project, "Access to GitHub", new ThrowableConvertor<ProgressIndicator, List<GithubRepo>, IOException>() { @NotNull @Override public List<GithubRepo> convert(ProgressIndicator indicator) throws IOException { return GithubUtil.runTask( project, GithubAuthDataHolder.createFromSettings(), indicator, new ThrowableConvertor<GithubAuthData, List<GithubRepo>, IOException>() { @NotNull @Override public List<GithubRepo> convert(@NotNull GithubAuthData auth) throws IOException { return GithubApiUtil.getAvailableRepos(auth); } }); } }); } catch (IOException e) { GithubNotifications.showError(project, "Couldn't get the list of GitHub repositories", e); return; } Collections.sort( availableRepos, new Comparator<GithubRepo>() { @Override public int compare(final GithubRepo r1, final GithubRepo 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(availableRepos.get(i).getCloneUrl()); } dialog.show(); if (!dialog.isOK()) { 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); }