@@ -2499,7 +2499,14 @@ public function worktree_cleanup_merged( array $opts = array() ): array|\WP_Erro
24992499 );
25002500 }
25012501
2502- $ listing = $ this ->worktree_list ();
2502+ $ listing = $ this ->worktree_list (
2503+ null ,
2504+ null ,
2505+ array (
2506+ 'include_status ' => false ,
2507+ 'include_disk ' => false ,
2508+ )
2509+ );
25032510 if ( $ listing instanceof \WP_Error ) {
25042511 return $ listing ;
25052512 }
@@ -2517,7 +2524,8 @@ public function worktree_cleanup_merged( array $opts = array() ): array|\WP_Erro
25172524
25182525 $ this ->emit_worktree_cleanup_progress ( $ progress , 'start ' , '' , $ checked , $ total_worktrees , $ candidates , $ skipped , $ removed_count , $ started_at );
25192526
2520- // Fetch + prune each primary once up-front so upstream-gone signals are fresh.
2527+ // Fetch + prune each primary once per repo, but keep status/disk probes inside
2528+ // the row loop so budgeted dry-runs can return partial evidence promptly.
25212529 $ fetched = array ();
25222530 $ fetch_timeouts = array ();
25232531
@@ -2554,8 +2562,6 @@ public function worktree_cleanup_merged( array $opts = array() ): array|\WP_Erro
25542562 continue ;
25552563 }
25562564
2557- $ dirty_count = (int ) ( $ wt ['dirty ' ] ?? 0 );
2558-
25592565 ++$ checked ;
25602566 $ this ->emit_worktree_cleanup_progress ( $ progress , 'checking ' , (string ) $ handle , $ checked , $ total_worktrees , $ candidates , $ skipped , $ removed_count , $ started_at );
25612567
@@ -2601,6 +2607,13 @@ public function worktree_cleanup_merged( array $opts = array() ): array|\WP_Erro
26012607 continue ;
26022608 }
26032609
2610+ $ dirty_probe = $ this ->probe_worktree_dirty_count ( $ wt_path , self ::CLEANUP_GIT_PROBE_TIMEOUT );
2611+ if ( is_wp_error ( $ dirty_probe ) ) {
2612+ $ skipped [] = $ this ->build_worktree_probe_timeout_skip ( $ handle , $ repo , $ branch , $ wt_path , $ created_at , $ metadata , $ disk_fields , $ dirty_probe );
2613+ continue ;
2614+ }
2615+ $ dirty_count = (int ) $ dirty_probe ;
2616+
26042617 if ( $ dirty_count > 0 && ! $ force ) {
26052618 // Before falling through to the generic dirty_worktree skip, try to
26062619 // classify whether this is the "merged PR + obsolete dirty edits"
0 commit comments