From 0f93d4f37ad0f6e25a2bc389efcd2c8c386a6356 Mon Sep 17 00:00:00 2001 From: "Ilya.Kazakevich" Date: Wed, 28 May 2025 19:11:06 +0200 Subject: [PATCH] IJOB-596: Do not purge `.idea` directory. `training.project.ProjectUtils.protectedDirNames` is a set of dirs that should never be purged. Due to mistype, it was `idea`, not `.idea`. As result, it was purged, `modules.xml` was dropped with an expected result. GitOrigin-RevId: 2ee26f3b3e3ff7c65fb9fa9fd59760f9592bf8d4 --- .../src/training/project/ProjectUtils.kt | 16 ++++------------ .../featuresSuggester/ProjectUtilsTest.kt | 4 +++- 2 files changed, 7 insertions(+), 13 deletions(-) diff --git a/plugins/ide-features-trainer/src/training/project/ProjectUtils.kt b/plugins/ide-features-trainer/src/training/project/ProjectUtils.kt index 397b75e32b59..c8f62ac61d05 100644 --- a/plugins/ide-features-trainer/src/training/project/ProjectUtils.kt +++ b/plugins/ide-features-trainer/src/training/project/ProjectUtils.kt @@ -1,4 +1,4 @@ -// Copyright 2000-2022 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license. +// Copyright 2000-2025 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license. package training.project import com.intellij.ide.GeneralSettings @@ -33,23 +33,15 @@ import java.io.File import java.io.FileFilter import java.io.IOException import java.io.PrintWriter -import java.nio.file.FileVisitResult -import java.nio.file.FileVisitor -import java.nio.file.Files -import java.nio.file.Path -import java.nio.file.Paths +import java.nio.file.* import java.nio.file.attribute.BasicFileAttributes import java.util.concurrent.CompletableFuture -import kotlin.io.path.exists -import kotlin.io.path.getLastModifiedTime -import kotlin.io.path.isDirectory -import kotlin.io.path.name -import kotlin.io.path.pathString +import kotlin.io.path.* object ProjectUtils { private const val LEARNING_PROJECT_MODIFICATION = "LEARNING_PROJECT_MODIFICATION" private const val FEATURE_TRAINER_VERSION = "feature-trainer-version.txt" - private val protectedDirNames = hashSetOf("idea", ".git", "git", "venv") + private val protectedDirNames = hashSetOf(Project.DIRECTORY_STORE_FOLDER, ".git", "git", "venv") @ApiStatus.Internal diff --git a/plugins/ide-features-trainer/testSrc/training/featuresSuggester/ProjectUtilsTest.kt b/plugins/ide-features-trainer/testSrc/training/featuresSuggester/ProjectUtilsTest.kt index 917de54fbe97..cfd2d9a6d7e6 100644 --- a/plugins/ide-features-trainer/testSrc/training/featuresSuggester/ProjectUtilsTest.kt +++ b/plugins/ide-features-trainer/testSrc/training/featuresSuggester/ProjectUtilsTest.kt @@ -1,6 +1,7 @@ // Copyright 2000-2025 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license. package training.featuresSuggester +import com.intellij.openapi.project.Project import com.intellij.openapi.project.ProjectManager import com.intellij.testFramework.common.timeoutRunBlocking import com.intellij.testFramework.junit5.TestApplication @@ -41,9 +42,10 @@ class ProjectUtilsTest { val goodFiles = arrayOf( protectedFile, root.resolve("venv").createDirectory(), + root.resolve(Project.DIRECTORY_STORE_FOLDER).resolve("modules.xml").createDirectories(), root.resolve(".git").resolve("file").createParentDirectories().createFile()) - LangManager.Companion.getInstance().setLearningProjectPath(lang, root.pathString) + LangManager.getInstance().setLearningProjectPath(lang, root.pathString) ProjectUtils.restoreProject(lang, ProjectManager.getInstance().defaultProject) Assertions.assertFalse(badFile.exists(), "$badFile should have been deleted") for (goodFile in goodFiles) {