Skip to content

Commit 2606357

Browse files
author
David Hasani
committed
handle empty diff
1 parent 554cee1 commit 2606357

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
@@ -474,6 +474,8 @@ export const failedStepMessage = 'The step failed, fetching additional details..
474474

475475
export const jobCompletedMessage = 'The transformation completed.'
476476

477+
export const noChangesMadeMessage = "I didn't make any changes for this transformation."
478+
477479
export const noOngoingJobMessage = 'No ongoing job.'
478480

479481
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
@@ -147,7 +147,7 @@ export class DiffModel {
147147

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

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

0 commit comments

Comments
 (0)