@@ -140,19 +140,20 @@ const prepareRepoForImport = (
140140 ctx : SessionImportContext ,
141141 wipe : boolean
142142) : Effect . Effect < void , ScrapError , ScrapRequirements > => {
143- const wipeLine = wipe ? `rm -rf ${ shellEscape ( ctx . template . targetDir ) } ` : ":"
143+ const targetDir = shellEscape ( ctx . template . targetDir )
144+ const wipeLine = wipe ? `rm -rf ${ targetDir } ` : ":"
144145 const gitDir = `${ ctx . template . targetDir } /.git`
145146 const prepScript = [
146147 "set -e" ,
147148 wipeLine ,
148- `mkdir -p ${ shellEscape ( ctx . template . targetDir ) } ` ,
149+ `mkdir -p ${ targetDir } ` ,
149150 `if [ ! -d ${ shellEscape ( gitDir ) } ]; then` ,
150- ` PARENT=$(dirname ${ shellEscape ( ctx . template . targetDir ) } )` ,
151+ ` PARENT=$(dirname ${ targetDir } )` ,
151152 " mkdir -p \"$PARENT\"" ,
152- ` git clone ${ shellEscape ( ctx . manifest . repo . originUrl ) } ${ shellEscape ( ctx . template . targetDir ) } ` ,
153+ ` git clone ${ shellEscape ( ctx . manifest . repo . originUrl ) } ${ targetDir } ` ,
153154 "fi" ,
154- `cd ${ shellEscape ( ctx . template . targetDir ) } ` ,
155- `SAFE=${ shellEscape ( ctx . template . targetDir ) } ` ,
155+ `cd ${ targetDir } ` ,
156+ `SAFE=${ targetDir } ` ,
156157 "git -c safe.directory=\"$SAFE\" fetch --all --prune" ,
157158 `git -c safe.directory="$SAFE" checkout --detach ${ shellEscape ( ctx . manifest . repo . head ) } ` ,
158159 `git -c safe.directory="$SAFE" reset --hard ${ shellEscape ( ctx . manifest . repo . head ) } ` ,
@@ -174,10 +175,11 @@ const applyWorktreePatch = (ctx: SessionImportContext): Effect.Effect<void, Scra
174175 Effect . gen ( function * ( _ ) {
175176 const patchPartsAbs = yield * _ ( resolveSnapshotPartsAbs ( ctx , ctx . manifest . artifacts . worktreePatchChunks ) )
176177 const patchCatArgs = patchPartsAbs . map ( ( p ) => shellEscape ( p ) ) . join ( " " )
178+ const targetDir = shellEscape ( ctx . template . targetDir )
177179 const applyInner = [
178180 "set -e" ,
179- `cd ${ shellEscape ( ctx . template . targetDir ) } ` ,
180- `SAFE=${ shellEscape ( ctx . template . targetDir ) } ` ,
181+ `cd ${ targetDir } ` ,
182+ `SAFE=${ targetDir } ` ,
181183 "git -c safe.directory=\"$SAFE\" apply --allow-empty --binary --whitespace=nowarn -"
182184 ] . join ( "; " )
183185 const applyScript = [
@@ -225,6 +227,7 @@ const restoreTarChunksIntoContainerDir = (
225227
226228const runRebuildCommands = ( ctx : SessionImportContext ) : Effect . Effect < void , ScrapError , ScrapRequirements > =>
227229 Effect . gen ( function * ( _ ) {
230+ const targetDir = shellEscape ( ctx . template . targetDir )
228231 const commands = ctx . manifest . rebuild . commands
229232 if ( commands . length === 0 ) {
230233 return
@@ -236,7 +239,7 @@ const runRebuildCommands = (ctx: SessionImportContext): Effect.Effect<void, Scra
236239 continue
237240 }
238241 yield * _ ( Effect . log ( `Rebuilding: ${ trimmed } ` ) )
239- const script = `set -e; cd ${ shellEscape ( ctx . template . targetDir ) } ; ${ trimmed } `
242+ const script = `set -e; cd ${ targetDir } ; ${ trimmed } `
240243 yield * _ (
241244 runDockerExec ( ctx . resolved , "scrap session rebuild" , ctx . template . containerName , script , ctx . template . sshUser )
242245 )
0 commit comments