Skip to content

Commit 4a7c58e

Browse files
authored
Fix cleanup plan local worktree signals (#659)
* Fix cleanup plan local worktree signals * Fix changed-file CLI lint
1 parent 96c0220 commit 4a7c58e

4 files changed

Lines changed: 11 additions & 11 deletions

File tree

inc/Cli/Commands/WorkspaceCommand.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -283,7 +283,7 @@ public function triage( array $args, array $assoc_args ): void {
283283
WP_CLI::error('Usage: wp datamachine-code workspace triage ' . $operation . ' <row-id> --reason=<reason>');
284284
return;
285285
}
286-
$result = $workspace->workspace_row_triage_mark((string) $args[1], 'ignore' === $operation ? 'ignored' : 'quarantined', (string) ( $assoc_args['reason'] ?? '' ));
286+
$result = $workspace->workspace_row_triage_mark( (string) $args[1], 'ignore' === $operation ? 'ignored' : 'quarantined', (string) ( $assoc_args['reason'] ?? '' ) );
287287
$this->render_workspace_triage_result($result, $assoc_args, false);
288288
return;
289289

@@ -292,7 +292,7 @@ public function triage( array $args, array $assoc_args ): void {
292292
WP_CLI::error('Usage: wp datamachine-code workspace triage adopt <row-id> [--name=<name>]');
293293
return;
294294
}
295-
$result = $workspace->workspace_row_triage_adopt((string) $args[1], isset($assoc_args['name']) ? (string) $assoc_args['name'] : null);
295+
$result = $workspace->workspace_row_triage_adopt( (string) $args[1], isset($assoc_args['name']) ? (string) $assoc_args['name'] : null );
296296
$this->render_workspace_triage_result($result, $assoc_args, false);
297297
return;
298298

@@ -321,7 +321,7 @@ private function render_workspace_triage_result( array|\WP_Error $result, array
321321
}
322322

323323
if ( ! $is_list ) {
324-
WP_CLI::success((string) ( $result['message'] ?? 'Workspace triage updated.' ));
324+
WP_CLI::success( (string) ( $result['message'] ?? 'Workspace triage updated.' ) );
325325
$row = is_array($result['row'] ?? null) ? (array) $result['row'] : array();
326326
if ( array() !== $row ) {
327327
$this->format_items(array( $this->workspace_triage_table_row($row) ), array( 'row_id', 'status', 'issues', 'age_days', 'reason', 'path' ), $assoc_args, 'row_id');
@@ -807,7 +807,7 @@ private function run_cleanup_plan( array $assoc_args ): void {
807807
$input['force_artifact_cleanup'] = (bool) $assoc_args['force'];
808808
}
809809
if ( 'json' !== (string) ( $assoc_args['format'] ?? 'table' ) ) {
810-
$profile = $include_artifacts ? 'includes artifact scan' : 'worktree inventory only';
810+
$profile = $include_artifacts ? 'includes artifact scan' : 'local worktree merge signals';
811811
WP_CLI::log(sprintf('Planning cleanup (%s; %s)...', $mode, $profile));
812812
}
813813

@@ -4155,7 +4155,7 @@ private function render_stale_lock_followup( array $report ): void {
41554155
WP_CLI::log('Stale workspace locks:');
41564156
WP_CLI::log(sprintf('Preview: %s', (string) ( $report['preview_command'] ?? 'wp datamachine-code workspace worktree locks --prune-stale --dry-run --format=json' )));
41574157
WP_CLI::log(sprintf('Apply: %s', (string) ( $report['apply_command'] ?? 'wp datamachine-code workspace worktree locks --prune-stale --format=json' )));
4158-
WP_CLI::log((string) ( $report['safety'] ?? 'Active filesystem flocks are reported and protected.' ));
4158+
WP_CLI::log( (string) ( $report['safety'] ?? 'Active filesystem flocks are reported and protected.' ) );
41594159

41604160
$rows = array();
41614161
foreach ( (array) ( $report['database'] ?? array() ) as $row ) {

inc/Workspace/WorkspaceCleanupPlan.php

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -66,11 +66,10 @@ public function workspace_cleanup_plan( array $opts = array() ): array|\WP_Error
6666
if ( $inputs['include_worktrees'] ) {
6767
$worktree_plan = $this->worktree_cleanup_merged(
6868
array(
69-
'dry_run' => true,
70-
'skip_github' => true,
71-
'inventory_only' => true,
72-
'older_than' => $inputs['worktree_older_than'],
73-
'sort' => $inputs['worktree_sort'],
69+
'dry_run' => true,
70+
'skip_github' => true,
71+
'older_than' => $inputs['worktree_older_than'],
72+
'sort' => $inputs['worktree_sort'],
7473
)
7574
);
7675
if ( $worktree_plan instanceof \WP_Error ) {

tests/smoke-worktree-cleanup-cli.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1121,7 +1121,7 @@ public function execute( array $input ): array
11211121
datamachine_code_cleanup_assert('retention' === ( $cleanup_plan_ability->last_input['mode'] ?? '' ), 'cleanup plan receives retention mode');
11221122
datamachine_code_cleanup_assert(false === ( $cleanup_plan_ability->last_input['include_artifacts'] ?? true ), 'retention cleanup plan skips exhaustive artifact scan by default');
11231123
datamachine_code_cleanup_assert(true === ( $cleanup_plan_ability->last_input['include_worktrees'] ?? false ), 'retention cleanup plan keeps inventory worktree planning enabled');
1124-
datamachine_code_cleanup_assert(in_array('Planning cleanup (retention; worktree inventory only)...', WP_CLI::$logs, true), 'human cleanup plan reports bounded scan profile before planning');
1124+
datamachine_code_cleanup_assert(in_array('Planning cleanup (retention; local worktree merge signals)...', WP_CLI::$logs, true), 'human cleanup plan reports bounded scan profile before planning');
11251125
datamachine_code_cleanup_assert(in_array('Artifacts: skipped for bounded retention planning; run `wp datamachine-code workspace cleanup plan --mode=artifacts` when you want artifact rows.', WP_CLI::$logs, true), 'human cleanup plan shows explicit artifact follow-up command');
11261126

11271127
WP_CLI::$logs = array();

tests/smoke-worktree-cleanup.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -599,6 +599,7 @@ public function worktree_list( ?string $repo = null, ?string $state = null, arra
599599
$artifact_row = $cleanup_plan['rows']['artifact_cleanup'][0] ?? array();
600600
$assert(true, str_starts_with((string) ( $artifact_row['row_id'] ?? '' ), 'cleanup-row-'), 'artifact cleanup row has stable row ID');
601601
$assert(true, isset($cleanup_plan['rows']['worktree_removal']), 'cleanup plan includes worktree removal row bucket');
602+
$assert_contains($cleanup_plan['rows']['worktree_removal'] ?? array(), 'demo@unmerged-feature', 'cleanup plan promotes locally clean remote-backed worktree instead of active/no-signal resolver');
602603
$assert(true, isset($cleanup_plan['rows']['resolver']), 'cleanup plan includes optional resolver row bucket');
603604
$chunk_report = $ws->workspace_cleanup_plan_chunks(
604605
array(

0 commit comments

Comments
 (0)