Repository navigation
fix(xtest): refresh otdf-sdk-mgr bare-repo branches; clean up interrupted js installs - #667
Conversation
|
Note Currently processing new changes in this PR. This may take a few minutes, please wait... ⚙️ Run configuration
📒 Files selected for processing: 1
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info
📝 Walkthrough
Merge Risk: ⚪ Minimal · up to
|
…s installs `git clone --bare` records no fetch refspec, so the `fetch --all --tags` run on every later checkout refreshed tags only. Every branch stayed at clone time, and a worktree added for it -- `install tip`, or `--platform main` -- built that stale commit. checkout.BARE_REFRESH now fetches origin's branches into refs/remotes/origin/* with --prune, for the SDK and platform bare repos alike, and runs after a fresh clone too. checkout.upstream_ref maps a branch name onto those refs. A branch origin no longer has is refused with a CheckoutError rather than built from the clone's copy, and `HEAD` means origin's default branch as of the clone. Fetching into the bare repo's own refs/heads/* instead would move branches that other worktrees have checked out, and would fail for good once upstream replaced a branch `foo` with `foo/bar`. Worktrees are added --detach and reset to the refreshed ref. That also fixes go source rebuilds: checkout_go_from_platform reset an existing worktree to a FETCH_HEAD fetched into the bare repo, and FETCH_HEAD is per worktree, so every rebuild after the first failed with "pathspec 'FETCH_HEAD' did not match". `install tip` for go, js and java now reports a refused branch, or a failed git command with git's stderr, as an error rather than a traceback, as it already did for the platform. The tests run real git against a local origin, through the SDK, go and platform entry points alike: branches, HEAD, tags, SHAs and force-pushed PR refs. isolated_git keeps them off the developer's config, any inherited GIT_DIR, and the network. AGENTS.md claimed the bare clone mapped refs/heads/*, which is what hid this. It and the code comments also said `git pull` fails in a worktree; it fast-forwards or merges origin's default branch into whatever is checked out. install_js_release already removes a partial dist when npm fails (#663). It now does the same when the install is interrupted: install_release skips any dist that exists, so a Ctrl-C mid-install left a directory with no CLI that every later install accepted as installed. Part 2a of the DSPX-4372-t1 plan. Signed-off-by: Dave Mihalcik <dmihalcik@virtru.com>
2ead7ec to
96d1425
Compare
|



Part 2a of the DSPX-4372-t1 plan, split out of #626: fixes the benchmark needs, which every
otdf-sdk-mgrinstall benefits from. Based onmain.What it does
git clone --barerecords no fetch refspec, so thefetch --all --tagsbefore every checkout refreshed tags only. Every branch stayed where the first clone found it, andinstall tip mainor--platform mainbuilt that stale commit.checkout.BARE_REFRESHnow fetches origin's branches intorefs/remotes/origin/*with--prune, for the SDK and platform bare repos alike, andcheckout.upstream_refmaps a branch name onto them. Fetching into the bare repo's ownrefs/heads/*instead would move branches that other worktrees have checked out, leaving their HEAD ahead of their files, and would fail for good once upstream replaced a branchfoowithfoo/bar.HEADmeans origin's default branch as of the clone; a platformHEADworktree used to reset to itself.checkout_go_from_platformreset an existing worktree to aFETCH_HEADfetched into the bare repo, which no worktree can see, so every rebuild after the first failed withpathspec 'FETCH_HEAD' did not match. It now resets to the refreshed ref, like the SDK and platform paths.install tipreports checkout failures as errors. A refused branch, or a failed git command with git's stderr, now printsError: …and exits 1 for go, js and java, as the platform path already did, instead of a traceback.dist/when npm fails. A Ctrl-C mid-install still left a directory holding onlycli.sh, whichinstall_releasethen skipped as installed from then on. Both js install paths now remove it unless the install finished.AGENTS.mdclaimed the bare clone mappedrefs/heads/*, which is what hid the first bug. It and the code comments also saidgit pullfails in a worktree; it merges origin's default branch into whatever is checked out.Validation
uv run pytestinotdf-sdk-mgr: 207 passed, and 321 at the top of this track (feat(xtest): export benchmark manifest pins from otdf-local env #642). ruff, ruff format and pyright are clean.test_checkout.pyruns real git against a local origin. Every shared behaviour is parametrized over the SDK, go and platform entry points: new and existing worktrees follow their branch,HEAD(including beside a tag namedmain), a deleted branch is refused, tags and SHAs are checked out and then reused, and a force-pushedrefs/pull/N/headis followed. This replaces the stubbed command-string test for platform PR refs. SDK-only tests guard other worktrees, force pushes andx→x/yrenames; platform-only tests cover the helper-scripts worktree. ACliRunnertest covers theinstall tiperror path.symbolic-ref --short, treating every non-origin name as a deleted branch, dropping go's explicit PR-ref fetch or its+, swallowing go's refusal, and dropping theinstall tipcatch each fail a test.isolated_gitkeeps those tests off the developer's git config, any inheritedGIT_DIR, and the network (GIT_ALLOW_PROTOCOL=file).Follow-ups
Older problems found while reviewing this PR are fixed in a stack of drafts based on it: #673 (don't reset a directory that isn't a worktree) → #674 (branch names vs versions) → #675 (tags moved upstream) → #676 (
checkout go/--all).Stack (DSPX-4372-t1 plan)
Two parallel tracks from
main; they share no imports and meet in stage 5.maininstall benchmarkotdf-local envexportsmainSummary by CodeRabbit
Bug Fixes
Documentation