Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ const val MAVEN_BUILD_SKIP_UNIT_TESTS = "clean test-compile"
const val MAVEN_DEFAULT_BUILD_DIRECTORY_NAME = "target"
const val IDEA_DIRECTORY_NAME = ".idea"
const val GIT_DIRECTORY_NAME = ".git"
const val GITHUB_DIRECTORY_NAME = ".github"
const val DS_STORE_FILE_NAME = ".DS_Store"
const val INVALID_SUFFIX_SHA = "sha1"
const val INVALID_SUFFIX_REPOSITORIES = "repositories"
Expand Down Expand Up @@ -92,14 +93,12 @@ data class CodeModernizerSessionContext(
return isMavenTargetDirName && hasPomSibling
}

private fun File.isIdeaFolder(): Boolean = this.isDirectory && this.name == IDEA_DIRECTORY_NAME

private fun File.isGitFolder(): Boolean = this.isDirectory && this.name == GIT_DIRECTORY_NAME
private fun File.isInvalidFolder(): Boolean = this.isDirectory && this.name in listOf(IDEA_DIRECTORY_NAME, GIT_DIRECTORY_NAME, GITHUB_DIRECTORY_NAME)

private fun findDirectoriesToExclude(sourceFolder: File): List<File> {
val excluded = mutableListOf<File>()
sourceFolder.walkTopDown().onEnter {
if (it.isMavenTargetFolder() || it.isIdeaFolder() || it.isGitFolder()) {
if (it.isMavenTargetFolder() || it.isInvalidFolder()) {
excluded.add(it)
return@onEnter false
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -335,13 +335,14 @@ class CodeWhispererCodeModernizerSessionTest : CodeWhispererCodeModernizerTestBa
}

@Test
fun `CodeModernizerSession can create zip and excludes idea folder`() {
fun `CodeModernizerSession can create zip and excludes idea folder and github folder`() {
addFilesToProjectModule(
"pom.xml",
"src/tmp.java",
".idea/smth.iml",
"someModule/pom.xml",
"someModule/.idea/smthelse.iml"
"someModule/.idea/smthelse.iml",
"someModule/.github/test.txt"
)
// get project.projectFile because project.projectFile can not be null
val rootManager = ModuleRootManager.getInstance(module)
Expand Down
Loading