mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
Merge branch 'master' of git.labs.intellij.net:idea/community
This commit is contained in:
+1
-1
@@ -6,7 +6,7 @@
|
||||
|
||||
:: ---------------------------------------------------------------------
|
||||
:: Before you run IntelliJ IDEA specify the location of the
|
||||
:: JDK 1.5 installation directory which will be used for running IDEA
|
||||
:: JDK 1.6 installation directory which will be used for running IDEA
|
||||
:: ---------------------------------------------------------------------
|
||||
IF "%IDEA_JDK%" == "" SET IDEA_JDK=%JDK_HOME%
|
||||
IF "%IDEA_JDK%" == "" goto error
|
||||
|
||||
@@ -0,0 +1,51 @@
|
||||
IntelliJ IDEA
|
||||
|
||||
INSTALLATION INSTRUCTIONS
|
||||
===============================================================================
|
||||
|
||||
Linux Installation Instructions
|
||||
------------------------------------------------------------------------------
|
||||
1. Unpack the IntelliJ IDEA distribution file that you downloaded to
|
||||
where you wish to install the program. We will refer to this destination
|
||||
location as your {installation home} below.
|
||||
|
||||
2. Open a console and cd into "{installation home}/bin" and type:
|
||||
|
||||
./idea.sh
|
||||
|
||||
to start the application.
|
||||
|
||||
3. [OPTIONAL] Add the "{installation home}/bin" to your PATH environmental
|
||||
variable so that you may start IntelliJ IDEA from any directory.
|
||||
|
||||
4. [OPTIONAL] To adjust the value of JVM heap size open idea.vmoptions and
|
||||
modify the -Xms and -Xmx parameters.
|
||||
|
||||
|
||||
[OPTIONAL] Changing location of "config" and "system" directory
|
||||
------------------------------------------------------------------------------
|
||||
By default IDEA stores all your settings under ~/.IntelliJIdea10/config directory
|
||||
and stores data cache under ~/.IntelliJIdea10/system directory.
|
||||
If you want to change these settings,
|
||||
|
||||
1. Open a console and cd into "{installation home}/bin"
|
||||
|
||||
2. Open file "idea.properties" in an editor. You should find strings like
|
||||
|
||||
idea.system.path=~/.IntelliJIdea10/system
|
||||
|
||||
and
|
||||
|
||||
idea.config.path=~/.IntelliJIdea10/config
|
||||
|
||||
and change them.
|
||||
|
||||
3. Note that we recommend to store data cache ("system" directory) at a disk
|
||||
with at least 1G bytes free space
|
||||
|
||||
|
||||
|
||||
|
||||
Enjoy!
|
||||
|
||||
-IntelliJ IDEA Development Team
|
||||
@@ -198,6 +198,7 @@ def layoutLinux(Map args, String home, Paths paths) {
|
||||
fileset(dir: "$home/bin/nix")
|
||||
fileset(dir: "$home/build/images")
|
||||
}
|
||||
fileset(dir: "$home/build", includes: "Install-Linux-tar.txt")
|
||||
}
|
||||
|
||||
patchPropertiesFile(paths.distUnix)
|
||||
|
||||
@@ -18,8 +18,8 @@
|
||||
<feedback eap-url="http://youtrack.jetbrains.net" release-url="http://www.jetbrains.com/feedback/feedback.jsp?product=IDEA&build=$BUILD&timezone=$TIMEZONE&eval=$EVAL"/>
|
||||
<plugins url="http://plugins.intellij.net"/>
|
||||
<whatsnew url="http://www.jetbrains.com/idea/whatsnew/index.html"/>
|
||||
<keymap win="http://www.jetbrains.com/idea/docs/IntelliJIDEA9_ReferenceCard.pdf"
|
||||
mac="http://www.jetbrains.com/idea/docs/IntelliJIDEA9_ReferenceCard_Mac.pdf"/>
|
||||
<keymap win="http://www.jetbrains.com/idea/docs/IntelliJIDEA_ReferenceCard.pdf"
|
||||
mac="http://www.jetbrains.com/idea/docs/IntelliJIDEA_ReferenceCard_Mac.pdf"/>
|
||||
|
||||
<plugins-page category="VCS Integration" title="Select VCS Integration Plugins"/>
|
||||
<plugins-page title="Select Other Plugins"/>
|
||||
|
||||
@@ -17,12 +17,15 @@ package com.intellij.psi.formatter.java;
|
||||
|
||||
import com.intellij.formatting.*;
|
||||
import com.intellij.lang.ASTNode;
|
||||
import com.intellij.psi.JavaTokenType;
|
||||
import com.intellij.psi.codeStyle.CodeStyleSettings;
|
||||
import com.intellij.psi.formatter.FormatterUtil;
|
||||
import com.intellij.psi.impl.source.tree.ElementType;
|
||||
import com.intellij.psi.impl.source.tree.JavaDocElementType;
|
||||
import com.intellij.psi.impl.source.tree.JavaElementType;
|
||||
import com.intellij.psi.impl.source.tree.StdTokenSets;
|
||||
import com.intellij.psi.tree.IElementType;
|
||||
import com.intellij.psi.tree.TokenSet;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.ArrayList;
|
||||
@@ -30,6 +33,10 @@ import java.util.List;
|
||||
|
||||
public class BlockContainingJavaBlock extends AbstractJavaBlock{
|
||||
|
||||
private static final TokenSet TYPES_OF_STATEMENTS_WITH_OPTIONAL_BRACES = TokenSet.create(
|
||||
JavaElementType.IF_STATEMENT, JavaElementType.WHILE_STATEMENT, JavaElementType.FOR_STATEMENT
|
||||
);
|
||||
|
||||
private final static int BEFORE_FIRST = 0;
|
||||
private final static int BEFORE_BLOCK = 1;
|
||||
private final static int AFTER_ELSE = 2;
|
||||
@@ -207,12 +214,37 @@ public class BlockContainingJavaBlock extends AbstractJavaBlock{
|
||||
return new ChildAttributes(getCodeBlockExternalIndent(), null);
|
||||
}
|
||||
|
||||
boolean useExternalIndent = false;
|
||||
if (newChildIndex == getSubBlocks().size()) {
|
||||
useExternalIndent = true;
|
||||
}
|
||||
else if (TYPES_OF_STATEMENTS_WITH_OPTIONAL_BRACES.contains(myNode.getElementType())) {
|
||||
// There is a possible case that we have situation like below:
|
||||
// if (true) <enter was pressed here>
|
||||
// <caret>
|
||||
// System.out.println();
|
||||
// We would like to indent current caret position then because there is a high probability that the user starts
|
||||
// typing there (populating statement body). So, we perform dedicated check for that here and use 'external indent'
|
||||
// if necessary.
|
||||
Block prevBlock = getSubBlocks().get(newChildIndex - 1);
|
||||
Block nextBlock = getSubBlocks().get(newChildIndex);
|
||||
if (prevBlock instanceof ASTBlock && nextBlock instanceof ASTBlock) {
|
||||
ASTNode prevNode = ((ASTBlock)prevBlock).getNode();
|
||||
ASTNode nextNode = ((ASTBlock)nextBlock).getNode();
|
||||
if (prevNode != null && nextNode != null && prevNode.getElementType() == JavaTokenType.RPARENTH
|
||||
&& nextNode.getElementType() != JavaTokenType.LBRACE)
|
||||
{
|
||||
useExternalIndent = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (useExternalIndent) {
|
||||
return new ChildAttributes(getCodeBlockChildExternalIndent(newChildIndex), null);
|
||||
}
|
||||
|
||||
return new ChildAttributes(myIndentsBefore.get(newChildIndex), null);
|
||||
|
||||
else {
|
||||
return new ChildAttributes(myIndentsBefore.get(newChildIndex), null);
|
||||
}
|
||||
}
|
||||
|
||||
private boolean isInsideForParens(final int newChildIndex) {
|
||||
|
||||
@@ -240,8 +240,7 @@ public abstract class CodeInsightTestCase extends PsiTestCase {
|
||||
}
|
||||
}));
|
||||
|
||||
// grand VFS refresh significantly slows down local tests and generally not needed
|
||||
//VirtualFileManager.getInstance().refresh(false);
|
||||
toDir.refresh(false, true);
|
||||
}
|
||||
else {
|
||||
editorInfos = new LinkedHashMap<VirtualFile, EditorInfo>();
|
||||
|
||||
@@ -595,13 +595,6 @@ public abstract class PlatformTestCase extends UsefulTestCase implements DataPro
|
||||
public static File createTempDir(@NonNls final String prefix) throws IOException {
|
||||
final File tempDirectory = FileUtil.createTempDirectory(TEST_DIR_PREFIX + prefix, null);
|
||||
myFilesToDelete.add(tempDirectory);
|
||||
// grand VFS refresh significantly slows down local tests and generally not needed
|
||||
//ApplicationManager.getApplication().runWriteAction(new Runnable() {
|
||||
// @Override
|
||||
// public void run() {
|
||||
// VirtualFileManager.getInstance().refresh(false);
|
||||
// }
|
||||
//});
|
||||
return tempDirectory;
|
||||
}
|
||||
|
||||
|
||||
@@ -613,6 +613,29 @@ public abstract class AndroidRunningState implements RunProfileState, AndroidDeb
|
||||
return true;
|
||||
}
|
||||
|
||||
private class MyISyncProgressMonitor implements SyncService.ISyncProgressMonitor {
|
||||
@Override
|
||||
public void start(int totalWork) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void stop() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCanceled() {
|
||||
return myStopped;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void startSubTask(String name) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void advance(int work) {
|
||||
}
|
||||
}
|
||||
|
||||
private boolean uploadApp(IDevice device, String remotePath, String localPath) throws IOException {
|
||||
if (myStopped) return false;
|
||||
getProcessHandler().notifyTextAvailable("Uploading file\n\tlocal path: " + localPath + "\n\tremote path: " + remotePath + '\n', STDOUT);
|
||||
@@ -621,12 +644,57 @@ public abstract class AndroidRunningState implements RunProfileState, AndroidDeb
|
||||
getProcessHandler().notifyTextAvailable("Can't upload file: device is not available.\n", STDERR);
|
||||
return false;
|
||||
}
|
||||
SyncService.SyncResult result = service.pushFile(localPath, remotePath, SyncService.getNullProgressMonitor());
|
||||
if (result.getCode() != SyncService.RESULT_OK) {
|
||||
getProcessHandler().notifyTextAvailable("Can't upload file: " + result.getMessage() + ".\n", STDERR);
|
||||
return false;
|
||||
SyncService.SyncResult result = service.pushFile(localPath, remotePath, new MyISyncProgressMonitor());
|
||||
int code = result.getCode();
|
||||
String errorMessage;
|
||||
switch (code) {
|
||||
case SyncService.RESULT_OK:
|
||||
return true;
|
||||
case SyncService.RESULT_CANCELED:
|
||||
errorMessage = "Command canceled";
|
||||
break;
|
||||
case SyncService.RESULT_CONNECTION_ERROR:
|
||||
errorMessage = "Connection error";
|
||||
break;
|
||||
case SyncService.RESULT_CONNECTION_TIMEOUT:
|
||||
errorMessage = "Connection timeout";
|
||||
break;
|
||||
case SyncService.RESULT_FILE_READ_ERROR:
|
||||
errorMessage = "Cannot read the file";
|
||||
break;
|
||||
case SyncService.RESULT_FILE_WRITE_ERROR:
|
||||
errorMessage = "Cannot write the file";
|
||||
break;
|
||||
case SyncService.RESULT_LOCAL_IS_DIRECTORY:
|
||||
errorMessage = "Local is directory";
|
||||
break;
|
||||
case SyncService.RESULT_NO_DIR_TARGET:
|
||||
errorMessage = "Target directory not found";
|
||||
break;
|
||||
case SyncService.RESULT_NO_LOCAL_FILE:
|
||||
errorMessage = "Local file not found";
|
||||
break;
|
||||
case SyncService.RESULT_NO_REMOTE_OBJECT:
|
||||
errorMessage = "No remote object";
|
||||
break;
|
||||
case SyncService.RESULT_REMOTE_IS_FILE:
|
||||
errorMessage = "Remote is a file";
|
||||
break;
|
||||
case SyncService.RESULT_REMOTE_PATH_ENCODING:
|
||||
errorMessage = "Incorrect remote path encoding";
|
||||
break;
|
||||
case SyncService.RESULT_REMOTE_PATH_LENGTH:
|
||||
errorMessage = "Incorrect remote path length";
|
||||
break;
|
||||
case SyncService.RESULT_TARGET_IS_FILE:
|
||||
errorMessage = "Target is a file";
|
||||
break;
|
||||
default:
|
||||
errorMessage = "Can't upload file";
|
||||
}
|
||||
return true;
|
||||
getProcessHandler()
|
||||
.notifyTextAvailable(errorMessage + (result.getMessage() != null ? "\n" + result.getMessage() + "\n" : "\n"), STDERR);
|
||||
return false;
|
||||
}
|
||||
|
||||
@SuppressWarnings({"DuplicateThrows"})
|
||||
@@ -676,13 +744,13 @@ public abstract class AndroidRunningState implements RunProfileState, AndroidDeb
|
||||
executeDeviceCommandAndWriteToConsole(device, "pm install -r \"" + remotePath + '\"', receiver);
|
||||
if (myStopped) return false;
|
||||
}*/
|
||||
if (!isSuccess(receiver)) {
|
||||
/*if (!isSuccess(receiver)) {
|
||||
getProcessHandler().notifyTextAvailable("Can't reinstall application. Installing from scratch.\n", STDOUT);
|
||||
executeDeviceCommandAndWriteToConsole(device, "pm uninstall \"" + remotePath + '\"', receiver);
|
||||
if (myStopped) return false;
|
||||
executeDeviceCommandAndWriteToConsole(device, "pm install \"" + remotePath + '\"', receiver);
|
||||
if (myStopped) return false;
|
||||
}
|
||||
}*/
|
||||
boolean success = isSuccess(receiver);
|
||||
getProcessHandler().notifyTextAvailable(receiver.output.toString(), success ? STDOUT : STDERR);
|
||||
return success;
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
package org.jetbrains.android.sdk;
|
||||
|
||||
import com.android.ddmlib.AndroidDebugBridge;
|
||||
import com.android.ddmlib.DdmPreferences;
|
||||
import com.android.sdklib.IAndroidTarget;
|
||||
import com.android.sdklib.ISdkLog;
|
||||
import com.android.sdklib.SdkConstants;
|
||||
@@ -145,6 +146,7 @@ public abstract class AndroidSdk {
|
||||
String adbPath = getAdbPath();
|
||||
if (!myDdmLibInitialized) {
|
||||
myDdmLibInitialized = true;
|
||||
DdmPreferences.setTimeOut(AndroidUtils.TIMEOUT);
|
||||
AndroidDebugBridge.init(AndroidEnableDdmsAction.isDdmsEnabled());
|
||||
AndroidDebugBridge.createBridge(adbPath, true);
|
||||
}
|
||||
|
||||
@@ -119,7 +119,7 @@ public class AndroidUtils {
|
||||
public static final String EXT_NATIVE_LIB = "so";
|
||||
@NonNls public static final String RES_OVERLAY_DIR_NAME = "res-overlay";
|
||||
|
||||
private static final int TIMEOUT = 30000;
|
||||
public static final int TIMEOUT = 30000;
|
||||
|
||||
private AndroidUtils() {
|
||||
}
|
||||
|
||||
@@ -23,6 +23,9 @@
|
||||
<action id="Github.Rebase" class="org.jetbrains.plugins.github.GithubRebaseAction">
|
||||
<add-to-group group-id="VcsGlobalGroup"/>
|
||||
</action>
|
||||
<action id="Github.Open.In.Browser" class="org.jetbrains.plugins.github.GithubOpenInBrowserAction">
|
||||
<add-to-group group-id="EditorPopupMenu"/>
|
||||
</action>
|
||||
<action id="Github.Rebase.Internal" class="org.jetbrains.plugins.github.GithubRebase"/>
|
||||
</actions>
|
||||
</idea-plugin>
|
||||
@@ -0,0 +1,136 @@
|
||||
/*
|
||||
* Copyright 2000-2010 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.jetbrains.plugins.github;
|
||||
|
||||
import com.intellij.ide.BrowserUtil;
|
||||
import com.intellij.openapi.actionSystem.AnActionEvent;
|
||||
import com.intellij.openapi.actionSystem.PlatformDataKeys;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.project.DumbAwareAction;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.roots.ProjectRootManager;
|
||||
import com.intellij.openapi.ui.Messages;
|
||||
import com.intellij.openapi.util.IconLoader;
|
||||
import com.intellij.openapi.vcs.VcsException;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import git4idea.GitRemote;
|
||||
import git4idea.GitUtil;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Created by IntelliJ IDEA.
|
||||
*
|
||||
* @author oleg
|
||||
* @date 12/10/10
|
||||
*/
|
||||
public class GithubOpenInBrowserAction extends DumbAwareAction {
|
||||
public static final Icon ICON = IconLoader.getIcon("/icons/github.png");
|
||||
private static final Logger LOG = Logger.getInstance(GithubOpenInBrowserAction.class.getName());
|
||||
private static final String CANNOT_OPEN_IN_BROWSER = "Cannot open in browser";
|
||||
|
||||
protected GithubOpenInBrowserAction() {
|
||||
super("Open in browser", "Open corresponding GitHub link in browser", ICON);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update(final AnActionEvent e) {
|
||||
final Project project = e.getData(PlatformDataKeys.PROJECT);
|
||||
final VirtualFile virtualFile = e.getData(PlatformDataKeys.VIRTUAL_FILE);
|
||||
if (project == null || project.isDefault() || virtualFile == null) {
|
||||
e.getPresentation().setEnabled(false);
|
||||
return;
|
||||
}
|
||||
if (GithubUtil.getGithubBoundRepository(project) == null){
|
||||
e.getPresentation().setEnabled(false);
|
||||
return;
|
||||
}
|
||||
e.getPresentation().setEnabled(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void actionPerformed(final AnActionEvent e) {
|
||||
final Project project = e.getData(PlatformDataKeys.PROJECT);
|
||||
|
||||
final VirtualFile[] roots = ProjectRootManager.getInstance(project).getContentRoots();
|
||||
if (roots.length == 0) {
|
||||
Messages.showErrorDialog(project, "Project doesn't have any project roots", CANNOT_OPEN_IN_BROWSER);
|
||||
return;
|
||||
}
|
||||
final VirtualFile root = roots[0];
|
||||
// Check if git is already initialized and presence of remote branch
|
||||
final boolean gitDetected = GitUtil.isUnderGit(root);
|
||||
if (!gitDetected) {
|
||||
Messages.showErrorDialog(project, "Cannot find any git repository configured for the project", CANNOT_OPEN_IN_BROWSER);
|
||||
return;
|
||||
}
|
||||
final VirtualFile virtualFile = e.getData(PlatformDataKeys.VIRTUAL_FILE);
|
||||
final String rootPath = root.getPath();
|
||||
final String path = virtualFile.getPath();
|
||||
if (!path.startsWith(rootPath)){
|
||||
Messages.showErrorDialog(project, "File is not under project root", CANNOT_OPEN_IN_BROWSER);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
try {
|
||||
// Check that given repository is properly configured git repository
|
||||
GitRemote githubRemote = null;
|
||||
final List<GitRemote> gitRemotes = GitRemote.list(project, root);
|
||||
if (gitRemotes.isEmpty()) {
|
||||
Messages.showErrorDialog(project, "Git repository doesn't have any remotes configured", CANNOT_OPEN_IN_BROWSER);
|
||||
return;
|
||||
}
|
||||
for (GitRemote gitRemote : gitRemotes) {
|
||||
if (gitRemote.pushUrl().contains("git@github.com")) {
|
||||
githubRemote = gitRemote;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (githubRemote == null) {
|
||||
Messages.showErrorDialog(project, "Configured own github repository is not found", CANNOT_OPEN_IN_BROWSER);
|
||||
return;
|
||||
}
|
||||
|
||||
final String pushUrl = githubRemote.pushUrl();
|
||||
final String login = GithubSettings.getInstance().getLogin();
|
||||
final int index = pushUrl.lastIndexOf(login);
|
||||
if (index == -1) {
|
||||
Messages.showErrorDialog(project, "Github remote repository doesn't seem to be your own repository: " + pushUrl,
|
||||
CANNOT_OPEN_IN_BROWSER);
|
||||
return;
|
||||
}
|
||||
String repoName = pushUrl.substring(index + login.length() + 1);
|
||||
if (repoName.endsWith(".git")) {
|
||||
repoName = repoName.substring(0, repoName.length() - 4);
|
||||
}
|
||||
final RepositoryInfo repositoryInfo = GithubUtil.getDetailedRepositoryInfo(project, repoName);
|
||||
if (repositoryInfo == null) {
|
||||
Messages
|
||||
.showErrorDialog(project, "Github repository doesn't seem to be your own repository: " + pushUrl, CANNOT_OPEN_IN_BROWSER);
|
||||
return;
|
||||
}
|
||||
// TODO[oleg] support custom branches here
|
||||
BrowserUtil.launchBrowser("https://github.com/" + login + "/" + repoName + "/blob/master" + path.substring(rootPath.length()));
|
||||
|
||||
} catch (VcsException e1){
|
||||
Messages.showErrorDialog(project, "Error happened during git operation: " + e1.getMessage(), CANNOT_OPEN_IN_BROWSER);
|
||||
return;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -26,7 +26,6 @@ import com.intellij.openapi.ui.Messages;
|
||||
import com.intellij.openapi.util.IconLoader;
|
||||
import com.intellij.openapi.vcs.VcsException;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import git4idea.GitBranch;
|
||||
import git4idea.GitRemote;
|
||||
import git4idea.GitUtil;
|
||||
import git4idea.actions.BasicAction;
|
||||
@@ -45,6 +44,7 @@ import java.util.List;
|
||||
public class GithubRebaseAction extends DumbAwareAction {
|
||||
public static final Icon ICON = IconLoader.getIcon("/icons/github.png");
|
||||
private static final Logger LOG = Logger.getInstance(GithubRebaseAction.class.getName());
|
||||
private static final String CANNOT_PERFORM_GITHUB_REBASE = "Cannot perform github rebase";
|
||||
|
||||
public GithubRebaseAction() {
|
||||
super("Rebase my fork", "Rebase your forked repository relative to the origin", ICON);
|
||||
@@ -56,6 +56,10 @@ public class GithubRebaseAction extends DumbAwareAction {
|
||||
e.getPresentation().setEnabled(false);
|
||||
return;
|
||||
}
|
||||
if (GithubUtil.getGithubBoundRepository(project) == null){
|
||||
e.getPresentation().setEnabled(false);
|
||||
return;
|
||||
}
|
||||
e.getPresentation().setEnabled(true);
|
||||
}
|
||||
|
||||
@@ -64,54 +68,29 @@ public class GithubRebaseAction extends DumbAwareAction {
|
||||
final Project project = e.getData(PlatformDataKeys.PROJECT);
|
||||
final VirtualFile[] roots = ProjectRootManager.getInstance(project).getContentRoots();
|
||||
if (roots.length == 0) {
|
||||
Messages.showErrorDialog(project, "Project doesn't have any project roots", "Cannot create new GitHub repository");
|
||||
Messages.showErrorDialog(project, "Project doesn't have any project roots", CANNOT_PERFORM_GITHUB_REBASE);
|
||||
return;
|
||||
}
|
||||
final VirtualFile root = roots[0];
|
||||
// Check if git is already initialized and presence of remote branch
|
||||
final boolean gitDetected = GitUtil.isUnderGit(root);
|
||||
if (!gitDetected) {
|
||||
Messages.showErrorDialog(project, "Cannot find any git repository configured for the project", "Cannot perform github rebase");
|
||||
Messages.showErrorDialog(project, "Cannot find any git repository configured for the project", CANNOT_PERFORM_GITHUB_REBASE);
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
// Check current branch
|
||||
final GitBranch currentBranch = GitBranch.current(project, root);
|
||||
if (currentBranch == null) {
|
||||
Messages.showErrorDialog(project, "Cannot find current branch", "Cannot perform github rebase");
|
||||
return;
|
||||
}
|
||||
if (!"master".equals(currentBranch.getName())) {
|
||||
Messages.showErrorDialog(project, "Cannot perform rebase with '" + currentBranch.getName() + "' branch.\nPlease switch to master",
|
||||
"Cannot perform github rebase");
|
||||
return;
|
||||
}
|
||||
|
||||
// Check that given repository is properly configured git repository
|
||||
GitRemote githubRemote = null;
|
||||
final GitRemote githubRemote = GithubUtil.getGithubBoundRepository(project);
|
||||
final List<GitRemote> gitRemotes = GitRemote.list(project, root);
|
||||
if (gitRemotes.isEmpty()) {
|
||||
Messages.showErrorDialog(project, "Git repository doesn't have any remotes configured", "Cannot perform github rebase");
|
||||
return;
|
||||
}
|
||||
for (GitRemote gitRemote : gitRemotes) {
|
||||
if (gitRemote.pushUrl().contains("git@github.com")) {
|
||||
githubRemote = gitRemote;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (githubRemote == null) {
|
||||
Messages.showErrorDialog(project, "Configured own github repository is not found", "Cannot perform github rebase");
|
||||
return;
|
||||
}
|
||||
LOG.assertTrue(githubRemote != null);
|
||||
|
||||
final String pushUrl = githubRemote.pushUrl();
|
||||
final String login = GithubSettings.getInstance().getLogin();
|
||||
final int index = pushUrl.lastIndexOf(login);
|
||||
if (index == -1) {
|
||||
Messages.showErrorDialog(project, "Github remote repository doesn't seem to be your own repository: " + pushUrl,
|
||||
"Cannot perform github rebase");
|
||||
CANNOT_PERFORM_GITHUB_REBASE);
|
||||
return;
|
||||
}
|
||||
String repoName = pushUrl.substring(index + login.length() + 1);
|
||||
@@ -122,12 +101,12 @@ public class GithubRebaseAction extends DumbAwareAction {
|
||||
final RepositoryInfo repositoryInfo = GithubUtil.getDetailedRepositoryInfo(project, repoName);
|
||||
if (repositoryInfo == null) {
|
||||
Messages
|
||||
.showErrorDialog(project, "Github repository doesn't seem to be your own repository: " + pushUrl, "Cannot perform github rebase");
|
||||
.showErrorDialog(project, "Github repository doesn't seem to be your own repository: " + pushUrl, CANNOT_PERFORM_GITHUB_REBASE);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!repositoryInfo.isFork()) {
|
||||
Messages.showErrorDialog(project, "Github repository '" + repoName + "' is not a forked one", "Cannot perform github rebase");
|
||||
Messages.showErrorDialog(project, "Github repository '" + repoName + "' is not a forked one", CANNOT_PERFORM_GITHUB_REBASE);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -161,7 +140,7 @@ public class GithubRebaseAction extends DumbAwareAction {
|
||||
addRemoteHandler.addParameters("add", repoName, parentRepoUrl);
|
||||
addRemoteHandler.run();
|
||||
if (addRemoteHandler.getExitCode() != 0) {
|
||||
Messages.showErrorDialog("Failed to add GitHub remote: '" + parentRepoUrl + "'", "Failed to add GitHub remote");
|
||||
Messages.showErrorDialog("Failed to add GitHub remote: '" + parentRepoUrl + "'", CANNOT_PERFORM_GITHUB_REBASE);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -175,7 +154,7 @@ public class GithubRebaseAction extends DumbAwareAction {
|
||||
action.actionPerformed(actionEvent);
|
||||
}
|
||||
catch (VcsException e1) {
|
||||
Messages.showErrorDialog(project, "Error happened during git operation: " + e1.getMessage(), "Cannot perform github rebase");
|
||||
Messages.showErrorDialog(project, "Error happened during git operation: " + e1.getMessage(), CANNOT_PERFORM_GITHUB_REBASE);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,9 +5,14 @@ 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.roots.ProjectRootManager;
|
||||
import com.intellij.openapi.util.Computable;
|
||||
import com.intellij.openapi.util.JDOMUtil;
|
||||
import com.intellij.openapi.util.Ref;
|
||||
import com.intellij.openapi.vcs.VcsException;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import git4idea.GitRemote;
|
||||
import git4idea.GitUtil;
|
||||
import org.apache.commons.httpclient.HttpClient;
|
||||
import org.apache.commons.httpclient.HttpMethod;
|
||||
import org.apache.commons.httpclient.UsernamePasswordCredentials;
|
||||
@@ -236,4 +241,30 @@ public class GithubUtil {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static GitRemote getGithubBoundRepository(final Project project){
|
||||
final VirtualFile[] roots = ProjectRootManager.getInstance(project).getContentRoots();
|
||||
if (roots.length == 0) {
|
||||
return null;
|
||||
}
|
||||
final VirtualFile root = roots[0];
|
||||
// Check if git is already initialized and presence of remote branch
|
||||
final boolean gitDetected = GitUtil.isUnderGit(root);
|
||||
if (!gitDetected) {
|
||||
return null;
|
||||
}
|
||||
try {
|
||||
// Check that given repository is properly configured git repository
|
||||
final List<GitRemote> gitRemotes = GitRemote.list(project, root);
|
||||
for (GitRemote gitRemote : gitRemotes) {
|
||||
if (gitRemote.pushUrl().contains("git@github.com")) {
|
||||
return gitRemote;
|
||||
}
|
||||
}
|
||||
} catch (VcsException e){
|
||||
// ignore
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user