Repository navigation
refactor(switch): consolidate handle_switch into worktree/switch - #2597
Conversation
worktrunk-bot
left a comment
There was a problem hiding this comment.
Windows build is broken: cargo build fails with three unused_imports errors in src/commands/worktree/mod.rs (test (windows) run).
The root cause is that commands::picker is #[cfg(unix)]-gated, and after this refactor picker is the only consumer of these re-exports. Before the move, handle_switch.rs (compiled on all platforms) also pulled them through worktree::*, which kept them live on Windows. Now that run_switch lives inside worktree/switch.rs and reaches its helpers via super::resolve::* and same-module paths, nothing on Windows references the worktree:: re-exports of offer_bare_repo_worktree_path_fix, execute_switch, plan_switch, approve_switch_hooks, run_pre_switch_hooks, or spawn_switch_background_hooks.
path_mismatch survives because repository_ext.rs (always compiled) still consumes it via super::worktree::path_mismatch.
Fix is to gate the picker-only re-exports on #[cfg(unix)]. Inline suggestion below. Happy to push the commit if you prefer.
The codecov/patch failure on the same run looks like a side-effect of the move — codecov treats lines 1045–1525 of the new switch.rs as added patch lines even though they're the same code as the old handle_switch.rs. Worth re-checking once Windows compiles.
CI failed — Windows build breaks with unused_imports errors after the picker re-exports lost their non-picker consumer (handle_switch.rs).
`handle_switch.rs` was a thin coordinator over `worktree/switch.rs` — loading config, planning, approving hooks, executing, and handling output/shell-integration prompts. The split forced cross-file imports of `SwitchOptions`, `SwitchPlan`, `SwitchBranchInfo`, `SwitchResult`, `plan_switch`, and `execute_switch` despite all the real work living in `worktree/switch.rs`. Move the body into `worktree/switch.rs` as `run_switch` (renamed from `handle_switch`) and delete `src/commands/handle_switch.rs`. Update the two call sites (`main.rs`, `commands/picker/mod.rs`) and the `STDOUT_ALLOWED_PATHS` allowlist. Drop the now-unused `SwitchPlan` re-export from `commands/worktree/mod.rs`. No behavior change. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
b5eeab3 to
5078f2d
Compare
After consolidating handle_switch into worktree/switch, several worktree re-exports are consumed only by `commands::picker`, which is `#[cfg(unix)]`-gated. On Windows they trigger `unused_imports` and break the build. Gate them on `cfg(unix)` so they only exist where their consumer does. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
5078f2d to
2ca655d
Compare
Lost in the modify/delete merge with #2597 (which renamed handle_switch to run_switch in worktree/switch.rs). Local pre-merge passed because the working tree had the edit, but the merge commit didn't stage it. Co-Authored-By: Claude <[email protected]>
Adds Azure DevOps as a third forge alongside GitHub and GitLab: - `wt switch pr:N` dispatches to GitHub or Azure DevOps automatically based on the repo's configured remotes (GitHub still wins in mixed-remote setups). - `wt list --full` surfaces Azure DevOps PR and pipeline status via the `az` CLI. - `forge.platform` accepts `azure-devops` as an override. - `wt config show --full` reports `az` install/auth state when the platform is detected as Azure DevOps. Implementation notes: - New `AzureDevOpsProvider` implements `RemoteRefProvider`; auto-detects the organisation from any Azure DevOps remote URL so contributors don't have to pass `--org`. - `GitRemoteUrl` learns `is_azure_devops()`, `azure_organization()`, and `azure_project()` to parse `dev.azure.com`, `ssh.dev.azure.com`, and legacy `*.visualstudio.com` URLs (which don't fit the standard host/owner/repo shape). - Pipeline URLs are constructed from org/project/build ID rather than the API's `url` field (which is a REST endpoint, not a browser URL). - Requires the `azure-devops` extension (`az extension add --name azure-devops`). Originally proposed by @mikeyroush in max-sixty#1256; reimplemented against current `main` to pick up the `[forge]` config section (max-sixty#1826), `url.insteadOf` fallback (max-sixty#1771), and `handle_switch` consolidation (max-sixty#2597) that landed after the original branch. Co-Authored-By: mroush <[email protected]> Co-Authored-By: Claude <[email protected]>
Summary
src/commands/handle_switch.rswas a thin coordinator oversrc/commands/worktree/switch.rs. The boundary forced cross-file imports ofSwitchOptions,SwitchPlan,SwitchBranchInfo,SwitchResult,plan_switch, andexecute_switchdespite all the real work living inworktree/switch.rs.worktree/switch.rsasrun_switch(renamed fromhandle_switch) and deletedsrc/commands/handle_switch.rs.main.rs,commands/picker/mod.rs),commands/mod.rs, theSTDOUT_ALLOWED_PATHSallowlist intests/integration_tests/output_system_guard.rs, and thehandle_switch.rsreference insrc/git/error.rs. Dropped the now-unusedSwitchPlanre-export fromcommands/worktree/mod.rs.cargo run -- hook pre-merge --yespasses (3490 tests + lints + doc + insta + lychee).Test plan
cargo run -- hook pre-merge --yes(full pre-merge: tests, lints, doc, insta, lychee)cargo check --bins --tests --features shell-integration-tests🤖 Generated with Claude Code