Skip to content

fix: Make melos version --ignore correctly filter packages#1001

Merged
spydon merged 5 commits intomainfrom
fix/version-ignore-filter
Apr 5, 2026
Merged

fix: Make melos version --ignore correctly filter packages#1001
spydon merged 5 commits intomainfrom
fix/version-ignore-filter

Conversation

@spydon
Copy link
Copy Markdown
Collaborator

@spydon spydon commented Apr 5, 2026

Summary

  • Remove assertion blocking package filters for the version commandparsePackageFilters() in base.dart had an assert that explicitly prevented the version command from using it, left as "unimplemented" when filter support was added for the run command.
  • Filter --manual-version packages against --ignore — Manually specified packages that match the ignore glob are now skipped with a warning instead of being silently versioned.
  • Filter dependent package traversal against --ignore — Ignored packages are excluded from the dependentPackagesToVersion set and are not traversed through. This means packages that would only need a version bump via an ignored intermediate package are also correctly excluded. If a package has a non-ignored path to a versioned package, it still gets bumped as expected.

Test plan

  • melos version --ignore "pkg_name" should exclude matching packages from versioning
  • melos version --ignore "mid" --manual-version "mid:1.0.0" should skip mid with a warning
  • Given chain core → mid → app, running melos version --ignore "mid" with a core version bump should NOT bump mid or app
  • Given core → mid (ignored) and core → app and mid → app, running with --ignore "mid" should still bump app (direct non-ignored dependency on core)
  • Verify existing version command behavior (without --ignore) is unchanged

The `--ignore` flag (and other package filters) were not being applied
to the `version` command due to an assertion in `parsePackageFilters()`
that explicitly blocked it. Additionally, dependent packages and manual
versions bypassed the ignore filter entirely.

- Remove assertion blocking package filters for the version command
- Filter `--manual-version` packages against filtered packages with warning
- Filter dependent package traversal so ignored packages are excluded
  and not traversed through, preventing downstream packages from being
  versioned via an ignored intermediate
@docs-page
Copy link
Copy Markdown

docs-page bot commented Apr 5, 2026

To view this pull requests documentation preview, visit the following URL:

docs.page/invertase/melos~1001

Documentation is deployed and generated using docs.page.

Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request ensures that ignored packages are correctly excluded during the melos version process, including manual versioning and dependent traversal. Feedback identifies a correctness bug where transitive dependent traversal is incorrectly nested within a loop, potentially skipping updates when only graduating pre-releases. Additionally, improvements are suggested to use more idiomatic Dart for map lookups and collection filtering.

spydon added 3 commits April 5, 2026 04:25
…anges

If a package depends (directly or transitively) on an ignored package
that has versionable commits, versioning it would produce a broken
release since the ignored dependency won't be bumped. These packages
are now skipped with a warning.
- Move BFS traversal outside the packagesToVersion loop so dependents
  of graduated packages are also transitively resolved
- Use direct map lookup instead of keys.contains for filteredPackages
- Simplify packagesToManuallyVersion with map/whereType
- Fix expected version for dependent bump: 0.0.1+1 not 0.0.2
- Include ignored packages from --manual-version in the
  ignored-with-changes set so dependents are correctly blocked
@spydon spydon merged commit e03d1cb into main Apr 5, 2026
9 checks passed
@spydon spydon deleted the fix/version-ignore-filter branch April 5, 2026 02:53
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