Skip to content

Commit 0faca04

Browse files
author
David Hasani
committed
handle empty diff
1 parent 7a5ad3b commit 0faca04

File tree

2 files changed

+3
-20
lines changed

2 files changed

+3
-20
lines changed

packages/core/src/codewhisperer/models/constants.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -481,6 +481,8 @@ export const failedStepMessage = 'The step failed, fetching additional details..
481481

482482
export const jobCompletedMessage = 'The transformation completed.'
483483

484+
export const noChangesMadeMessage = "I didn't make any changes for this transformation."
485+
484486
export const noOngoingJobMessage = 'No ongoing job.'
485487

486488
export const nothingToShowMessage = 'Nothing to show'

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

Lines changed: 1 addition & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ export class DiffModel {
148148

149149
if (!diffContents.trim()) {
150150
getLogger().error(`CodeTransformation: diff.patch file is empty`)
151-
throw new Error('No changes were made as a part of this transformation.')
151+
throw new Error(CodeWhispererConstants.noChangesMadeMessage)
152152
}
153153

154154
const changedFiles = parsePatch(diffContents)
@@ -379,25 +379,6 @@ export class ProposedTransformationExplorer {
379379
pathContainingArchive = path.dirname(pathToArchive)
380380
const zip = new AdmZip(pathToArchive)
381381
zip.extractAllTo(pathContainingArchive)
382-
383-
// TODO: below only needed if the backend cannot fix the "b/" diff.patch issue
384-
const diffPatch = fs.readFileSync(
385-
path.join(pathContainingArchive, ExportResultArchiveStructure.PathToDiffPatch),
386-
'utf-8'
387-
)
388-
const lines = diffPatch.split('\n')
389-
const newLines = lines.map((line) => {
390-
if (line.trim().startsWith('diff') || line.trim().startsWith('+++')) {
391-
return line.replace('b', 'b/')
392-
}
393-
return line
394-
})
395-
const newDiffPatch = newLines.join('\n')
396-
fs.writeFileSync(
397-
path.join(pathContainingArchive, ExportResultArchiveStructure.PathToDiffPatch),
398-
newDiffPatch
399-
)
400-
401382
diffModel.parseDiff(
402383
path.join(pathContainingArchive, ExportResultArchiveStructure.PathToDiffPatch),
403384
transformByQState.getProjectPath()

0 commit comments

Comments
 (0)