fix(workspace): keep generic-loader project roots workspace-relative#77
fix(workspace): keep generic-loader project roots workspace-relative#77gbleu wants to merge 1 commit into
Conversation
parse_package_json kept source_root absolute whenever cwd was absolute (always the case in CLI usage), while changed files parsed from git diff headers are repo-relative. ProjectIndex ownership checks use file_path.starts_with(root), and a relative path never starts with an absolute root — so every npm/yarn/pnpm/bun workspace run on an absolute cwd attributed zero projects and returned an empty affected set, even though discovery and the semantic trace both worked. Strip the cwd prefix unconditionally, matching the Nx loader's behavior. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthrough
Changessource_root Path Fix
Estimated code review effort: 1 (Trivial) | ~5 minutes Possibly related PRs
Suggested reviewers: 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
📦 Preview Release AvailableA preview release has been published for commit c177c02. Installationnpm install https://github.com/frontops-dev/domino/releases/download/pr-77-c177c02/front-ops-domino-1.4.0.tgzRunning the previewnpx https://github.com/frontops-dev/domino/releases/download/pr-77-c177c02/front-ops-domino-1.4.0.tgz affectedDetails |
|
✅ PASS (["@fix/a","@fix/b"] vs stock []) |
Fixes #73.
Problem
In generic workspace mode (npm/yarn/pnpm/bun, no
nx.json), the affected set is always empty when the CLI is run from an absolute cwd — i.e. every real-world invocation. Discovery and the semantic trace both work, but nothing is ever attributed.parse_package_json(src/workspace/workspaces.rs) keptsource_root/rootabsolute whenevercwdis absolute, while changed files parsed from thegit diffheaders (src/git.rs::parse_diff) are repo-relative.ProjectIndex::resolve_packages(src/utils.rs) decides ownership viafile_path.starts_with(root), and a relative path never starts with an absolute root — so every lookup returns empty. The Nx loader (src/workspace/nx.rs) already strips the cwd prefix, which is why Nx-mode attribution works.Net effect: generic mode returns a silent false-green (empty affected set) if used for CI gating.
Fix
Strip the cwd prefix unconditionally in
parse_package_json, matching the Nx loader. Thecwd.is_absolute()branch that preserved the absolute path is removed; thestrip_prefix(cwd).unwrap_or(project_dir)fallback already handles the relative-cwd case. The one unit test asserting the old absolute-root behavior is updated to expect the workspace-relative root.Verification
cargo test— all unit tests pass.nx affectedon a 250-package pnpm monorepo (Nx 22): 251 projects discovered viapnpm-workspace.yaml, correct affected sets across a 14-scenario matrix (comment-only edit → source package only; body change in a shared lib → exact consumer set incl. transitive chains; type-shape change → 3 precise projects vs 16 from Nx's file-graph).Related but distinct: #70 (Nx-mode discovery missing inferred projects).
🤖 Generated with Claude Code
Summary by CodeRabbit