Skip to content

Commit

Permalink
[fix] Confirm if user wants to reimport instead of disallowing it
Browse files Browse the repository at this point in the history
  • Loading branch information
agluszak committed Oct 3, 2024
1 parent cd8784c commit 8c234a2
Showing 1 changed file with 8 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,12 @@
import com.google.idea.blaze.base.wizard2.ProjectDataDirectoryValidator;
import com.google.idea.blaze.base.wizard2.WorkspaceTypeData;
import com.google.idea.common.experiments.BoolExperiment;
import com.intellij.icons.AllIcons;
import com.intellij.icons.AllIcons.General;
import com.intellij.ide.RecentProjectsManager;
import com.intellij.ide.util.PropertiesComponent;
import com.intellij.openapi.Disposable;
import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.application.ApplicationNamesInfo;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.fileChooser.FileChooserDescriptor;
Expand Down Expand Up @@ -465,9 +467,12 @@ public BlazeValidationResult validate() {
return BlazeValidationResult.failure(
new BlazeValidationError("Project data directory is not valid"));
}
if (projectDataDir.exists()) {
return BlazeValidationResult.failure(
new BlazeValidationError(projectDataDir + " already exists"));
if (projectDataDir.exists() && !ApplicationManager.getApplication().isUnitTestMode()) {
int result = Messages.showOkCancelDialog("This folder has already been imported by the Bazel plugin. Reimporting it can cause data loss.", "Possible Loss of Project Data", "OK", "Cancel", AllIcons.General.ShowWarning);

if (result == Messages.CANCEL) {
return BlazeValidationResult.cancelled();
}
}
for (ProjectDataDirectoryValidator validator :
ProjectDataDirectoryValidator.EP_NAME.getExtensions()) {
Expand Down

0 comments on commit 8c234a2

Please sign in to comment.