Skip to content
25 changes: 25 additions & 0 deletions packages/core/src/codewhisperer/models/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -896,3 +896,28 @@ export enum SecurityScanStep {
}

export const amazonqCodeIssueDetailsTabTitle = 'Code Issue Details'

export const testGenExcludePatterns = [
'**/annotation-generated-src/*',
'**/annotation-generated-tst/*',
'**/build/*',
'**/env/*',
'**/release-info/*',
'**/*.jar',
'**/*.exe',
'**/*.a',
'**/*.map',
'**/*.graph',
'**/*.so',
'**/*.csv',
'**/*.dylib',
'**/*.parquet',
'**/*.xlsx',
'**/*.tar.gz',
'**/*.tar',
'**/*.pack',
'**/*.pkg',
'**/*.pkl',
'**/*.deb',
'**/*.model',
]
6 changes: 5 additions & 1 deletion packages/core/src/codewhisperer/util/zipUtil.ts
Original file line number Diff line number Diff line change
Expand Up @@ -412,7 +412,11 @@ export class ZipUtil {

const sourceFiles = await collectFiles(
projectPaths,
vscode.workspace.workspaceFolders as CurrentWsFolders,
(useCase === FeatureUseCase.TEST_GENERATION
? [...(vscode.workspace.workspaceFolders ?? [])].sort(
(a, b) => b.uri.fsPath.length - a.uri.fsPath.length
)
: vscode.workspace.workspaceFolders) as CurrentWsFolders,
{
maxSizeBytes: this.getProjectScanPayloadSizeLimitInBytes(),
},
Expand Down
19 changes: 8 additions & 11 deletions packages/core/src/shared/utilities/workspaceUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +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'
import { FeatureUseCase, testGenExcludePatterns } from '../../codewhisperer/models/constants'

type GitIgnoreRelativeAcceptor = {
folderPath: string
Expand Down Expand Up @@ -224,18 +224,12 @@ export function getWorkspaceRelativePath(
workspaceFolders?: readonly vscode.WorkspaceFolder[]
} = {
workspaceFolders: vscode.workspace.workspaceFolders,
},
useCase?: FeatureUseCase
}
): { relativePath: string; workspaceFolder: vscode.WorkspaceFolder } | undefined {
if (!override.workspaceFolders) {
return
}
let folders = override.workspaceFolders
if (useCase && 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)
}
const folders = override.workspaceFolders

for (const folder of folders) {
if (isInDirectory(folder.uri.fsPath, childPath)) {
Expand Down Expand Up @@ -393,7 +387,10 @@ export async function collectFiles(
const inputExcludePatterns = options?.excludePatterns ?? defaultExcludePatterns
const maxSizeBytes = options?.maxSizeBytes ?? maxRepoSizeBytes

const excludePatterns = [...getGlobalExcludePatterns()]
const excludePatterns = [
...getGlobalExcludePatterns(),
...(useCase === FeatureUseCase.TEST_GENERATION ? [...testGenExcludePatterns, ...defaultExcludePatterns] : []),
]
if (inputExcludePatterns.length) {
excludePatterns.push(...inputExcludePatterns)
}
Expand All @@ -408,7 +405,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 }, useCase)
const relativePath = getWorkspaceRelativePath(file.fsPath, { workspaceFolders })
if (!relativePath) {
continue
}
Expand Down
Loading