fix: Make melos version --ignore correctly filter packages#1001
Merged
Conversation
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
|
To view this pull requests documentation preview, visit the following URL: docs.page/invertase/melos~1001 Documentation is deployed and generated using docs.page. |
There was a problem hiding this comment.
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.
…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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
parsePackageFilters()inbase.darthad anassertthat explicitly prevented theversioncommand from using it, left as "unimplemented" when filter support was added for theruncommand.--manual-versionpackages against--ignore— Manually specified packages that match the ignore glob are now skipped with a warning instead of being silently versioned.--ignore— Ignored packages are excluded from thedependentPackagesToVersionset 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 versioningmelos version --ignore "mid" --manual-version "mid:1.0.0"should skipmidwith a warningcore → mid → app, runningmelos version --ignore "mid"with acoreversion bump should NOT bumpmidorappcore → mid (ignored)andcore → appandmid → app, running with--ignore "mid"should still bumpapp(direct non-ignored dependency oncore)--ignore) is unchanged