fix(newTree.fsx): crash if remote branch disappears#326
Conversation
|
Hey @nodefect, one or more CI jobs failed. Please check the workflow logs. |
5d9bb78 to
4f676b6
Compare
Reset remote branch tracking to avoid stale refs: replacing per-branch 'git remote set-branches --add' with a single per-remote 'git remote set-branches' (without --add) to reset the tracked branches to only those that still exist. This fixes the crash when a previously-tracked remote branch is deleted (e.g. after a PR is merged), because 'git fetch --all' no longer tries to fetch stale refs. To avoid breaking existing worktrees, we now also inspect the branches currently used by local worktrees (via 'git worktree list --porcelain') and include them in the set of branches to track. Fixes tarsgate#325
4f676b6 to
dfb7d16
Compare
|
/pi I just tested this with a PR URL as an argument, and it failed with this error: Please fix it, and remember you can push directly to this branch that PR326 targets (thanks to the TOKEN that you have access to). |
When a remote has no fetch refspec yet (e.g. after a single-branch bare clone that was renamed), without --add fails. Use --add in that case, and keep the original set-branches behaviour when refspecs already exist so stale branches are still cleared.
|
The fix has been pushed directly to the PR branch Root cause: Fix:
This preserves the stale-branch cleanup for existing remotes while also working for a fresh clone. View action run | Model: ppq/autoclaw | Time: 7m 59s | Tokens: 2.4M | Cost: $0.14 | Pi SDK v0.78.1 | Action v2.19.2 |
|
Hey @nodefect, one or more CI jobs failed. Please check the workflow logs. |
Problem
newTree.fsxcrashes withfatal: couldn't find remote ref refs/heads/someBranchwhen a previously-tracked remote branch is deleted (e.g. after a PR is merged).Cause
The script used
git remote set-branches --add \u003cremote\u003e \u003cbranch\u003eonce per branch. Since--addis cumulative, deleted branches stayed in the refspec forever andgit fetch --alllater tried (and failed) to fetch them.Fix
GetExistingWorktreeBranches— inspectsgit worktree list --porcelainso we know which branches existing local worktrees depend on.git ls-remote).git remote set-branches \u003cremote\u003e \u003cbranch\u003e…(without--add) per remote. This resets the refspec to exactly the branches that still exist, clearing any stale entries.Closes #325