-
Notifications
You must be signed in to change notification settings - Fork 749
fix(amazonq): Updating logic for getWorkspaceRelativePath in shared src for /test #6628
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
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
4 changes: 4 additions & 0 deletions
4
packages/amazonq/.changes/next-release/Bug Fix-ee447a9f-6a92-47c5-8e94-069c1aee46ab.json
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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." | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -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 | ||||||
|
|
@@ -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) { | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can just do
Suggested change
|
||||||
| // 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 } | ||||||
| } | ||||||
|
|
@@ -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[]> = [] | ||||||
|
|
||||||
|
|
@@ -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) | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is already |
||||||
| if (!relativePath) { | ||||||
| continue | ||||||
| } | ||||||
|
|
||||||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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 😞