use of org.jetbrains.plugins.github.exceptions.GithubStatusCodeException in project intellij-community by JetBrains.
the class GithubShareAction method checkExistingRemote.
private static boolean checkExistingRemote(@NotNull final Project project, @NotNull final GithubAuthDataHolder authHolder, @NotNull String remote) {
final GithubFullPath path = GithubUrlUtil.getUserAndRepositoryFromRemoteUrl(remote);
if (path == null) {
return GithubNotifications.showYesNoDialog(project, "Project Is Already on GitHub", "Can't connect to repository from configured remote. You could want to check .git config.\n" + "Do you want to proceed anyway?");
}
try {
GithubRepo repo = GithubUtil.computeValueInModalIO(project, "Access to GitHub", indicator -> GithubUtil.runTask(project, authHolder, indicator, connection -> GithubApiUtil.getDetailedRepoInfo(connection, path.getUser(), path.getRepository())));
int result = Messages.showDialog(project, "Successfully connected to " + repo.getHtmlUrl() + ".\n" + "Do you want to proceed anyway?", "Project Is Already on GitHub", new String[] { "Continue", "Open in Browser", Messages.CANCEL_BUTTON }, 2, Messages.getQuestionIcon());
if (result == 0)
return true;
if (result == 1) {
BrowserUtil.browse(repo.getHtmlUrl());
}
return false;
} catch (GithubStatusCodeException e) {
if (e.getStatusCode() == HttpStatus.SC_NOT_FOUND) {
return GithubNotifications.showYesNoDialog(project, "Project Is Already on GitHub", "Can't connect to repository from configured remote. You could want to check .git config.\n" + "Do you want to proceed anyway?");
}
GithubNotifications.showErrorDialog(project, "Failed to Connect to GitHub", e);
return false;
} catch (IOException e) {
GithubNotifications.showErrorDialog(project, "Failed to Connect to GitHub", e);
return false;
}
}
Aggregations