Repository navigation
worktree.sh: fall back to local origin/main when git fetch fails offline - #62
Conversation
|
Hi @BunsDev, could you take a look at this offline fallback fix for worktree.sh when you get some time? Verified with npm test and signed with SSH. Thank you! |
BunsDev
left a comment
There was a problem hiding this comment.
Thanks, this makes sense. new now cuts from the local origin/main with a note instead of aborting under set -e. In remove, a stale origin/main can only make the merged check answer "not merged", which keeps the branch, so that's the safe direction. Modex itself reads only the last stdout line of worktree.sh new and looks at stderr only on failure, so the new note can't break worktree threads.
One suggestion: 2>/dev/null hides why the fetch failed, which could be offline, expired credentials or a different remote name. Leaving git's own error visible next to the note, or including it in the note, would make the stale-base case easier to diagnose.
CI: the one failure, supervisor death without a cleanup receipt never authorizes deletion with write EPIPE, is a known flake on the older main this run tested against. It's fixed on main by #64 and isn't related to this change.
Before merge
- GitHub shows
0be1b8cas unverified (unknown_key), andmainrequires verified signatures. Add the SSH key you sign with as a Signing key under Settings → SSH and GPG keys. The rebase below then produces a verified commit. mainrequires branches to be up to date, so please rebase onto the currentmain. That also picks up the #64 fix for the flaky test.
0be1b8c to
0261596
Compare
|
Thanks for the review and suggestion, @BunsDev! I've updated the PR:
|
BunsDev
left a comment
There was a problem hiding this comment.
Reviewed and verified with a simulated offline clone (origin pointed at an unresolvable host).
new: onmainthe script aborts with exit 128 and creates nothing. With this change git's error stays visible, the note prints, and the worktree is cut from the localorigin/main.remove, branch with no commits of its own: completes and deletes the branch. It's an ancestor of the localorigin/main.remove, branch with an unmerged commit: onmainthe script exits 128 after the worktree is already gone, before reporting the branch. With this change it finishes and keeps the branch (branch work kept (not merged into origin/main)). Thels-remote/ghchecks also fail offline and resolve to "not merged", so the safe default holds.
The repo has no shell-test harness, so this manual run is the regression evidence. Cosmetic: the later ls-remote still prints one fatal: line during an offline remove. Thanks!
🤖 Generated with Claude Code
|
Thanks for reviewing and verifying the offline behavior locally! Glad the fallback works safely in both |
…67) The three contributor bug fixes landed today: send rejections reach the caller (#61), staged renames diff as renames (#60, with its follow-ups noted), and worktree.sh survives a failed fetch (#62). #39's branding images merged yesterday. Drop all four from "Open contributor PRs". Co-authored-by: Claude Opus 5.5 <[email protected]>
Fixes #58
Summary
Allows
scripts/worktree.sh new <name>andremove <name>to work offline by treatinggit fetch -q origin mainas best-effort rather than aborting the script underset -e.Changes
new <name>: If fetchingorigin/mainfails, git's error output remains visible on stderr alongside a note (note: could not fetch origin/main; using local ref), and the script falls back to cutting the branch from the localorigin/mainref.remove <name>: If the fetch fails during removal, the script continues cleanly with|| trueand checks merge status against the local ref (which safely keeps unmerged branches).Verification
origin/mainref with error diagnosis visible.mainand ran the full test suite (npm test: 147/147 passing).