Skip to content

Allow tap-qualified formula names - #18

Merged
korylprince merged 2 commits into
macadmins:mainfrom
korylprince:allow-tap-qualified-formula
Nov 12, 2026
Merged

korylprince merged 2 commits into
macadmins:mainfrom
korylprince:allow-tap-qualified-formula

Conversation

@korylprince

Copy link
Copy Markdown
Contributor

Summary

Formula arguments are currently validated against ^[A-Za-z0-9+@._-]{1,128}$, so tap-qualified names such as homebrew/core/foo are rejected with invalid formula name. That leaves no way to target a specific tap when more than one tap provides a formula with the same name.

This change accepts an optional user/repo/ prefix on formula arguments:

  • The tap user and repo must start with an alphanumeric character and are limited to 64 characters each, so empty segments, leading -/., and .. are rejected.
  • The formula part is unchanged.
  • Casks from the official homebrew/cask* taps are still rejected, which keeps the existing homebrew/cask/vlc test case.

With check, a tap-qualified name won't match an entry in the brew info --installed cache (which is keyed by bare name), so it falls back to a direct brew info --json <name> call. That's the existing behaviour for names not found in the cache.

The README documents the new form.

Testing

  • go test ./...
  • golangci-lint run ./... (v2.6.2, matching CI): 0 issues
  • New test cases cover valid tap-qualified names and rejected ones (cask taps, malformed segments, length limits).

🤖 Generated with Claude Code

Copilot AI balanced review requested due to automatic review settings November 12, 2026 02:38

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Note

Copilot was unable to complete this review at the selected tier due to model policy or plan restrictions.

🟡 Changes recommended

A moderate active issue remains in main.go where the cask-tap rejection logic uses an overly broad "homebrew/cask" prefix match that could incorrectly reject non-official tap-qualified formulae, so the matching needs tightening to the intended official cask tap patterns.

1 open issue
What changed in this PR

Adds support for tap-qualified Homebrew formula arguments (e.g. homebrew/core/foo) to allow disambiguation across taps while keeping casks from official homebrew/cask* taps unsupported.

Changes:

  • Expand formula argument validation to accept an optional user/repo/ tap prefix with segment constraints.
  • Preserve existing behavior by rejecting tap-qualified names from official homebrew/cask* taps.
  • Update documentation and extend tests to cover accepted and rejected tap-qualified inputs.
File Description
README.md Documents the newly supported tap-qualified formula argument syntax and clarifies that casks remain unsupported.
main.go Updates formula argument validation to allow an optional tap prefix and adds explicit rejection logic for homebrew/cask* tap-qualified inputs.
main_test.go Adds and refines test cases for valid tap-qualified formula names and rejected cases including malformed prefixes and cask taps.

Review effort: Balanced

Comment thread main.go Resolved
Copilot AI balanced review requested due to automatic review settings November 12, 2026 03:20

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Note

Copilot was unable to complete this review at the selected tier due to model policy or plan restrictions.

🟢 Approval recommended

The review evidence indicates the change is narrowly scoped to formula argument validation with documented behavior and accompanying unit tests for both accepted tap-qualified names and explicit rejections/edge cases, leaving no unresolved issues.

No open issues 🎉

1 resolved since last review

Review effort: Balanced

@grahamgilbert grahamgilbert left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Please fix the test coverage though

korylprince and others added 2 commits November 12, 2026 15:06
Formula arguments were limited to bare names, so there was no way to
target a specific tap when more than one tap provides a formula with
the same name (e.g. homebrew/core/foo vs someuser/sometap/foo).

Accept an optional user/repo/ prefix in formula arguments. Casks from
the official homebrew/cask* taps are still rejected.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The cask check matched any tap whose repo started with "cask", which
also rejected unrelated taps such as homebrew/caskify. Match only
homebrew/cask and homebrew/cask-* instead.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@korylprince
korylprince force-pushed the allow-tap-qualified-formula branch from a47e52f to e571ca5 Compare November 12, 2026 21:06
Copilot AI balanced review requested due to automatic review settings November 12, 2026 21:06
@korylprince
korylprince merged commit a31d519 into macadmins:main Nov 12, 2026
3 checks passed
@korylprince korylprince mentioned this pull request Nov 12, 2026

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Note

Copilot was unable to complete this review at the selected tier due to model policy or plan restrictions.

🟡 Changes recommended

A critical validation flaw in main.go allows option-like inputs (e.g., "--help") to pass as a formula name and be forwarded to brew, creating a surprising argument-injection vector that must be fixed before approval.

1 open issue

Review effort: Balanced

Comment thread main.go
Comment on lines +19 to +21
var formulaRe = regexp.MustCompile( //nolint:gochecknoglobals
`^([A-Za-z0-9][A-Za-z0-9_-]{0,63}/[A-Za-z0-9][A-Za-z0-9_.-]{0,63}/)?[A-Za-z0-9+@._-]{1,128}$`,
)
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.

3 participants