Skip to content

Commit dc12705

Browse files
Fix cleanup eligible drain dry-run counts (#860)
Co-authored-by: homeboy-ci[bot] <266378653+homeboy-ci[bot]@users.noreply.github.com>
1 parent 0e0f22e commit dc12705

3 files changed

Lines changed: 12 additions & 3 deletions

File tree

inc/Cli/Commands/WorkspaceCommand.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6398,6 +6398,10 @@ private function render_worktree_cleanup_eligible_drain_result( array $result, a
63986398
'metric' => 'processed',
63996399
'value' => (int) ( $summary['processed'] ?? 0 ),
64006400
),
6401+
array(
6402+
'metric' => 'planned',
6403+
'value' => (int) ( $summary['planned'] ?? 0 ),
6404+
),
64016405
array(
64026406
'metric' => 'would_remove',
64036407
'value' => (int) ( $summary['would_remove'] ?? 0 ),
@@ -6437,6 +6441,7 @@ private function render_worktree_cleanup_eligible_drain_result( array $result, a
64376441
fn( $row ) => array(
64386442
'pass' => (int) ( $row['pass'] ?? 0 ),
64396443
'processed' => (int) ( $row['processed'] ?? 0 ),
6444+
'planned' => (int) ( $row['planned'] ?? 0 ),
64406445
'would_remove' => (int) ( $row['would_remove'] ?? 0 ),
64416446
'removed' => (int) ( $row['removed'] ?? 0 ),
64426447
'skipped' => (int) ( $row['skipped'] ?? 0 ),
@@ -6445,7 +6450,7 @@ private function render_worktree_cleanup_eligible_drain_result( array $result, a
64456450
),
64466451
$passes
64476452
),
6448-
array( 'pass', 'processed', 'would_remove', 'removed', 'skipped', 'remaining_total', 'bytes' ),
6453+
array( 'pass', 'processed', 'planned', 'would_remove', 'removed', 'skipped', 'remaining_total', 'bytes' ),
64496454
array( 'format' => 'table' ),
64506455
'pass'
64516456
);

inc/Workspace/WorkspaceCleanupEligibleDrainOrchestrator.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@ public function run( array $input ): array|\WP_Error {
8282
'summary' => array(
8383
'passes' => 0,
8484
'processed' => 0,
85+
'planned' => 0,
8586
'would_remove' => 0,
8687
'removed' => 0,
8788
'skipped' => 0,
@@ -133,7 +134,8 @@ public function run( array $input ): array|\WP_Error {
133134
'pass' => $pass,
134135
'dry_run' => ! empty($pass_result['dry_run']),
135136
'processed' => (int) ( $summary['processed'] ?? 0 ),
136-
'would_remove' => ! empty($pass_result['dry_run']) ? count( (array) ( $pass_result['candidates'] ?? array() ) ) : 0,
137+
'planned' => ! empty($pass_result['dry_run']) ? count( (array) ( $pass_result['candidates'] ?? array() ) ) : 0,
138+
'would_remove' => (int) ( $summary['would_remove'] ?? 0 ),
137139
'removed' => (int) ( $summary['removed'] ?? 0 ),
138140
'skipped' => (int) ( $summary['skipped'] ?? 0 ),
139141
'bytes_reclaimed' => (int) ( $summary['bytes_reclaimed'] ?? 0 ),
@@ -147,6 +149,7 @@ public function run( array $input ): array|\WP_Error {
147149
$result['pass_results'][] = $pass_summary;
148150
++$result['summary']['passes'];
149151
$result['summary']['processed'] += $pass_summary['processed'];
152+
$result['summary']['planned'] += $pass_summary['planned'];
150153
$result['summary']['would_remove'] += $pass_summary['would_remove'];
151154
$result['summary']['removed'] += $pass_summary['removed'];
152155
$result['summary']['skipped'] += $pass_summary['skipped'];

tests/smoke-cleanup-eligible-drain.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,8 @@ function cleanup_eligible_drain_assert( bool $condition, string $label ): void {
9898
cleanup_eligible_drain_assert(false === $preview['applied'], 'preview is non-destructive');
9999
cleanup_eligible_drain_assert(1 === count($preview_ability->calls), 'preview runs one pass');
100100
cleanup_eligible_drain_assert('preview' === $preview['summary']['stop_reason'], 'preview stop reason');
101-
cleanup_eligible_drain_assert(2 === $preview['summary']['would_remove'], 'preview counts would-remove candidates');
101+
cleanup_eligible_drain_assert(2 === $preview['summary']['planned'], 'preview counts planned candidates');
102+
cleanup_eligible_drain_assert(0 === $preview['summary']['would_remove'], 'preview does not claim removal before fresh safety checks');
102103

103104
$empty_ability = new CleanupEligibleDrainFakeAbility(
104105
array(

0 commit comments

Comments
 (0)