Skip to content

fix(amazonq): Fix devfile detection on Feature Dev invocation. #5583

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 20, 2025
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" : "bugfix",
"description" : "/dev: Fix prompt to enable devfile build not triggering when devfile is present."
}
Original file line number Diff line number Diff line change
Expand Up @@ -479,7 +479,7 @@ class FeatureDevController(
),
)

if (!session.context.checkForDevFile()) {
if (!session.context.hasDevFile()) {
followUps.add(
FollowUp(
pillText = message("amazonqFeatureDev.follow_up.generate_dev_file"),
Expand Down Expand Up @@ -741,7 +741,7 @@ class FeatureDevController(
}

val codeWhispererSettings = CodeWhispererSettings.getInstance().getAutoBuildSetting()
val hasDevFile = session.context.checkForDevFile()
val hasDevFile = session.context.hasDevFile()
val isPromptedForAutoBuildFeature = codeWhispererSettings.containsKey(session.context.workspaceRoot.path)

if (hasDevFile && !isPromptedForAutoBuildFeature) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import org.apache.commons.codec.digest.DigestUtils
import org.apache.commons.io.FileUtils
import software.aws.toolkits.jetbrains.core.coroutines.getCoroutineBgContext
import software.aws.toolkits.jetbrains.services.amazonq.QConstants.MAX_FILE_SIZE_BYTES
import software.aws.toolkits.jetbrains.utils.getWorkspaceDevFile
import software.aws.toolkits.jetbrains.utils.isWorkspaceDevFile
import software.aws.toolkits.resources.AwsCoreBundle
import software.aws.toolkits.telemetry.AmazonqTelemetry
Expand Down Expand Up @@ -57,11 +58,8 @@ open class FeatureDevSessionContext(val project: Project, val maxProjectSizeByte

private var _selectionRoot = workspaceRoot

// This function checks for existence of `devfile.yaml` in customer's repository, currently only `devfile.yaml` is supported for this feature.
fun checkForDevFile(): Boolean {
val devFile = File(addressableRoot.toString(), "devfile.yaml")
return devFile.exists()
}
fun hasDevFile(): Boolean =
getWorkspaceDevFile(addressableRoot) != null

fun getProjectZip(isAutoBuildFeatureEnabled: Boolean?): ZipCreationResult {
val zippedProject = runBlocking {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@ package software.aws.toolkits.jetbrains.utils

import com.intellij.openapi.vfs.VirtualFile

fun isDevFile(file: VirtualFile): Boolean =
file.name.matches(Regex("devfile\\.ya?ml", RegexOption.IGNORE_CASE))

fun isWorkspaceDevFile(file: VirtualFile, addressableRoot: VirtualFile): Boolean =
file.name.matches(Regex("devfile\\.ya?ml", RegexOption.IGNORE_CASE)) &&
file.parent?.path == addressableRoot.path
isDevFile(file) && file.parent?.path == addressableRoot.path

fun getWorkspaceDevFile(addressableRoot: VirtualFile): VirtualFile? =
addressableRoot.children.find { isDevFile(it) }
Loading