|
32 | 32 | } |
33 | 33 |
|
34 | 34 | $using = slic_target(); |
35 | | -$target_path = slic_plugins_dir( $using ); |
| 35 | +$is_worktree = slic_stacks_is_worktree( $stack_id ); |
| 36 | +$worktree_info = null; |
| 37 | + |
| 38 | +if ( $is_worktree ) { |
| 39 | + $stack_state = slic_stacks_get( $stack_id ); |
| 40 | + if ( $stack_state ) { |
| 41 | + $worktree_info = [ |
| 42 | + 'target' => $stack_state['worktree_target'] ?? null, |
| 43 | + 'branch' => $stack_state['worktree_branch'] ?? null, |
| 44 | + 'full_path' => $stack_state['worktree_full_path'] ?? null, |
| 45 | + ]; |
| 46 | + } |
| 47 | +} |
| 48 | + |
| 49 | +$target_path = $is_worktree && ! empty( $worktree_info['full_path'] ) |
| 50 | + ? $worktree_info['full_path'] |
| 51 | + : slic_plugins_dir( $using ); |
| 52 | + |
36 | 53 | if ( empty( $using ) ) { |
37 | 54 | echo magenta( "Currently not using any target, commands requiring a target will fail." . PHP_EOL ); |
38 | 55 | echo light_cyan( "Stack: {$stack_id}" . PHP_EOL ); |
39 | 56 | return; |
40 | 57 | } |
41 | 58 |
|
42 | | -echo light_cyan( "Using {$using}" . PHP_EOL ); |
| 59 | +if ( $is_worktree && ! empty( $worktree_info['target'] ) && ! empty( $worktree_info['branch'] ) ) { |
| 60 | + echo light_cyan( "Using {$using} ({$worktree_info['target']} worktree for {$worktree_info['branch']})" . PHP_EOL ); |
| 61 | +} else { |
| 62 | + echo light_cyan( "Using {$using}" . PHP_EOL ); |
| 63 | +} |
43 | 64 | echo light_cyan( "Stack: {$stack_id}" . PHP_EOL ); |
44 | 65 |
|
45 | 66 | // Show stack ports - ensure they're up-to-date from Docker |
|
60 | 81 | } |
61 | 82 |
|
62 | 83 | if ( $target_path === getcwd() ) { |
63 | | - echo light_cyan( PHP_EOL . "The directory you are in is the current use target." ); |
| 84 | + $message = $is_worktree |
| 85 | + ? "The directory you are in is the current use target of the worktree." |
| 86 | + : "The directory you are in is the current use target."; |
| 87 | + echo light_cyan( PHP_EOL . $message ); |
64 | 88 | } else { |
65 | | - echo yellow( PHP_EOL . "The directory you are in is not the current use target." ); |
| 89 | + $message = $is_worktree |
| 90 | + ? "The directory you are in is not the current use target of the worktree." |
| 91 | + : "The directory you are in is not the current use target."; |
| 92 | + echo yellow( PHP_EOL . $message ); |
66 | 93 | } |
0 commit comments