Skip to content

fix: match from_package selection against component's own package#26

Merged
flxapps merged 3 commits intomainfrom
fix/from-package-selection-own-package
Mar 25, 2026
Merged

fix: match from_package selection against component's own package#26
flxapps merged 3 commits intomainfrom
fix/from-package-selection-own-package

Conversation

@flxapps
Copy link
Copy Markdown
Collaborator

@flxapps flxapps commented Mar 25, 2026

The from_package selection in magnitude overrides only matched components whose superclass came from the specified package, not components defined in that package. So if you re-export classes from an upstream package (like patrol) and configure:

magnitude_overrides:
  - operations: ["*"]
    magnitude: ignore
    selection:
      from_package:
        - patrol

...changes to classes like AndroidSelector — which is defined in patrol, not subclassing anything from it — would still show up in every changelog. The override was silently doing nothing for them.

Fixed by also checking context.ownPackage (extracted from the component's package: URI filePath) against the from_package list. Added tests for the new behaviour and a regression guard for the existing superclass-package path.

@github-actions
Copy link
Copy Markdown

Version Analysis

Next Version: 6.0.5

Changelog: 📄 View detailed changelog in job summary

Badge:
Version Badge

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Fixes from_package magnitude override selection so it matches components defined in a given external package (via package: URI filePath), not only components whose superclass originated from that package—addressing missed overrides for re-exported classes.

Changes:

  • Extend from_package matching to also compare against the component’s own package parsed from component.filePath.
  • Add focused unit tests covering direct-package matching, non-matches, multi-package lists, magnitude downgrades, and enclosing-context behavior.
  • Add a regression test to ensure superclass-package matching still works.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
test/comparators/apply_overrides_test.dart Adds test coverage for from_package matching via package: file paths and regression guards.
lib/doc_comparator/apply_overrides.dart Implements own-package matching by parsing package: URIs from filePath in selection context.
Comments suppressed due to low confidence (1)

lib/doc_comparator/apply_overrides.dart:112

  • In the fromPackage loop, context.ownPackage is evaluated for every configured package, and it currently parses the URI each time. For large change sets and multiple overrides, this adds avoidable overhead. Consider computing final ownPackage = context.ownPackage; once before the loop (or caching it in _SelectionContext) and comparing against that.
  if (selection.fromPackage != null) {
    bool packageMatched = false;
    for (final package in selection.fromPackage!) {
      // Match if the component is defined in the package (via its filePath)
      if (context.ownPackage == package) {
        packageMatched = true;
        break;
      }
      // Also match if the component's superclass comes from the package
      if (context.superClassPackages.contains(package)) {
        packageMatched = true;
        break;
      }
    }

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread lib/doc_comparator/apply_overrides.dart
@github-actions
Copy link
Copy Markdown

Version Analysis

Next Version: 6.0.5

Changelog: 📄 View detailed changelog in job summary

Badge:
Version Badge

@github-actions
Copy link
Copy Markdown

Version Analysis

Next Version: 6.0.5

Changelog: 📄 View detailed changelog in job summary

Badge:
Version Badge

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated no new comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@flxapps flxapps merged commit 1af5c40 into main Mar 25, 2026
8 checks passed
@flxapps flxapps deleted the fix/from-package-selection-own-package branch March 25, 2026 10:56
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.

2 participants