Skip to content

Commit

Permalink
Merge main into feature/q-mega
Browse files Browse the repository at this point in the history
  • Loading branch information
aws-toolkit-automation authored Nov 26, 2024
2 parents 703514a + dcaceb2 commit 3e30e52
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"type" : "feature",
"description" : "Amazon Q /dev: support `Dockerfile` files"
}
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,12 @@ class FeatureDevSessionContext(val project: Project, val maxProjectSizeBytes: Lo
"dist/?"
).map { Regex(it) }

// well known source files that do not have extensions
private val wellKnownSourceFiles = setOf(
"Dockerfile",
"Dockerfile.build"
)

// projectRoot: is the directory where the project is located when selected to open a project.
val projectRoot = project.guessProjectDir() ?: error("Cannot guess base directory for project ${project.name}")

Expand Down Expand Up @@ -117,6 +123,8 @@ class FeatureDevSessionContext(val project: Project, val maxProjectSizeBytes: Lo
return deferredResults.any { it.await() }
}

private fun wellKnown(file: VirtualFile): Boolean = wellKnownSourceFiles.contains(file.name)

suspend fun zipFiles(projectRoot: VirtualFile): File = withContext(getCoroutineBgContext()) {
val files = mutableListOf<VirtualFile>()
val ignoredExtensionMap = mutableMapOf<String, Long>().withDefault { 0L }
Expand All @@ -126,8 +134,9 @@ class FeatureDevSessionContext(val project: Project, val maxProjectSizeBytes: Lo
projectRoot,
object : VirtualFileVisitor<Unit>() {
override fun visitFile(file: VirtualFile): Boolean {
val isWellKnown = runBlocking { wellKnown(file) }
val isFileIgnoredByExtension = runBlocking { ignoreFileByExtension(file) }
if (isFileIgnoredByExtension) {
if (!isWellKnown && isFileIgnoredByExtension) {
val extension = file.extension.orEmpty()
ignoredExtensionMap[extension] = (ignoredExtensionMap[extension] ?: 0) + 1
return false
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ val ALLOWED_CODE_EXTENSIONS = setOf(
"d",
"dart",
"dfm",
"dockerfile",
"dpr",
"e",
"el",
Expand Down

0 comments on commit 3e30e52

Please sign in to comment.