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
2 changes: 1 addition & 1 deletion inc/Workspace/WorkspaceWorktreeLifecycle.php
Original file line number Diff line number Diff line change
Expand Up @@ -720,7 +720,7 @@ public function worktree_list( ?string $repo = null, ?string $state = null, arra
continue;
}
$entry_path = $this->workspace_path . '/' . $entry;
if ( ! is_dir($entry_path . '/.git') ) {
if ( ! file_exists($entry_path . '/.git') ) {
continue;
}
$primaries[] = $entry;
Expand Down
6 changes: 6 additions & 0 deletions tests/smoke-worktree-lifecycle-metadata.php
Original file line number Diff line number Diff line change
Expand Up @@ -321,6 +321,9 @@ function () use ( $tmp ): void {
$run('git add README.md', $primary);
$run('git commit -m initial', $primary);
$run('git remote add origin https://github.com/acme/demo.git', $primary);
$linked_primary = DATAMACHINE_WORKSPACE_PATH . '/linked-primary';
$run('git worktree add ../linked-primary -b linked-primary HEAD', $primary);
$assert(true, is_file($linked_primary . '/.git'), 'linked primary fixture uses a .git file');
// Synthetic runtime registration so the env-driven session capture has a
// runtime to scan. DMC enumerates no runtime IDs itself — the integration
// layer (here, the test) declares them via the public filter.
Expand All @@ -334,6 +337,9 @@ function () use ( $tmp ): void {

$ws = new \DataMachineCode\Workspace\Workspace();
$GLOBALS['wpdb'] = new DatamachineCodeLifecycleInventoryWpdb();
$linked_list = $ws->worktree_list('linked-primary', null, array( 'include_status' => false, 'include_disk' => false ));
$linked_items = array_values(array_filter($linked_list['worktrees'] ?? array(), fn( $wt ) => ( $wt['handle'] ?? '' ) === 'linked-primary'));
$assert(1, count($linked_items), 'worktree_list discovers primary checkouts whose .git is a file');

$GLOBALS['datamachine_code_test_filters']['datamachine_worktree_disk_budget_thresholds'] = function ( array $thresholds ): array {
$thresholds['refuse_free_bytes'] = PHP_INT_MAX;
Expand Down
Loading