MAGETAB-74 modal committing form to github overlaps everything and hangs if git executable has not been specified.

This commit is contained in:
Oleg Shpynov
2011-06-08 11:34:19 +04:00
parent 15384474fd
commit 17ce5d86be
3 changed files with 30 additions and 2 deletions
@@ -41,6 +41,9 @@ public class GithubCheckoutProvider implements CheckoutProvider {
@Override
public void doCheckout(@NotNull final Project project, @Nullable final Listener listener) {
if (!GithubUtil.testGitExecutable(project)){
return;
}
BasicAction.saveAll();
final List<RepositoryInfo> availableRepos = GithubUtil.getAvailableRepos(project, false);
if (availableRepos == null){
@@ -17,7 +17,6 @@ import com.intellij.openapi.util.Computable;
import com.intellij.openapi.util.IconLoader;
import com.intellij.openapi.util.JDOMUtil;
import com.intellij.openapi.util.Ref;
import com.intellij.openapi.vcs.ProjectLevelVcsManager;
import com.intellij.openapi.vcs.VcsException;
import com.intellij.openapi.vcs.VcsOutgoingChangesProvider;
import com.intellij.openapi.vcs.changes.ChangeListManager;
@@ -26,7 +25,6 @@ import com.intellij.openapi.vcs.changes.actions.RefreshAction;
import com.intellij.openapi.vcs.versionBrowser.CommittedChangeList;
import com.intellij.openapi.vfs.VfsUtil;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.util.Consumer;
import com.intellij.util.containers.HashSet;
import git4idea.GitRemote;
import git4idea.GitUtil;
@@ -69,6 +67,9 @@ public class GithubShareAction extends DumbAwareAction {
@Override
public void actionPerformed(final AnActionEvent e) {
final Project project = e.getData(PlatformDataKeys.PROJECT);
if (!GithubUtil.testGitExecutable(project)){
return;
}
final VirtualFile root = project.getBaseDir();
// Check if git is already initialized and presence of remote branch
final boolean gitDetected = GitUtil.isUnderGit(root);
@@ -20,6 +20,7 @@ import com.intellij.openapi.progress.ProgressIndicator;
import com.intellij.openapi.progress.ProgressManager;
import com.intellij.openapi.progress.Task;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.ui.Messages;
import com.intellij.openapi.util.Computable;
import com.intellij.openapi.util.Ref;
import com.intellij.openapi.util.text.StringUtil;
@@ -28,6 +29,9 @@ import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.util.net.HttpConfigurable;
import git4idea.GitRemote;
import git4idea.GitUtil;
import git4idea.config.GitVcsApplicationSettings;
import git4idea.config.GitVersion;
import git4idea.i18n.GitBundle;
import org.apache.commons.httpclient.HttpClient;
import org.apache.commons.httpclient.HttpMethod;
import org.apache.commons.httpclient.UsernamePasswordCredentials;
@@ -388,4 +392,24 @@ public class GithubUtil {
}
});
}
public static boolean testGitExecutable(final Project project) {
final GitVcsApplicationSettings settings = GitVcsApplicationSettings.getInstance();
final String executable = settings.getPathToGit();
final GitVersion version;
try {
version = GitVersion.identifyVersion(executable);
} catch (Exception e) {
Messages.showErrorDialog(project, e.getMessage(), GitBundle.getString("find.git.error.title"));
return false;
}
if (!version.isSupported()) {
Messages.showWarningDialog(project, GitBundle.message("find.git.unsupported.message", version.toString(), GitVersion.MIN),
GitBundle.getString("find.git.success.title"));
return false;
}
return true;
}
}