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
@@ -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
Loading