Commit 3aff87e
authored
Fix trunk branch bug in SSH createWorkspace (#435)
## Description
This PR adds a TDD test and fixes the trunk branch bug in the
`createWorkspace` functionality.
## Bug Fixed
When creating a new workspace, the `trunkBranch` parameter should
specify which branch to create the new branch from. However, in
SSHRuntime, this parameter was being ignored and new branches were
created from HEAD instead.
**Location**: `src/runtime/SSHRuntime.ts`
- The `trunkBranch` parameter was destructured as `_trunkBranch`
(unused)
- Branch creation used `HEAD` instead of the provided `trunkBranch`
- After `git clone` from bundle, branches exist as `origin/*` refs,
requiring proper reference resolution
## Changes
### 1. Added TDD Test (`tests/ipcMain/createWorkspace.test.ts`)
- Test: "creates new branch from specified trunk branch, not from
default branch"
- Runs for both LocalRuntime and SSHRuntime (runtime matrix)
- Uses unified verification with `WORKSPACE_EXECUTE_BASH`
- Creates distinct branch structure to verify correct trunk is used
### 2. Fixed SSHRuntime (`src/runtime/SSHRuntime.ts`)
- Use `trunkBranch` parameter instead of ignoring it
- Reference `origin/trunkBranch` for remote tracking branches after git
clone
- Maintains backward compatibility with local branch fallback
### 3. Added File Polyfill (`tests/setup.ts`)
- Node 18 + undici compatibility fix
## Test Scenario
1. Creates `custom-trunk` branch with `trunk-file.txt`
2. Creates `other-branch` with `other-file.txt`
3. Creates workspace specifying `custom-trunk` as trunk branch
4. Verifies workspace contains `trunk-file.txt` ✓
5. Verifies workspace does NOT contain `other-file.txt` ✓
6. Verifies git log contains "Custom trunk commit" ✓
## Results
- ✅ **LocalRuntime**: Test passes (already worked correctly)
- ✅ **SSHRuntime**: Test now passes (bug fixed!)
Both runtimes now correctly respect the `trunkBranch` parameter.
## Technical Details
The fix accounts for how git clone handles branches:
- After `git clone` from bundle, branches exist as remote tracking
branches (`origin/*`)
- When creating a new branch, we must reference `origin/trunkBranch` to
resolve the correct ref
- The command tries: local branch → `origin/branch` → fallback to
`branch`1 parent 5c24be2 commit 3aff87e
File tree
3 files changed
+124
-12
lines changed- src/runtime
- tests
- ipcMain
3 files changed
+124
-12
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
480 | 480 | | |
481 | 481 | | |
482 | 482 | | |
483 | | - | |
| 483 | + | |
| 484 | + | |
| 485 | + | |
| 486 | + | |
| 487 | + | |
| 488 | + | |
| 489 | + | |
| 490 | + | |
| 491 | + | |
| 492 | + | |
| 493 | + | |
| 494 | + | |
| 495 | + | |
| 496 | + | |
| 497 | + | |
484 | 498 | | |
485 | 499 | | |
486 | 500 | | |
| |||
669 | 683 | | |
670 | 684 | | |
671 | 685 | | |
672 | | - | |
673 | | - | |
674 | | - | |
675 | | - | |
676 | | - | |
677 | | - | |
678 | | - | |
| 686 | + | |
679 | 687 | | |
680 | 688 | | |
681 | 689 | | |
| |||
694 | 702 | | |
695 | 703 | | |
696 | 704 | | |
697 | | - | |
698 | | - | |
699 | | - | |
| 705 | + | |
| 706 | + | |
700 | 707 | | |
701 | | - | |
| 708 | + | |
| 709 | + | |
| 710 | + | |
| 711 | + | |
702 | 712 | | |
703 | 713 | | |
704 | 714 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
273 | 273 | | |
274 | 274 | | |
275 | 275 | | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
| 282 | + | |
| 283 | + | |
| 284 | + | |
| 285 | + | |
| 286 | + | |
| 287 | + | |
| 288 | + | |
| 289 | + | |
| 290 | + | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
| 297 | + | |
| 298 | + | |
| 299 | + | |
| 300 | + | |
| 301 | + | |
| 302 | + | |
| 303 | + | |
| 304 | + | |
| 305 | + | |
| 306 | + | |
| 307 | + | |
| 308 | + | |
| 309 | + | |
| 310 | + | |
| 311 | + | |
| 312 | + | |
| 313 | + | |
| 314 | + | |
| 315 | + | |
| 316 | + | |
| 317 | + | |
| 318 | + | |
| 319 | + | |
| 320 | + | |
| 321 | + | |
| 322 | + | |
| 323 | + | |
| 324 | + | |
| 325 | + | |
| 326 | + | |
| 327 | + | |
| 328 | + | |
| 329 | + | |
| 330 | + | |
| 331 | + | |
| 332 | + | |
| 333 | + | |
| 334 | + | |
| 335 | + | |
| 336 | + | |
| 337 | + | |
| 338 | + | |
| 339 | + | |
| 340 | + | |
| 341 | + | |
| 342 | + | |
| 343 | + | |
| 344 | + | |
| 345 | + | |
| 346 | + | |
| 347 | + | |
| 348 | + | |
| 349 | + | |
| 350 | + | |
| 351 | + | |
| 352 | + | |
| 353 | + | |
| 354 | + | |
| 355 | + | |
| 356 | + | |
| 357 | + | |
| 358 | + | |
| 359 | + | |
| 360 | + | |
| 361 | + | |
| 362 | + | |
| 363 | + | |
| 364 | + | |
276 | 365 | | |
277 | 366 | | |
278 | 367 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
9 | 9 | | |
10 | 10 | | |
11 | 11 | | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
0 commit comments