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
- Updated CLAUDE.md to clarify testing procedures, including automated BATS tests and manual smoke tests.
- Introduced new functions in `lib/args.sh` for validating positional arguments, improving error handling in command scripts.
- Refactored `lib/copy.sh` to streamline file copying logic with a new `_expand_and_copy_pattern` function, enhancing maintainability.
- Improved `create_worktree` and related functions in `lib/core.sh` for better folder name resolution and branch checking.
- Added comprehensive tests for new and existing functionalities, ensuring robust validation of command behaviors and error handling.
Copy file name to clipboardExpand all lines: CLAUDE.md
+33-13Lines changed: 33 additions & 13 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -14,10 +14,12 @@ This file provides guidance to Claude Code (claude.ai/code) when working with co
14
14
15
15
## Testing
16
16
17
-
This project uses **BATS tests** for core functions and **manual smoke tests** for end-to-end workflows. After any change:
17
+
This project uses **BATS tests** for core functions and **manual smoke tests** for end-to-end workflows. CI runs ShellCheck + BATS automatically on PRs (`.github/workflows/lint.yml`).
18
18
19
19
1. Run automated tests: `bats tests/`
20
-
2. Run relevant manual smoke tests:
20
+
2. Run a single test file: `bats tests/config.bats`
21
+
3. Run a single test by name: `bats tests/config.bats --filter "cfg_map_to_file_key"`
22
+
4. Run relevant manual smoke tests:
21
23
22
24
```bash
23
25
./bin/gtr new test-feature # Create worktree
@@ -30,6 +32,8 @@ This project uses **BATS tests** for core functions and **manual smoke tests** f
30
32
31
33
For exhaustive manual testing (hooks, copy patterns, adapters, `--force`, `--from-current`, etc.), see the full checklist in CONTRIBUTING.md or `.github/instructions/testing.instructions.md`.
32
34
35
+
**Test files**: `adapters`, `config`, `copy_safety`, `integration_lifecycle`, `parse_args`, `provider`, `resolve_base_dir`, `sanitize_branch_name` (all in `tests/`). Shared fixtures in `tests/test_helper.bash`.
36
+
33
37
**Tip**: Use a disposable repo for testing to avoid polluting your working tree:
|`lib/commands/*.sh`| One file per subcommand: `cmd_create`, `cmd_remove`, etc. (16 files) |
66
+
67
+
Libraries are sourced in the order listed above (ui → args → config → ... → launch → commands/\*.sh glob).
59
68
60
69
### Adapters
61
70
@@ -135,6 +144,17 @@ When adding commands or flags, update all three files:
135
144
-`completions/_git-gtr` (Zsh)
136
145
-`completions/git-gtr.fish` (Fish)
137
146
147
+
## Critical Gotcha: `set -e`
148
+
149
+
`bin/gtr` runs with `set -e`. Any unguarded non-zero return silently exits the entire script. When calling functions that may `return 1`, guard with `|| true`:
150
+
151
+
```bash
152
+
result=$(my_func)||true# Prevents silent exit
153
+
if my_func;then ...;fi# Also safe (if guards the return)
154
+
```
155
+
156
+
This is the most common source of subtle bugs in this codebase.
0 commit comments