fix(scripts/cloneWorkTree.fsx): add branch to fetch refspec before git fetch#295
fix(scripts/cloneWorkTree.fsx): add branch to fetch refspec before git fetch#295nodefect wants to merge 1 commit into
Conversation
| .UnwrapDefault() | ||
|
|
||
| let remoteNameForUrlOpt = | ||
| Misc.CrossPlatformStringSplitInLines remoteOutputForSetBranches |
There was a problem hiding this comment.
@nodefect this logic to query remotes is already present in the upper part of the script; either encapsulate it in a function and call it twice, or just call it once at the beginning and reuse its result later
| | Success _ -> () | ||
|
|
||
| // Ensure the branch is included in fetch refspec if it exists on remote | ||
| if isUrl && branchExists then |
There was a problem hiding this comment.
@nodefect there is no need to filter by isUrl=true; the command git remote set-branches --add can also be called even if isUrl=false, because the an existing remote of the git folder can be used (if only one remote present, then use that one; if more than one, then use origin or upstream)
|
/pi I added a PR review above. After addressing it, don't forget to push to the same branch of this PR (which is in nodefect's fork; the github TOKEN you have available belongs to this account) |
1. Eliminated duplicate remote-list parsingExtracted the repeated
Both call sites (inside the 2. Removed the
|
/pi I don't see your second push, try again |
What you need to do:
Once that push succeeds, the PR diff here will update automatically. View action run | Model: ppq/autoclaw | Time: 3m 33s | Tokens: 46.9K | Cost: $0.05 | Pi SDK v0.78.1 | Action v2.19.2 |
|
Superseded by #296 |
Fixes #292
Problem
When
cloneWorkTree.fsxis run on an existing clone to add a worktree for a branch that exists remotely but hasn't been fetched yet,git fetch --allwould not pull the branch because the bare clone's fetch refspec only includes the default branch. As a result,git worktree addwould create a worktree pointing to a local ref that was absent or outdated, effectively checking out the default branch (main) instead of the requested remote branch.Fix
Before
git fetch --all, locate the remote name that corresponds to the requestedrepoUrl, then rungit remote set-branches --add <remote> <branchName>to ensure the branch is included in the fetch refspec. This ensures the remote branch is actually fetched, sogit worktree add <folder> <branch>correctly checks out the intended branch.Changes
scripts/cloneWorkTree.fsx: Added logic to find the remote name for the givenrepoUrland callgit remote set-branches --add <remote> <branchName>whenisExistingClone,isUrl, andbranchExistsare all true.