@@ -2543,6 +2543,78 @@ export const makeGitVcsDriverCore = Effect.fn("makeGitVcsDriverCore")(function*
25432543 } ,
25442544 ) ;
25452545 } else {
2546+ // add -A marks unmerged paths resolved, so refuse while one still has conflict markers.
2547+ const unmergedPaths = ( yield * runGitStdoutWithOptions (
2548+ "GitVcsDriver.commit.unmergedPaths" ,
2549+ cwd ,
2550+ [ "-c" , "diff.relative=false" , "diff" , "--name-only" , "--diff-filter=U" , "-z" ] ,
2551+ env ? { env } : { } ,
2552+ ) )
2553+ . split ( "\0" )
2554+ . filter ( ( file ) => file . length > 0 ) ;
2555+ if ( unmergedPaths . length > 0 ) {
2556+ const check = yield * executeGit (
2557+ "GitVcsDriver.commit.conflictMarkers" ,
2558+ cwd ,
2559+ [
2560+ "-c" ,
2561+ "diff.relative=false" ,
2562+ "diff" ,
2563+ "--check" ,
2564+ "--no-color" ,
2565+ "--" ,
2566+ ...unmergedPaths . map ( ( file ) => `:(top,literal)${ file } ` ) ,
2567+ ] ,
2568+ {
2569+ ...( env ? { env } : { } ) ,
2570+ allowNonZeroExit : true ,
2571+ maxOutputBytes : REVIEW_METADATA_MAX_OUTPUT_BYTES ,
2572+ appendTruncationMarker : true ,
2573+ } ,
2574+ ) ;
2575+ const reports = check . stdout . split ( "\n" ) ;
2576+ const conflicted : string [ ] = [ ] ;
2577+ let topLevel : string | undefined ;
2578+ for ( const file of unmergedPaths ) {
2579+ const markerLines = new Set (
2580+ reports . flatMap ( ( line ) => {
2581+ const match = line . startsWith ( `${ file } :` )
2582+ ? / ^ ( \d + ) : l e f t o v e r c o n f l i c t m a r k e r $ / . exec ( line . slice ( file . length + 1 ) )
2583+ : null ;
2584+ return match ? [ Number ( match [ 1 ] ) - 1 ] : [ ] ;
2585+ } ) ,
2586+ ) ;
2587+ if ( markerLines . size === 0 ) continue ;
2588+ topLevel ??= ( yield * runGitStdout ( "GitVcsDriver.commit.topLevel" , cwd , [
2589+ "rev-parse" ,
2590+ "--show-toplevel" ,
2591+ ] ) ) . trim ( ) ;
2592+ const lines = ( yield * fileSystem . readFileString ( path . join ( topLevel , file ) ) . pipe (
2593+ Effect . mapError (
2594+ ( cause ) =>
2595+ new GitCommandError ( {
2596+ operation : "GitVcsDriver.commit.conflictMarkers" ,
2597+ command : "git commit" ,
2598+ cwd,
2599+ detail : `Could not check ${ file } for conflict markers.` ,
2600+ cause,
2601+ } ) ,
2602+ ) ,
2603+ ) ) . split ( "\n" ) ;
2604+ // Git also reports a lone "=======", which is valid content such as a heading underline.
2605+ const reported = ( marker : string ) =>
2606+ lines . some ( ( line , index ) => markerLines . has ( index ) && line . startsWith ( marker ) ) ;
2607+ if ( reported ( "<" ) && reported ( ">" ) ) conflicted . push ( file ) ;
2608+ }
2609+ if ( conflicted . length > 0 ) {
2610+ return yield * new GitCommandError ( {
2611+ operation : "GitVcsDriver.commit" ,
2612+ command : "git commit" ,
2613+ cwd,
2614+ detail : `Cannot commit with unresolved merge conflicts in ${ conflicted . join ( ", " ) } . Resolve them, then commit.` ,
2615+ } ) ;
2616+ }
2617+ }
25462618 yield * runGit (
25472619 "GitVcsDriver.commit.addAll" ,
25482620 cwd ,
0 commit comments