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": "Bug Fix",
"description": "Amazon Q /test: Fixing the issue of target file does not exist."
}
11 changes: 8 additions & 3 deletions packages/core/src/codewhisperer/util/zipUtil.ts
Original file line number Diff line number Diff line change
Expand Up @@ -410,9 +410,14 @@ export class ZipUtil {
return
}

const sourceFiles = await collectFiles(projectPaths, vscode.workspace.workspaceFolders as CurrentWsFolders, {
maxSizeBytes: this.getProjectScanPayloadSizeLimitInBytes(),
})
const sourceFiles = await collectFiles(
projectPaths,
vscode.workspace.workspaceFolders as CurrentWsFolders,
{
maxSizeBytes: this.getProjectScanPayloadSizeLimitInBytes(),
},
useCase
)
for (const file of sourceFiles) {
const projectName = path.basename(file.workspaceFolder.uri.fsPath)
const zipEntryPath = this.getZipEntryPath(projectName, file.relativeFilePath)
Expand Down
18 changes: 14 additions & 4 deletions packages/core/src/shared/utilities/workspaceUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import fs from '../fs/fs'
import { ChildProcess } from './processUtils'
import { isWin } from '../vscode/env'
import { maxRepoSizeBytes } from '../../amazonqFeatureDev/constants'
import { FeatureUseCase } from '../../codewhisperer/models/constants'

type GitIgnoreRelativeAcceptor = {
folderPath: string
Expand Down Expand Up @@ -223,12 +224,20 @@ export function getWorkspaceRelativePath(
workspaceFolders?: readonly vscode.WorkspaceFolder[]
} = {
workspaceFolders: vscode.workspace.workspaceFolders,
}
},
useCase?: FeatureUseCase
): { relativePath: string; workspaceFolder: vscode.WorkspaceFolder } | undefined {
if (!override.workspaceFolders) {
return
}
for (const folder of override.workspaceFolders) {
let folders = override.workspaceFolders
if (useCase && useCase === FeatureUseCase.TEST_GENERATION) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This feels too specific to be put in this shared utility method. Are you planning to update this later?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes Will remove this once I get confirmation from Q teams
For now this is required for UTG. I think this is the same case for other features too

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you track this in an issue somewhere so that someone comes back to it. This workspace util is become a monster 😞

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can just do

Suggested change
if (useCase && useCase === FeatureUseCase.TEST_GENERATION) {
if (useCase === FeatureUseCase.TEST_GENERATION) {

// Sort workspace folders by path length (descending) to prioritize deeper paths
// TODO: Need to enable this for entire Q
folders = [...override.workspaceFolders].sort((a, b) => b.uri.fsPath.length - a.uri.fsPath.length)
}

for (const folder of folders) {
if (isInDirectory(folder.uri.fsPath, childPath)) {
return { relativePath: path.relative(folder.uri.fsPath, childPath), workspaceFolder: folder }
}
Expand Down Expand Up @@ -352,7 +361,8 @@ export async function collectFiles(
excludeByGitIgnore?: boolean // default true
excludePatterns?: string[] // default defaultExcludePatterns
filterFn?: CollectFilesFilter
}
},
useCase?: FeatureUseCase
): Promise<CollectFilesResultItem[]> {
const storage: Awaited<CollectFilesResultItem[]> = []

Expand Down Expand Up @@ -398,7 +408,7 @@ export async function collectFiles(
const files = excludeByGitIgnore ? await filterOutGitignoredFiles(rootPath, allFiles, false) : allFiles

for (const file of files) {
const relativePath = getWorkspaceRelativePath(file.fsPath, { workspaceFolders })
const relativePath = getWorkspaceRelativePath(file.fsPath, { workspaceFolders }, useCase)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is already filterFn, why was this special parameter needed?

if (!relativePath) {
continue
}
Expand Down
Loading