33 * SPDX-License-Identifier: Apache-2.0
44 */
55
6- // import AdmZip from 'adm-zip'
6+ import AdmZip from 'adm-zip'
77import os from 'os'
88import fs from 'fs' // eslint-disable-line no-restricted-imports
99import { parsePatch , applyPatches , ParsedDiff } from 'diff'
1010import path from 'path'
1111import vscode from 'vscode'
12- // import { ExportIntent } from '@amzn/codewhisperer-streaming'
12+ import { ExportIntent } from '@amzn/codewhisperer-streaming'
1313import {
1414 TransformByQReviewStatus ,
1515 transformByQState ,
1616 PatchInfo ,
1717 DescriptionContent ,
1818 TransformationType ,
1919} from '../../models/model'
20- import { ExportResultArchiveStructure } from '../../../shared/utilities/download'
20+ import { ExportResultArchiveStructure , downloadExportResultArchive } from '../../../shared/utilities/download'
2121import { getLogger } from '../../../shared/logger'
2222import { telemetry } from '../../../shared/telemetry/telemetry'
2323import { CodeTransformTelemetryState } from '../../../amazonqGumby/telemetry/codeTransformTelemetryState'
2424import { MetadataResult } from '../../../shared/telemetry/telemetryClient'
2525import * as CodeWhispererConstants from '../../models/constants'
26- // import { createCodeWhispererChatStreamingClient } from '../../../shared/clients/codewhispererChatClient'
26+ import { createCodeWhispererChatStreamingClient } from '../../../shared/clients/codewhispererChatClient'
2727import { ChatSessionManager } from '../../../amazonqGumby/chat/storages/chatSession'
2828import { setContext } from '../../../shared/vscode/setContext'
2929import * as codeWhisperer from '../../client/codewhisperer'
@@ -325,7 +325,11 @@ export class ProposedTransformationExplorer {
325325 treeDataProvider : transformDataProvider ,
326326 } )
327327
328+ << < < < << HEAD
328329 let patchFiles : string [ ] = [ ]
330+ === = ===
331+ const patchFiles : string [ ] = [ ]
332+ >>> > >>> d92cadc19 ( remove short circuiting steps )
329333 let singlePatchFile : string = ''
330334 let patchFilesDescriptions : DescriptionContent | undefined = undefined
331335
@@ -377,15 +381,15 @@ export class ProposedTransformationExplorer {
377381 vscode . commands . registerCommand ( 'aws.amazonq.transformationHub.reviewChanges.startReview' , async ( ) => {
378382 await setContext ( 'gumby.reviewState' , TransformByQReviewStatus . PreparingReview )
379383
380- // const pathToArchive = path.join(
381- // ProposedTransformationExplorer.TmpDir,
382- // transformByQState.getJobId(),
383- // 'ExportResultsArchive.zip'
384- // )
385- const exportResultsArchiveSize = 0
384+ const pathToArchive = path . join (
385+ ProposedTransformationExplorer . TmpDir ,
386+ transformByQState . getJobId ( ) ,
387+ 'ExportResultsArchive.zip'
388+ )
389+ let exportResultsArchiveSize = 0
386390 let downloadErrorMessage = undefined
387391
388- // const cwStreamingClient = await createCodeWhispererChatStreamingClient()
392+ const cwStreamingClient = await createCodeWhispererChatStreamingClient ( )
389393 try {
390394 await telemetry . codeTransform_downloadArtifact . run ( async ( ) => {
391395 telemetry . record ( {
@@ -394,17 +398,17 @@ export class ProposedTransformationExplorer {
394398 codeTransformJobId : transformByQState . getJobId ( ) ,
395399 } )
396400
397- // await downloadExportResultArchive(
398- // cwStreamingClient,
399- // {
400- // exportId: transformByQState.getJobId(),
401- // exportIntent: ExportIntent.TRANSFORMATION,
402- // },
403- // pathToArchive
404- // )
401+ await downloadExportResultArchive (
402+ cwStreamingClient ,
403+ {
404+ exportId : transformByQState . getJobId ( ) ,
405+ exportIntent : ExportIntent . TRANSFORMATION ,
406+ } ,
407+ pathToArchive
408+ )
405409
406410 // Update downloaded artifact size
407- // exportResultsArchiveSize = (await fs.promises.stat(pathToArchive)).size
411+ exportResultsArchiveSize = ( await fs . promises . stat ( pathToArchive ) ) . size
408412
409413 telemetry . record ( { codeTransformTotalByteSize : exportResultsArchiveSize } )
410414 } )
@@ -425,17 +429,20 @@ export class ProposedTransformationExplorer {
425429 getLogger ( ) . error ( `CodeTransformation: ExportResultArchive error = ${ downloadErrorMessage } ` )
426430 throw new Error ( 'Error downloading diff' )
427431 } finally {
428- // cwStreamingClient.destroy()
432+ cwStreamingClient . destroy ( )
429433 }
430434
431435 let deserializeErrorMessage = undefined
432436 let pathContainingArchive = ''
437+ << < < < << HEAD
433438 patchFiles = [ ] // reset patchFiles if there was a previous transformation
439+ === = ===
440+ >>> > >>> d92cadc19 ( remove short circuiting steps )
434441 try {
435442 // Download and deserialize the zip
436- // pathContainingArchive = path.dirname(pathToArchive)
437- // const zip = new AdmZip(pathToArchive)
438- // zip.extractAllTo(pathContainingArchive)
443+ pathContainingArchive = path . dirname ( pathToArchive )
444+ const zip = new AdmZip ( pathToArchive )
445+ zip . extractAllTo ( pathContainingArchive )
439446 const files = fs . readdirSync ( path . join ( pathContainingArchive , ExportResultArchiveStructure . PathToPatch ) )
440447 if ( files . length === 1 ) {
441448 singlePatchFile = path . join (
0 commit comments