You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
- cli.py: 54% (CLI commands tested including secondary worktree usage)
120
-
121
110
7.**Missing Special Symbol Support in `wt run`**
122
111
- Problem: The `wt run` command didn't support the `^` (default) and `-` (previous) symbols, while `wt switch` did
123
112
- Error: Running `wt run ^ "git status"` or `wt run - "git diff"` resulted in "Error: Worktree not found"
124
113
- Solution: Added special handling for both `^` and `-` symbols in the `run` command (cli.py:379-409) to resolve them before looking up the worktree
125
114
- Implementation:
126
115
- Added check `if name == "-":` to find the previous worktree from `.wt_previous` file and resolve it to the worktree name
127
116
- Added check `elif name == "^":` to get the default worktree using `ctx.manager.get_default_worktree()` and use its name
128
-
- Tests: Added five new tests in test_cli.py:
129
-
-`test_run_command`: Tests running a command in a normal worktree
130
-
-`test_run_command_with_default_symbol`: Tests running a command using `^` symbol
131
-
-`test_run_command_with_previous_symbol`: Tests running a command using `-` symbol
132
-
-`test_run_command_no_previous_worktree`: Tests error handling when no previous worktree exists
133
-
-`test_run_command_nonexistent_worktree`: Tests error handling for non-existent worktrees
134
117
- Lesson: Always ensure consistency across commands - if a special symbol works in one command, users will expect it to work in related commands too
135
118
136
119
8.**Implementing wt sync Command**
@@ -151,7 +134,6 @@ wt-worktree/
151
134
- Initially used `error()` function which calls sys.exit, causing tests to fail
152
135
- Fixed by using `warning()` function instead to print errors without exiting
153
136
- This allows the command to continue syncing other worktrees after failures
154
-
- Tests: Added 6 comprehensive tests covering all options and edge cases
155
137
- Lesson: When implementing operations that process multiple items, use warning/info functions instead of error() to avoid early exit
156
138
157
139
9.**Detached Worktree Name Preservation**
@@ -167,16 +149,6 @@ wt-worktree/
167
149
- Modified `list_worktrees()` to retrieve stored names or fallback to `(detached-<commit>)`
168
150
- Fixed base branch selection: detached worktrees now use HEAD instead of default_base
169
151
- Key Insight: Git's `--worktree` config flag requires `extensions.worktreeConfig` to be enabled first
170
-
- Tests: Added 6 comprehensive tests for detached worktree creation, listing, switching, running commands, and deletion
171
152
- Lesson: Per-worktree config in git requires enabling the worktreeConfig extension, and is the right way to store worktree-specific metadata
172
153
- Backward Compatibility: Added `_infer_name_from_path()` to infer names from path patterns for detached worktrees created before this fix or via raw git commands
0 commit comments