Repository navigation
docs(switch): trim upstream tracking, add missing hooks, combine PR/MR sections - #1521
Conversation
worktrunk-bot
left a comment
There was a problem hiding this comment.
Docs-only PR — changes are accurate and well-structured. Two minor observations:
Details
Hook lifecycle ordering: Steps 5 and 6 list post-start before post-switch, but the code prepares post-switch first, then extends with post-start before spawning both together. Since they're all background hooks spawned in a single batch, the ordering doesn't matter functionally — but step 6 says "Runs" while step 5 says "Spawns", which implies different execution modes. Both are background hooks, so consistent wording (both "Spawns" or both "Runs ... (background)") would be clearer.
Upstream tracking trimming: The removed paragraph about --create not configuring upstream tracking was useful context — it explained why git push -u is needed after creating a branch. The new single-sentence version is tighter but drops the actionable guidance. Worth considering whether a brief note like "use git push -u to set up tracking" would help users who hit that.
Both are minor — this is a nice cleanup overall.
| Requires `gh` (GitHub) or `glab` (GitLab) CLI to be installed and authenticated. The `--create` flag cannot be used with `pr:`/`mr:` syntax since the branch already exists. | ||
|
|
||
| **Fork MRs:** The local branch uses the MR's branch name directly, so `git push` works normally. If a local branch with that name already exists tracking something else, rename it first. | ||
| **Forks:** The local branch uses the PR/MR's branch name directly (e.g., `feature-fix`), so `git push` works normally. If a local branch with that name already exists tracking something else, rename it first. |
There was a problem hiding this comment.
can you confirm this is correct re requiring to rename it?
worktrunk-bot
left a comment
There was a problem hiding this comment.
The latest commit applied the suggestion to docs/content/switch.md but since src/cli/mod.rs is the primary source for command pages, the change needs to go there first — the sync test will propagate it to docs and skills. Currently src/cli/mod.rs and skills/worktrunk/reference/switch.md still have "— standard git behavior" while docs/content/switch.md doesn't.
On the two open questions:
"Spawns" vs "Runs" (line 48): Both post-start and post-switch are background hooks spawned in a single batch. The wording should be consistent — either both "Spawns" or both "Runs ... (background)".
Rename requirement (skills line 105): Verified — when a local branch exists but tracks a different ref, wt switch pr:N fails with BranchTracksDifferentRef and hints git branch -m. For GitHub, it also tries a prefixed name (pr-N/branch) as a fallback before erroring. So the docs are accurate — users do need to rename (or the prefixed fallback kicks in on GitHub only).
|
@worktrunk-bot resolve conflicts |
…R sections - Remove verbose upstream tracking paragraph — `--create` matches standard git behavior (no upstream configured by default) - Add pre-switch and post-switch hooks to worktree creation lifecycle - Merge separate GitHub/GitLab sections into unified PR/MR section Closes #1518 Co-Authored-By: Claude Opus 4.6 <[email protected]>
Co-Authored-By: Claude <[email protected]>
Co-Authored-By: Claude Opus 4.6 <[email protected]>
Co-authored-by: Maximilian Roos <[email protected]>
Co-authored-by: worktrunk-bot <[email protected]>
Co-authored-by: worktrunk-bot <[email protected]>
… source The "Runs" → "Spawns" fix was applied to docs/content/switch.md but not to src/cli/mod.rs (the primary source) or the snapshot. Both post-start and post-switch are background hooks spawned in the same batch. Co-Authored-By: Claude <[email protected]>
8c05f97 to
5c0dd4b
Compare
worktrunk-bot
left a comment
There was a problem hiding this comment.
Stale snapshot: src/cli/mod.rs no longer has "— standard git behavior" but the snapshot still does. The snapshot test will fail — regenerate with cargo test --test integration help_switch_long and commit the updated snapshot.
Previous feedback (rename requirement, "Spawns" wording) is addressed — both look good now.
The snapshot had "— standard git behavior" suffix from a review suggestion applied to docs but not the primary source in cli.rs. Co-Authored-By: Claude Opus 4.6 <[email protected]>
|
Rebased onto main to resolve conflicts with #1523 (experimental badge anchor changes). Also fixed a stale snapshot — All CI checks pass. |
## Summary - Add `INSTA_UPDATE=always cargo test ... "test_help"` guidance to both CLAUDE.md and tests/CLAUDE.md for updating help snapshots after editing `after_long_help` text - Add a note to never manually edit `.snap` files (they contain ANSI escape sequences) ## Evidence In run [23096056615](https://github.com/max-sixty/worktrunk/actions/runs/23096056615), the mention bot edited `after_long_help` in `src/cli/mod.rs` for PR #1521 but only ran `cargo test --lib --bins` before pushing. The `help_switch_long` snapshot test failed in CI, requiring a second commit. The bot then struggled through 7 approaches to update the snapshot: 1. `cargo insta test --accept` (didn't work for file-based snapshots in this context) 2. Manual inspection of the snapshot file with `sed` 3. `cat -A` to examine raw bytes 4. Manual `Edit` of the snapshot file (couldn't reproduce ANSI escapes) 5. Trying to regenerate help output and compare 6. `UPDATE_SNAPSHOTS=1` (wrong env var name) 7. `INSTA_UPDATE=always` (correct — finally worked) The `tests/CLAUDE.md` only mentioned `cargo insta test --accept` for *first-time* inline snapshot creation. There was no guidance for updating existing file-based snapshots, and CLAUDE.md didn't mention the need to update help snapshots after editing help text. ## Test plan - [ ] Verify the new guidance is clear and actionable - [ ] Confirm `INSTA_UPDATE=always cargo test --test integration "test_help"` works as documented 🤖 Generated with [Claude Code](https://claude.com/claude-code) --------- Co-authored-by: worktrunk-bot <[email protected]> Co-authored-by: Claude Opus 4.6 <[email protected]>
Two behavioral issues observed in the past hour's CI runs: 1. Triple approval on PR #1531 — each of 3 commits triggered a new review run, and each re-approved despite the prior approval covering the same PR. The trivial-change exit path said "skip steps 2-3" but didn't explicitly block step 4 (approval), so the bot re-approved on trivial incremental changes. 2. Self-approval attempts on PRs #1521 and #1529 — the bot attempted `gh pr review --approve` on its own PRs before discovering GitHub rejects self-approvals. The authorship check was buried in step 4 instead of being caught in pre-flight. Fixes: - Add IS_SELF_AUTHORED check to pre-flight (step 1) so the bot knows before reaching step 4 - Make trivial-change exit path explicitly skip steps 2, 3, AND 4 - Update step 4 self-authored guidance to reference the pre-flight flag Co-Authored-By: Claude Opus 4.6 <[email protected]>
Summary
--createdoesn't configure upstream tracking, but that's standardgit switch -cbehavior. Removed the prominent explanation and folded the remote-branch note into the existing sentence.pre-switch(step 1) andpost-switch(step 6), matching the actual execution order inhandle_switch.rs.Closes #1518
Test plan
test_command_pages_and_skill_files_are_in_syncpasses (docs auto-synced)🤖 Generated with Claude Code