mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
RUBY-8360 GitHub plugin: can't share project on GitHub
This commit is contained in:
@@ -16,7 +16,6 @@
|
||||
package org.jetbrains.plugins.github;
|
||||
|
||||
import com.intellij.ide.passwordSafe.PasswordSafe;
|
||||
import com.intellij.ide.passwordSafe.PasswordSafeException;
|
||||
import com.intellij.openapi.components.PersistentStateComponent;
|
||||
import com.intellij.openapi.components.ServiceManager;
|
||||
import com.intellij.openapi.components.State;
|
||||
@@ -89,9 +88,8 @@ public class GithubSettings implements PersistentStateComponent<Element> {
|
||||
try {
|
||||
myPassword = PasswordSafe.getInstance().getPassword(ProjectManager.getInstance().getDefaultProject(), GithubSettings.class, GITHUB_SETTINGS_PASSWORD_KEY);
|
||||
}
|
||||
catch (PasswordSafeException e) {
|
||||
myPassword = null;
|
||||
return "";
|
||||
catch (Exception e) {
|
||||
myPassword = "";
|
||||
}
|
||||
}
|
||||
return myPassword;
|
||||
@@ -110,7 +108,7 @@ public class GithubSettings implements PersistentStateComponent<Element> {
|
||||
try {
|
||||
PasswordSafe.getInstance().storePassword(ProjectManager.getInstance().getDefaultProject(), GithubSettings.class, GITHUB_SETTINGS_PASSWORD_KEY, password);
|
||||
}
|
||||
catch (PasswordSafeException e) {
|
||||
catch (Exception e) {
|
||||
Messages.showErrorDialog("Error happened while storing password for github", "Error");
|
||||
LOG.error(e);
|
||||
}
|
||||
|
||||
@@ -158,6 +158,10 @@ public class GithubShareAction extends DumbAwareAction {
|
||||
}
|
||||
}, "Committing", false, project);
|
||||
}
|
||||
|
||||
// In this case we should create sample commit for binding project
|
||||
performFirstCommitIfRequired(project, root);
|
||||
|
||||
//git remote add origin git@github.com:login/name.git
|
||||
LOG.info("Adding GitHub as a remote host");
|
||||
final GitSimpleHandler addRemoteHandler = new GitSimpleHandler(project, root, GitCommand.REMOTE);
|
||||
@@ -176,36 +180,6 @@ public class GithubShareAction extends DumbAwareAction {
|
||||
LOG.info("Failed to add GitHub as remote: " + e.getMessage());
|
||||
return;
|
||||
}
|
||||
//git configure tracked branch
|
||||
LOG.info("Configuring tracked branch");
|
||||
final GitSimpleHandler configureTrackedHandler = new GitSimpleHandler(project, root, GitCommand.CONFIG);
|
||||
configureTrackedHandler.setNoSSH(true);
|
||||
configureTrackedHandler.setSilent(true);
|
||||
configureTrackedHandler.addParameters("branch.master.remote", "origin");
|
||||
|
||||
final GitSimpleHandler configureTrackedHandler2 = new GitSimpleHandler(project, root, GitCommand.CONFIG);
|
||||
configureTrackedHandler2.setNoSSH(true);
|
||||
configureTrackedHandler2.setSilent(true);
|
||||
configureTrackedHandler2.addParameters("branch.master.merge", "refs/heads/master");
|
||||
try {
|
||||
configureTrackedHandler.run();
|
||||
if (configureTrackedHandler.getExitCode() != 0) {
|
||||
Messages.showErrorDialog("Failed to configured tracked branch", "Failed to configured tracked branch");
|
||||
return;
|
||||
}
|
||||
configureTrackedHandler2.run();
|
||||
if (configureTrackedHandler2.getExitCode() != 0) {
|
||||
Messages.showErrorDialog("Failed to configured tracked branch", "Failed to configured tracked branch");
|
||||
return;
|
||||
}
|
||||
}
|
||||
catch (VcsException e) {
|
||||
Messages.showErrorDialog(e.getMessage(), "Failed to configured tracked branch");
|
||||
LOG.info("Failed to configured tracked branch: " + e.getMessage());
|
||||
return;
|
||||
}
|
||||
// In this case we should create sample commit for binding project
|
||||
performFirstCommitIfRequired(project, root);
|
||||
|
||||
//git push origin master
|
||||
final ProgressManager manager = ProgressManager.getInstance();
|
||||
@@ -217,7 +191,7 @@ public class GithubShareAction extends DumbAwareAction {
|
||||
progressIndicator.setText("Pushing to GitHub");
|
||||
}
|
||||
final GitLineHandler gitPushHandler = new GitLineHandler(project, root, GitCommand.PUSH);
|
||||
gitPushHandler.addParameters("origin", "master");
|
||||
gitPushHandler.addParameters("-u", "origin", "master");
|
||||
GitPushUtils.trackPushRejectedAsError(gitPushHandler, "Rejected push (" + root.getPresentableUrl() + "): ");
|
||||
errors.addAll(GitHandlerUtil.doSynchronouslyWithExceptions(gitPushHandler));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user