Skip to content

Commit a0ab632

Browse files
authored
Merge pull request #460 from Extra-Chill/fix-workspace-show-duplicate-loop
Prevent repeated workspace show loops
2 parents 9b9c76c + 7645358 commit a0ab632

2 files changed

Lines changed: 8 additions & 4 deletions

File tree

inc/Tools/WorkspaceTools.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -908,8 +908,7 @@ public function getListDefinition(): array
908908
*/
909909
public function getShowDefinition(): array
910910
{
911-
return $this->repeatableDefinition(
912-
array(
911+
return array(
913912
'class' => __CLASS__,
914913
'method' => 'handleShow',
915914
'description' => 'Show detailed information about a workspace repository (branch, remote, latest commit, dirty count).',
@@ -923,7 +922,6 @@ public function getShowDefinition(): array
923922
),
924923
'required' => array( 'name' ),
925924
),
926-
)
927925
);
928926
}
929927

tests/smoke-workspace-policy-tools.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ static function ( array $tools ) use ( $tool_id, $definition_callback, $contexts
7777

7878
echo "Workspace policy tools - smoke\n";
7979

80-
new \DataMachineCode\Tools\WorkspaceTools();
80+
$workspace_tools = new \DataMachineCode\Tools\WorkspaceTools();
8181
$tools = apply_filters('datamachine_tools', array());
8282

8383
$default_pipeline_tools = array(
@@ -94,6 +94,12 @@ static function ( array $tools ) use ( $tool_id, $definition_callback, $contexts
9494
$assert("{$tool} remains default pipeline-visible", array( 'chat', 'pipeline' ) === ( $tools[ $tool ]['modes'] ?? null ));
9595
}
9696

97+
$show_definition = $workspace_tools->getShowDefinition();
98+
$assert('workspace_show does not allow duplicate repeat calls', 'repeatable' !== ( $show_definition['runtime']['duplicate_policy'] ?? null ));
99+
100+
$ls_definition = $workspace_tools->getLsDefinition();
101+
$assert('workspace_ls still allows intentional repeat calls', 'repeatable' === ( $ls_definition['runtime']['duplicate_policy'] ?? null ));
102+
97103
$policy_tools = array(
98104
'workspace_write',
99105
'workspace_edit',

0 commit comments

Comments
 (0)