@@ -1382,9 +1382,10 @@ export const make = Effect.gen(function* () {
13821382 } ) ;
13831383
13841384 let currentHookName : string | null = null ;
1385- let pendingHookOutput : Array < { stream : "stdout" | "stderr" ; text : string } > = [ ] ;
1385+ let sawCommitHook = false ;
1386+ let pendingUnattributedOutput : Array < { stream : "stdout" | "stderr" ; text : string } > = [ ] ;
13861387 const emitHookOutput = (
1387- hookName : string ,
1388+ hookName : string | null ,
13881389 { stream, text } : { stream : "stdout" | "stderr" ; text : string } ,
13891390 ) => {
13901391 const sanitized = sanitizeProgressText ( text ) ;
@@ -1398,32 +1399,33 @@ export const make = Effect.gen(function* () {
13981399 text : sanitized ,
13991400 } ) ;
14001401 } ;
1402+ const finalizeUnattributedOutput = ( shouldEmit : boolean ) =>
1403+ Effect . suspend ( ( ) => {
1404+ const pending = pendingUnattributedOutput ;
1405+ pendingUnattributedOutput = [ ] ;
1406+ return shouldEmit
1407+ ? Effect . forEach ( pending , ( output ) => emitHookOutput ( null , output ) , { discard : true } )
1408+ : Effect . void ;
1409+ } ) ;
14011410 const commitProgress =
14021411 progressReporter && actionId
14031412 ? {
14041413 onOutputLine : ( output : { stream : "stdout" | "stderr" ; text : string } ) =>
14051414 Effect . suspend ( ( ) => {
14061415 if ( currentHookName === null ) {
1407- pendingHookOutput . push ( output ) ;
1416+ pendingUnattributedOutput . push ( output ) ;
14081417 return Effect . void ;
14091418 }
14101419 return emitHookOutput ( currentHookName , output ) ;
14111420 } ) ,
14121421 onHookStarted : ( hookName : string ) =>
14131422 Effect . suspend ( ( ) => {
1423+ sawCommitHook = true ;
14141424 currentHookName = hookName ;
1415- const bufferedOutput = pendingHookOutput ;
1416- pendingHookOutput = [ ] ;
14171425 return emit ( {
14181426 kind : "hook_started" ,
14191427 hookName,
1420- } ) . pipe (
1421- Effect . flatMap ( ( ) =>
1422- Effect . forEach ( bufferedOutput , ( output ) => emitHookOutput ( hookName , output ) , {
1423- discard : true ,
1424- } ) ,
1425- ) ,
1426- ) ;
1428+ } ) ;
14271429 } ) ,
14281430 onHookFinished : ( {
14291431 hookName,
@@ -1446,11 +1448,19 @@ export const make = Effect.gen(function* () {
14461448 } ,
14471449 }
14481450 : null ;
1449- const { commitSha } = yield * gitCore . commit ( cwd , suggestion . subject , suggestion . body , {
1450- timeoutMs : COMMIT_TIMEOUT_MS ,
1451- ...( disableSigning ? { disableSigning : true } : { } ) ,
1452- ...( commitProgress ? { progress : commitProgress } : { } ) ,
1453- } ) ;
1451+ const { commitSha } = yield * gitCore
1452+ . commit ( cwd , suggestion . subject , suggestion . body , {
1453+ timeoutMs : COMMIT_TIMEOUT_MS ,
1454+ ...( disableSigning ? { disableSigning : true } : { } ) ,
1455+ ...( commitProgress ? { progress : commitProgress } : { } ) ,
1456+ } )
1457+ . pipe (
1458+ Effect . tapError ( ( error ) =>
1459+ finalizeUnattributedOutput (
1460+ sawCommitHook && error . failureKind !== "commit_signing_failed" ,
1461+ ) ,
1462+ ) ,
1463+ ) ;
14541464 if ( currentHookName !== null ) {
14551465 yield * emit ( {
14561466 kind : "hook_finished" ,
@@ -1460,7 +1470,7 @@ export const make = Effect.gen(function* () {
14601470 } ) ;
14611471 currentHookName = null ;
14621472 }
1463- pendingHookOutput = [ ] ;
1473+ yield * finalizeUnattributedOutput ( sawCommitHook ) ;
14641474 return {
14651475 status : "created" as const ,
14661476 commitSha,
0 commit comments