fix(scripts/cloneWorkTree.fsx): add branch to fetch refspec before git fetch --all#296
fix(scripts/cloneWorkTree.fsx): add branch to fetch refspec before git fetch --all#296nodefect wants to merge 3 commits into
Conversation
cdd219d to
01496fb
Compare
87cd1c6 to
40c4a62
Compare
06b20ad to
beb6ec9
Compare
5c05f68 to
52912a2
Compare
93a5f2a to
73f9c39
Compare
bd0d748 to
911dfde
Compare
a5d9150 to
68011fc
Compare
|
/pi please review this PR |
|
Overall this is a solid and much-needed fix for #292. The core change — running However, I have a few concerns with the refactoring that introduce functional regressions. 🐛 Bug:
|
c7552b1 to
43308b0
Compare
43308b0 to
58be90e
Compare
|
/pi ok please address the "// TODO: add headBranch even if ArgType is not URL?", as it was suggested in the PR review Remember that you can pull nodefect's branch (on nodefect's fork) and push commits on top of it (the TOKEN you have available is the one that corresponds to this |
|
Done. Pushed a commit to the PR branch that resolves the TODO:
This makes the View action run | Model: ppq/autoclaw | Time: 5m 20s | Tokens: 305.5K | Cost: $0.11 | Pi SDK v0.78.1 | Action v2.19.2 |
Use git remote set-brances --add (fetch branch) for the target branch and head branch (main/master) in all remotes that contain them; and stop using `git rev-parse` because we prefer to use remote info rather than local (and potentially outdated) info. Also refactored: it turns out that the invocation of 'git symbolic-ref' was dead code (maybe since the introduction of 'git worktree add -b' usage). Fixes tarsgate#292
If a branch is in many remotes at the same time, prefix it with the remote name (and prefer non forks when choosing the remote name), otherwise the 'git worktree add' command could fail with: ``` git worktree add wip-npmAudit wip/npmAudit fatal: invalid reference: wip/npmAudit Git worktree add failed. ```
Fetch head branch in fetch refspec also for FolderName args.
37e9c2b to
731822e
Compare
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, rungit remote set-branches --add <remote> <branchName>on all remotes 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.Refactoring
Removed the separate
remoteBranchExistsvariable and consolidated branch checking into a singlebranchExistsbinding:git ls-remotegit ls-remoteThis eliminates the split between
isUrl/isExistingClonelogic for branch checks and ensures there's only one conceptual invocation ofgit ls-remote.Updates
Addressed the TODO regarding
headBranchforFolderNamearguments: when the first argument is a local folder path rather than a URL, the script now queries the current default branch viagit symbolic-ref --short HEADand includes it in the fetch refspec alongside the requested branch. If the query fails (e.g., detached HEAD), it gracefully falls back to fetching only the target branch.