EA-33321 and other NPE; made static methods static
authorKirill Likhodedov <Kirill.Likhodedov@jetbrains.com>
Tue, 31 Jan 2012 09:59:15 +0000 (13:59 +0400)
committerKirill Likhodedov <Kirill.Likhodedov@jetbrains.com>
Tue, 31 Jan 2012 09:59:15 +0000 (13:59 +0400)
plugins/github/src/org/jetbrains/plugins/github/GithubCheckoutListener.java

index 3b059e090d10797360b80066596d832e620278a6..5c812548caf3645f0077eebb9d7cbdcc097841df 100644 (file)
@@ -39,10 +39,13 @@ public class GithubCheckoutListener implements CheckoutListener {
   }
 
   @Nullable
-  private Pair<String, String> getGithubProjectInfo(final Project project) {
+  private static Pair<String, String> getGithubProjectInfo(final Project project) {
     final VirtualFile root = project.getBaseDir();
+    if (root == null) {
+      return null;
+    }
     // Check if git is already initialized and presence of remote branch
-    final GitRepository gitRepository = GitRepositoryManager.getInstance(project).getRepositoryForFile(project.getBaseDir());
+    final GitRepository gitRepository = GitRepositoryManager.getInstance(project).getRepositoryForFile(root);
     if (gitRepository == null){
       return null;
     }
@@ -53,6 +56,9 @@ public class GithubCheckoutListener implements CheckoutListener {
       return null;
     }
     String url = GithubUtil.getGithubUrl(gitRemote);
+    if (url == null) {
+      return null;
+    }
     int i = url.lastIndexOf("/");
     if (i == -1){
       return null;
@@ -77,7 +83,7 @@ public class GithubCheckoutListener implements CheckoutListener {
     return Pair.create(author, name);
   }
 
-  private void processProject(final Project openedProject, final GithubSettings settings, final String author, final String name) {
+  private static void processProject(final Project openedProject, final GithubSettings settings, final String author, final String name) {
     // try to enable git tasks integration
     final Runnable taskInitializationRunnable = new Runnable() {
       public void run() {
@@ -96,11 +102,11 @@ public class GithubCheckoutListener implements CheckoutListener {
     }
   }
 
-  private void enableGithubTrackerIntegration(final Project project,
-                                              final String login,
-                                              final String password,
-                                              final String author,
-                                              final String name) {
+  private static void enableGithubTrackerIntegration(final Project project,
+                                                     final String login,
+                                                     final String password,
+                                                     final String author,
+                                                     final String name) {
     // Look for github repository type
     final TaskManagerImpl manager = (TaskManagerImpl)TaskManager.getManager(project);
     final TaskRepository[] allRepositories = manager.getAllRepositories();