@@ -1295,34 +1295,53 @@ export const makeVcsDriverShape = Effect.fn("makeGitVcsDriverShape")(function* (
12951295 } ) ,
12961296 ) ,
12971297 ) ;
1298+ const resetIndex = Effect . gen ( function * ( ) {
1299+ // On Windows clean can remove './' and exit 0.
1300+ yield * recreateWorkspace ;
1301+ if ( yield * hasHeadCommit ( input . cwd ) ) {
1302+ yield * execute ( {
1303+ operation,
1304+ cwd : input . cwd ,
1305+ args : [ ...longPaths , "reset" , "--quiet" , "--" , "." ] ,
1306+ } ) ;
1307+ }
1308+ } ) ;
12981309 yield * recreateWorkspace ;
12991310 const clean = execute ( {
13001311 operation,
13011312 cwd : input . cwd ,
13021313 args : [ ...longPaths , "clean" , "-fd" , "--" , "." ] ,
1314+ env : { LC_ALL : "C" } ,
13031315 allowNonZeroExit : true ,
13041316 } ) ;
13051317 let cleaned = yield * clean ;
13061318 // Removing a new .gitignore exposes the files it hid; clean again until nothing is left.
1307- for ( let pass = 1 ; pass < 4 && cleaned . exitCode === 0 && cleaned . stdout . length > 0 ; pass ++ ) {
1319+ for (
1320+ let pass = 1 ;
1321+ pass < 4 && cleaned . exitCode === 0 && / ^ R e m o v i n g / m. test ( cleaned . stdout ) ;
1322+ pass ++
1323+ ) {
13081324 yield * recreateWorkspace ;
13091325 cleaned = yield * clean ;
13101326 }
1311- if ( cleaned . exitCode === 0 && cleaned . stdout . length > 0 ) {
1327+ if ( cleaned . exitCode === 0 && / ^ R e m o v i n g / m . test ( cleaned . stdout ) ) {
13121328 yield * recreateWorkspace ;
13131329 const remaining = yield * execute ( {
13141330 operation,
13151331 cwd : input . cwd ,
13161332 args : [ ...longPaths , "clean" , "-dn" , "--" , "." ] ,
1333+ env : { LC_ALL : "C" } ,
13171334 } ) ;
1318- if ( remaining . stdout . length > 0 )
1335+ if ( / ^ W o u l d r e m o v e / m. test ( remaining . stdout ) ) {
1336+ yield * resetIndex ;
13191337 return yield * new VcsProcessExitError ( {
13201338 operation,
13211339 command : "git clean" ,
13221340 cwd : input . cwd ,
13231341 exitCode : 0 ,
13241342 detail : "Could not clean the checkpoint workspace: untracked files remain." ,
13251343 } ) ;
1344+ }
13261345 }
13271346 if ( cleaned . exitCode !== 0 ) {
13281347 // Git can remove every child, then fail trying to remove './' itself.
@@ -1333,26 +1352,18 @@ export const makeVcsDriverShape = Effect.fn("makeGitVcsDriverShape")(function* (
13331352 Effect . map ( ( entries ) => entries . length === 0 ) ,
13341353 Effect . orElseSucceed ( ( ) => false ) ,
13351354 ) ) ;
1336- if ( ! emptiedWorkspace )
1355+ if ( ! emptiedWorkspace ) {
1356+ yield * resetIndex ;
13371357 return yield * new VcsProcessExitError ( {
13381358 operation,
13391359 command : "git clean" ,
13401360 cwd : input . cwd ,
13411361 exitCode : cleaned . exitCode ,
13421362 detail : cleaned . stderr . trim ( ) || "Could not clean the checkpoint workspace." ,
13431363 } ) ;
1364+ }
13441365 }
1345- // On Windows the same clean can remove './' and exit 0.
1346- yield * recreateWorkspace ;
1347-
1348- const headExists = yield * hasHeadCommit ( input . cwd ) ;
1349- if ( headExists ) {
1350- yield * execute ( {
1351- operation,
1352- cwd : input . cwd ,
1353- args : [ ...longPaths , "reset" , "--quiet" , "--" , "." ] ,
1354- } ) ;
1355- }
1366+ yield * resetIndex ;
13561367
13571368 return true ;
13581369 } ) ,
0 commit comments