Skip to content

Match Homebrew casks by bundle identifier and reject implausible name matches - #606

Open
joshmans wants to merge 1 commit into
mangerlahn:mainfrom
joshmans:pr/homebrew-cask-bundle-id-matching
Open

joshmans wants to merge 1 commit into
mangerlahn:mainfrom
joshmans:pr/homebrew-cask-bundle-id-matching

Conversation

@joshmans

Copy link
Copy Markdown

Relates to #297 (false positives for Homebrew casks).

Matching is by app file name only today, so generic names match unrelated casks (for example BrickLink's Studio.app matches wordpresscom-studio), and renamed apps match nothing. This change:

  • Rejects a name-only match when the cask's known bundle identifiers conflict with the app's (different identifier and different vendor), unless the cask's token or display name equals the app's name.
  • When the file name finds nothing, falls back to bundle identifier matching, but only if the cask's token or display name also resembles the app's name. Either signal alone produced false positives (identifiers are shared between suites, names between unrelated apps). Prefers an exact name match, then the base cask over its variants (zoom over zoom-for-it-admins).
  • Uses an identifier index built once, so the fallback does not scan every cask for every app (a naive scan took ~38 s for 400 unmatched apps against 8000 casks in a debug build; with the index the added cost is negligible).

Tests (UpdateRepositoryTest): a renamed app matched by identifier, base cask preferred over variants, identifier-only matches rejected without a resembling name (Safari, an unrelated app), generic-name match rejected on conflicting identifiers, and whole-component vendor comparison.

It touches the same area as #584 (empty OS version strings); I'm happy to rebase on whichever lands first.

Written with Claude's help. I have been running this on my own machine. The only failure in the suite is VersionParserTest.testEmptyVersionParsing, which already fails on main.

🤖 Generated with Claude Code

… matches

Casks are matched to apps by file name only. That misses apps whose file name is not
in the cask data and mismatches apps with generic names: Studio.app (BrickLink Studio)
was matched to the unrelated wordpresscom-studio cask.

- If the file name finds nothing, fall back to the cask's bundle identifiers (taken
  from its zap/uninstall data). A cask is only accepted when its token or display
  name also resembles the app's name, because identifiers appear in other casks'
  cleanup lists (Safari under raindropio, Word under bookends). Ties resolve to an
  exact name, then to the base cask over its variants. Apple apps are never matched.
- A name-only match is rejected when the cask lists identifiers that share neither the
  exact identifier nor the vendor with the app, unless the cask's token or display
  name equals the app's name.
- Entry now decodes the cask's display names.

Relates to mangerlahn#297. Adds tests for the matching rules; they construct a repository from
entries through a new internal initializer.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>

This branch has not been deployed

No deployments
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