Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion inc/Abilities/WorkspaceAbilities.php
Original file line number Diff line number Diff line change
Expand Up @@ -2288,6 +2288,10 @@ private function registerAbilities(): void {
'type' => 'boolean',
'description' => 'Schedule each candidate as a single-row worktree_cleanup_chunk job for resumable async apply.',
),
'remove_timeout' => array(
'type' => 'integer',
'description' => 'Timeout in seconds for destructive git worktree remove calls during apply. Defaults to the cleanup removal timeout.',
),
'include_repaired_metadata' => array(
'type' => 'boolean',
'description' => 'Also include repaired metadata rows. Requires explicit opt-in and still runs fresh safety probes before removal.',
Expand Down Expand Up @@ -4031,7 +4035,7 @@ public static function worktreeCleanupArtifacts( array $input ): array|\WP_Error
/**
* Apply only worktrees with explicit lifecycle cleanup_eligible metadata in a bounded batch.
*
* @param array $input Input parameters (dry_run, limit, older_than, sort, force, via_jobs, source).
* @param array $input Input parameters (dry_run, limit, older_than, sort, force, via_jobs, remove_timeout, source).
* @return array<string,mixed>|\WP_Error
*/
public static function worktreeBoundedCleanupEligibleApply( array $input ): array|\WP_Error {
Expand All @@ -4051,6 +4055,9 @@ public static function worktreeBoundedCleanupEligibleApply( array $input ): arra
if ( isset($input['sort']) && '' !== trim( (string) $input['sort']) ) {
$opts['sort'] = trim( (string) $input['sort']);
}
if ( isset($input['remove_timeout']) ) {
$opts['remove_timeout'] = (int) $input['remove_timeout'];
}
if ( isset($input['source']) && '' !== trim( (string) $input['source']) ) {
$opts['source'] = trim( (string) $input['source']);
}
Expand Down
15 changes: 11 additions & 4 deletions inc/Cli/Commands/WorkspaceCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -2960,10 +2960,14 @@ private function renderGitOperationResult( string $operation, array $result, arr
* metadata older than the compact duration (cleanup only, e.g. 7d, 24h).
* Candidate worktrees without valid `created_at` metadata are skipped.
*
* [--sort=<field>]
* : Sort cleanup candidates by reporting field. For artifact cleanup,
* `--sort=size` scans the cheap inventory once and returns the largest
* artifact opportunities without manual pagination.
* [--remove-timeout=<seconds>]
* : Timeout for destructive `git worktree remove` during cleanup apply.
* Defaults to a larger removal-specific budget than cheap git probes.
*
* [--sort=<field>]
* : Sort cleanup candidates by reporting field. For artifact cleanup,
* `--sort=size` scans the cheap inventory once and returns the largest
* artifact opportunities without manual pagination.
* ---
* options:
* - size
Expand Down Expand Up @@ -3492,6 +3496,9 @@ public function worktree( array $args, array $assoc_args ): void {
if ( isset($assoc_args['sort']) && '' !== trim( (string) $assoc_args['sort']) ) {
$input['sort'] = trim( (string) $assoc_args['sort']);
}
if ( isset($assoc_args['remove-timeout']) && '' !== trim( (string) $assoc_args['remove-timeout']) ) {
$input['remove_timeout'] = (int) $assoc_args['remove-timeout'];
}
break;
}

Expand Down
1 change: 1 addition & 0 deletions inc/Tasks/WorktreeCleanupChunkTask.php
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ public function executeTask( int $jobId, array $params ): void {
'skip_github' => array_key_exists('skip_github', $params) ? (bool) $params['skip_github'] : true,
'include_repaired_metadata' => ! empty($params['include_repaired_metadata']),
'stale_liveness_only' => ! empty($params['stale_liveness_only']),
'remove_timeout' => isset($params['remove_timeout']) ? (int) $params['remove_timeout'] : null,
)
),
default => new \WP_Error('invalid_cleanup_chunk_type', sprintf('Unknown cleanup chunk type: %s', $chunk_type), array( 'status' => 400 )),
Expand Down
5 changes: 5 additions & 0 deletions inc/Workspace/Workspace.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,11 @@ class Workspace {
*/
protected const CLEANUP_GIT_PROBE_TIMEOUT = 5;

/**
* Bound destructive git worktree removal separately from cheap probes.
*/
protected const CLEANUP_GIT_REMOVE_TIMEOUT = 60;

/**
* Closed PR pages to inspect per repo during cleanup.
*/
Expand Down
Loading
Loading