@@ -218,7 +218,7 @@ export class CheckpointService {
218218 this . log (
219219 `[saveCheckpoint] failed in stage stash phase: ${ err instanceof Error ? err . message : String ( err ) } ` ,
220220 )
221- await this . git . checkout ( [ "-f" , this . mainBranch ] )
221+ await this . restoreMain ( { branch : stashBranch , stashSha , force : true } )
222222 await this . git . branch ( [ "-D" , stashBranch ] ) . catch ( ( ) => { } )
223223 throw err
224224 }
@@ -232,19 +232,27 @@ export class CheckpointService {
232232 * - UNDO: Create branch
233233 * - UNDO: Change branch
234234 */
235+ let stashCommit
236+
235237 try {
236- // TODO: Add a test to see if empty commits break this.
237- const stashCommit = await this . git . commit ( message , undefined , { "--no-verify" : null } )
238+ stashCommit = await this . git . commit ( message , undefined , { "--no-verify" : null } )
238239 this . log ( `[saveCheckpoint] stashCommit: ${ message } -> ${ JSON . stringify ( stashCommit ) } ` )
239240 } catch ( err ) {
240241 this . log (
241242 `[saveCheckpoint] failed in stash commit phase: ${ err instanceof Error ? err . message : String ( err ) } ` ,
242243 )
243- await this . git . checkout ( [ "-f" , this . mainBranch ] )
244+ await this . restoreMain ( { branch : stashBranch , stashSha , force : true } )
244245 await this . git . branch ( [ "-D" , stashBranch ] ) . catch ( ( ) => { } )
245246 throw err
246247 }
247248
249+ if ( ! stashCommit ) {
250+ this . log ( "[saveCheckpoint] no stash commit" )
251+ await this . restoreMain ( { branch : stashBranch , stashSha } )
252+ await this . git . branch ( [ "-D" , stashBranch ] )
253+ return undefined
254+ }
255+
248256 /**
249257 * PHASE: Diff
250258 * Mutations:
0 commit comments