Skip to content

Commit 0ed2a3a

Browse files
authored
fix(amazonq): incorrect zip entry path for file scans #6741
## Problem Reproduce steps: 1. Open a window with multiple workspace folders, for example `workspaceFolders: [folder1, folder2]` 2. Open any file and run a code review on the active file, for example `folder1/sample.py` 3. The zip entry will be created with the workspaceFolder duplicated, for example `folder1/folder1/sample.py` ## Solution Explicitly set `includeWorkspaceFolder` to false when getting the relative path of the file.
1 parent 600ee8f commit 0ed2a3a

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"type": "Bug Fix",
3+
"description": "/review: Zip files are created with the wrong file path for file scans in multifolder workspaces."
4+
}

packages/core/src/codewhisperer/util/zipUtil.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,8 @@ export class ZipUtil {
117117
// Note: workspaceFolder.name is not the same as the file system folder name,
118118
// use the fsPath value instead
119119
const projectName = path.basename(workspaceFolder.uri.fsPath)
120-
const relativePath = vscode.workspace.asRelativePath(uri)
120+
// Set includeWorkspaceFolder to false because we are already manually prepending the projectName
121+
const relativePath = vscode.workspace.asRelativePath(uri, false)
121122
const zipEntryPath = this.getZipEntryPath(projectName, relativePath)
122123
zip.addFile(zipEntryPath, Buffer.from(content, 'utf-8'))
123124

0 commit comments

Comments
 (0)