Skip to content

Commit 24a6f5f

Browse files
dhasani23David Hasani
andauthored
fix(amazonq): show diff.patch first, then parse it (aws#8008)
## Problem Better to first open the diff.patch for user to see, then parse it and apply it, so that if it is malformed, it is first visible to user. ## Solution Open diff.patch first. --- - Treat all work as PUBLIC. Private `feature/x` branches will not be squash-merged at release time. - Your code changes must meet the guidelines in [CONTRIBUTING.md](https://github.com/aws/aws-toolkit-vscode/blob/master/CONTRIBUTING.md#guidelines). - License: I confirm that my contribution is made under the terms of the Apache 2.0 license. --------- Co-authored-by: David Hasani <[email protected]>
1 parent 0401a71 commit 24a6f5f

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

packages/core/src/codewhisperer/service/transformByQ/transformApiHandler.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -743,7 +743,7 @@ export async function pollTransformationJob(jobId: string, validStates: string[]
743743
}
744744
await sleep(CodeWhispererConstants.transformationJobPollingIntervalSeconds * 1000)
745745
} catch (e: any) {
746-
getLogger().error(`CodeTransformation: GetTransformation error = %O`, e)
746+
getLogger().error(`CodeTransformation: error = %O`, e)
747747
throw e
748748
}
749749
}
@@ -827,11 +827,11 @@ async function processClientInstructions(jobId: string, clientInstructionsPath:
827827
getLogger().info(`CodeTransformation: copied project to ${destinationPath}`)
828828
const diffContents = await fs.readFileText(clientInstructionsPath)
829829
if (diffContents.trim()) {
830-
const diffModel = new DiffModel()
831-
diffModel.parseDiff(clientInstructionsPath, path.join(destinationPath, 'sources'), true)
832830
// show user the diff.patch
833831
const doc = await vscode.workspace.openTextDocument(clientInstructionsPath)
834832
await vscode.window.showTextDocument(doc, { viewColumn: vscode.ViewColumn.One })
833+
const diffModel = new DiffModel()
834+
diffModel.parseDiff(clientInstructionsPath, path.join(destinationPath, 'sources'), true)
835835
} else {
836836
// still need to set the project copy so that we can use it below
837837
transformByQState.setProjectCopyFilePath(path.join(destinationPath, 'sources'))

packages/core/src/codewhisperer/service/transformByQ/transformationResultsViewProvider.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,8 @@ export class DiffModel {
166166
throw new Error(CodeWhispererConstants.noChangesMadeMessage)
167167
}
168168

169+
getLogger().info(`CodeTransformation: parsing patch file at ${pathToDiff}`)
170+
169171
let changedFiles = parsePatch(diffContents)
170172
// exclude dependency_upgrade.yml from patch application
171173
changedFiles = changedFiles.filter((file) => !file.oldFileName?.includes('dependency_upgrade'))

0 commit comments

Comments
 (0)