Skip to content

feat: harden Cargo workspace detection with TOML parsing#50

Merged
thefourcraft merged 2 commits intoproductionfrom
feature/cargo-workspace-detection-hardening
May 4, 2026
Merged

feat: harden Cargo workspace detection with TOML parsing#50
thefourcraft merged 2 commits intoproductionfrom
feature/cargo-workspace-detection-hardening

Conversation

@thefourcraft
Copy link
Copy Markdown
Member

Summary

  • Replace fragile line-scanner in parse_cargo_workspace_members with proper TOML parsing via the existing toml crate (no new dependencies)
  • Include root package as member "." when Cargo.toml has both [package] and [workspace] (virtual manifests stay unaffected)
  • Respect workspace.exclude patterns, including basic glob matching (* wildcard)
  • Deduplicate members via BTreeSet for deterministic lexicographic ordering
  • Fall back to prior line-scanner if TOML parse fails (malformed files tolerated)

Test plan

  • cargo_workspace_with_package_and_workspace_includes_root_as_dot — root package added as "."
  • cargo_workspace_exclude_removes_matching_members — excluded paths filtered out
  • cargo_workspace_deduplicates_overlapping_patterns — overlapping globs yield no duplicates
  • cargo_workspace_root_member_has_workspace_root_stamped — root member has correct root path
  • All 722 existing tests pass
  • cargo clippy --bin barzel -- -D warnings clean

Replace line-scanner in parse_cargo_workspace_members with proper TOML
parsing via the existing toml crate.

- Parse workspace.members patterns via toml::Value instead of regex scanning
- Include root package as member '.' when both [package] and [workspace] present
- Respect workspace.exclude patterns (including basic glob matching)
- Deduplicate members with BTreeSet for deterministic ordering
- Fall back to prior line-scanner if TOML parse fails (malformed files)
…anged

The '.' member (workspace root with [package]) has member.root == workspace
root, so the old prefix check would select it for every change anywhere in
the repo.  Now '.' is selected only when at least one changed file falls
outside every other member's subtree — a sub-member-only change no longer
spuriously triggers the root package.
@thefourcraft thefourcraft merged commit c626037 into production May 4, 2026
11 checks passed
thefourcraft added a commit that referenced this pull request May 4, 2026
* feat: harden JS workspace glob handling with exclusions and dedup

pnpm-workspace.yaml, lerna.json, and package.json workspaces arrays now:
- Respect !-prefixed exclusion patterns (e.g. '!packages/experimental')
- Deduplicate overlapping patterns (e.g. ["packages/*", "packages/api"])
  via BTreeSet on relative path — first occurrence wins

New helpers: parse_yaml_list_items, js_glob_excludes,
expand_js_workspace_patterns.  Cargo detection from PR #50 is unchanged.

* fix: parse_yaml_list_items scopes to packages: section only

Previously the parser collected list items from every section of
pnpm-workspace.yaml.  Now it tracks whether we are inside the top-level
packages: block and stops collecting when a new top-level key appears, so
values in ignoredBuiltDependencies, catalogs, and other sections cannot
be mistaken for workspace members.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant