From 9774bc356a419d858baebf0b40e8261424a6478d Mon Sep 17 00:00:00 2001 From: Kirill Likhodedov Date: Wed, 13 Mar 2013 12:52:16 +0400 Subject: [PATCH] [github] Fix "Share project on Github": use native Git instead of JGit --- .../plugins/github/GithubShareAction.java | 34 +++++-------------- 1 file changed, 9 insertions(+), 25 deletions(-) diff --git a/plugins/github/src/org/jetbrains/plugins/github/GithubShareAction.java b/plugins/github/src/org/jetbrains/plugins/github/GithubShareAction.java index 07802c913717..01ee9ccc2af1 100644 --- a/plugins/github/src/org/jetbrains/plugins/github/GithubShareAction.java +++ b/plugins/github/src/org/jetbrains/plugins/github/GithubShareAction.java @@ -50,8 +50,6 @@ import git4idea.actions.BasicAction; import git4idea.actions.GitInit; import git4idea.commands.*; import git4idea.i18n.GitBundle; -import git4idea.jgit.GitHttpAdapter; -import git4idea.push.GitSimplePushResult; import git4idea.repo.GitRepository; import git4idea.repo.GitRepositoryManager; import git4idea.util.GitFileUtils; @@ -237,29 +235,15 @@ public class GithubShareAction extends DumbAwareAction { new Task.Backgroundable(project, "Pushing to GitHub", false) { @Override public void run(@NotNull ProgressIndicator indicator) { - GitSimplePushResult pushResult = GitHttpAdapter.push(repository, "origin", remoteUrl, "refs/heads/master:refs/heads/master"); - switch (pushResult.getType()) { - case NOT_PUSHED: - showPushError(project, "Push failed:
" + pushResult.getOutput()); - break; - case REJECT: - showPushError(project, "Push was rejected:
" + pushResult.getOutput()); - break; - case CANCEL: - Notificator.getInstance(project).notify(new Notification(GithubUtil.GITHUB_NOTIFICATION_GROUP, "Push cancelled", - "The project was created on GitHub but wasn't pushed yet.", NotificationType.WARNING)); - break; - case NOT_AUTHORIZED: - showPushError(project, "Push authorization failure:
" + pushResult.getOutput()); - break; - case ERROR: - showPushError(project, "Push failed:
" + pushResult.getOutput()); - break; - case SUCCESS: - Notificator.getInstance(project).notify(new Notification(GithubUtil.GITHUB_NOTIFICATION_GROUP, "Success", - "Successfully created project ''" + name + "'' on github", - NotificationType.INFORMATION)); - break; + Git git = ServiceManager.getService(Git.class); + GitCommandResult result = git.push(repository, "origin", remoteUrl, "refs/heads/master:refs/heads/master"); + if (result.success()) { + Notificator.getInstance(project).notify(new Notification(GithubUtil.GITHUB_NOTIFICATION_GROUP, "Success", + "Successfully created project '" + name + "' on GitHub", + NotificationType.INFORMATION)); + } + else { + showPushError(project, "Push failed:
" + result.getErrorOutputAsHtmlString()); } } }.queue();