Skip to content

Commit

Permalink
addressing minor comments and fixing chat messaging
Browse files Browse the repository at this point in the history
  • Loading branch information
ntarakad-aws committed Nov 17, 2024
1 parent e420a97 commit 4875b2b
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 22 deletions.
2 changes: 1 addition & 1 deletion packages/amazonq/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -1095,6 +1095,6 @@
},
"engines": {
"npm": "^10.1.0",
"vscode": "^1.68.0"
"vscode": "^1.83.0"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -224,11 +224,11 @@ export class Messenger {
options: [
{
value: JDKVersion.JDK8,
label: JDKVersion.JDK8.toString(),
label: JDKVersion.JDK8,
},
{
value: JDKVersion.JDK11,
label: JDKVersion.JDK11.toString(),
label: JDKVersion.JDK11,
},
{
value: JDKVersion.UNSUPPORTED,
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/codewhisperer/models/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -468,7 +468,7 @@ export const jobStartedChatMessage =
'I am starting to transform your code. It can take 10 to 30 minutes to upgrade your code, depending on the size of your project. To monitor progress, go to the Transformation Hub. If I run into any issues, I might pause the transformation to get input from you on how to proceed.'

export const userPatchDescriptionChatMessage = `
I can now divide the transformation results into diff patches if you would like to review and accept each diff with fewer changes:
I can now divide the transformation results into diff patches (if applicable to the app) if you would like to review and accept each diff with fewer changes:
• Minimal Compatible Library Upgrade to Java 17: Dependencies to the minimum compatible versions in Java 17, including Springboot, JUnit, and PowerMockito.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -169,42 +169,34 @@ export class DiffModel {
diffDescription: PatchInfo | undefined,
totalDiffPatches: number
): PatchFileNode {
console.log('parsing ', pathToDiff)
this.patchFileNodes = []
const diffContents = fs.readFileSync(pathToDiff, 'utf8')
console.log('diff contents: ', diffContents)
const changedFiles = parsePatch(diffContents)
console.log('changed files: ', changedFiles)
// path to the directory containing copy of the changed files in the transformed project
const pathToTmpSrcDir = this.copyProject(pathToWorkspace, changedFiles)
transformByQState.setProjectCopyFilePath(pathToTmpSrcDir)
console.log('path to tmp src dir: ', pathToTmpSrcDir)

applyPatches(changedFiles, {
loadFile: function (fileObj, callback) {
// load original contents of file
const filePath = path.join(pathToWorkspace, fileObj.oldFileName!.substring(2))
console.log(`loading filePath ${filePath}, exists = ${fs.existsSync(filePath)}`)
if (!fs.existsSync(filePath)) {
// must be a new file (ex. summary.md), so pass empty string as original contents and do not pass error
callback(undefined, '')
} else {
// must be a modified file (most common), so pass original contents
const fileContents = fs.readFileSync(filePath, 'utf-8')
console.log('original contents = ', fileContents)
callback(undefined, fileContents)
}
},
// by now, 'content' contains the changes from the patch
patched: function (fileObj, content, callback) {
const filePath = path.join(pathToTmpSrcDir, fileObj.newFileName!.substring(2))
console.log(`about to write ${content} to ${filePath}`)
// write changed contents to the copy of the original file (or create a new file)
fs.writeFileSync(filePath, content)
callback(undefined)
},
complete: function (err) {
console.log(`error = ${err}`)
if (err) {
getLogger().error(`CodeTransformation: ${err} when applying patch`)
} else {
Expand Down Expand Up @@ -438,17 +430,26 @@ export class ProposedTransformationExplorer {
pathContainingArchive = path.dirname(pathToArchive)
const zip = new AdmZip(pathToArchive)
zip.extractAllTo(pathContainingArchive)
console.log('pathContainingArchive = ', pathContainingArchive)
const files = fs.readdirSync(path.join(pathContainingArchive, ExportResultArchiveStructure.PathToPatch))
files.forEach((file) => {
const filePath = path.join(pathContainingArchive, ExportResultArchiveStructure.PathToPatch, file)
if (file === 'diff.patch') {
singlePatchFile = filePath
} else if (file.endsWith('.json')) {
const jsonData = fs.readFileSync(filePath, 'utf-8')
patchFilesDescriptions = JSON.parse(jsonData)
if (files.length === 1) {
singlePatchFile = path.join(
pathContainingArchive,
ExportResultArchiveStructure.PathToPatch,
files[0]
)
} else {
const jsonFile = files.find((file) => file.endsWith('.json'))
if (!jsonFile) {
throw new Error('Expected JSON file not found')
}
})
const filePath = path.join(
pathContainingArchive,
ExportResultArchiveStructure.PathToPatch,
jsonFile
)
const jsonData = fs.readFileSync(filePath, 'utf-8')
patchFilesDescriptions = JSON.parse(jsonData)
}
if (patchFilesDescriptions !== undefined) {
for (const patchInfo of patchFilesDescriptions.content) {
patchFiles.push(
Expand Down Expand Up @@ -488,7 +489,6 @@ export class ProposedTransformationExplorer {
await vscode.commands.executeCommand('aws.amazonq.transformationHub.summary.reveal')
} catch (e: any) {
deserializeErrorMessage = (e as Error).message
console.log('error parsing diff ', deserializeErrorMessage)
getLogger().error(`CodeTransformation: ParseDiff error = ${deserializeErrorMessage}`)
transformByQState.getChatControllers()?.transformationFinished.fire({
message: `${CodeWhispererConstants.errorDeserializingDiffChatMessage} ${deserializeErrorMessage}`,
Expand Down

0 comments on commit 4875b2b

Please sign in to comment.