35598 Commits

Author SHA1 Message Date
Sam Ford
473f448b22
OnSystem: handle non-macOS current_os values
The `OnSystem.os_condition_met?` method only handles Linux and macOS
values for the current OS, so this fails when testing with a generic
OS. This shortcoming is only being surfaced now because there weren't
any tests for `OnSystem` before.

This addresses the issue by accounting for macOS values (`:macos` or
a symbol from `MacOSVersion::SYMBOLS`) and returning `false` for any
other values (`:linux`, `:generic`, etc.).
2025-06-08 10:13:40 -04:00
Sam Ford
ccfc31bc18
MacOSRequirement: add more type signatures
This adds more type signatures to `MacOSRequirement` to move it closer
to `typed: strict`. There are a few areas that aren't quite clear to
me based on the code and existing tests, so I've done what I can at
the moment.
2025-06-08 10:13:40 -04:00
Sam Ford
8350b8a43a
MacOSRequirement: add #highest_allowed method
This adds a `#highest_allowed` method to `MacOSRequirement`, so we can
easily identify the highest supported macOS version that a requirement
allows, if any.

This can be used when producing a minimal set of supported macOS
versions that meet requirements in `UsesOnSystem.macos_requirements`.
One of the intended use cases for this is to identify which macOS
versions we could simulate to work with all variations of a cask that
uses macOS on_system blocks.
2025-06-08 10:13:40 -04:00
Sam Ford
01825acabd
UsesOnSystem: Collect macOS requirements
When determining macOS requirements for a cask, we may need to
reference requirements from related on_system blocks (e.g.,
`on_monterey :or_older`, `on_ventura`, `on_sonoma :or_newer`) when
`depends_on macos` isn't adequate.

Sometimes casks specify different `depends_on macos` values in macOS
on_system blocks but that value is only set when the cask is loaded
in an environment that satisfies the on_system block's requirements.
There are other casks that contain macOS on_system blocks and use
`depends_on macos` outside of the on_system blocks but it may only
use the macOS version of the lowest on_system block (e.g.,
`>= :monterey`), which isn't sufficient if the cask's values vary
based on macOS version.

To be able to simulate macOS versions that meet the requirements of
all the on_system blocks in a cask, we need to collect the macOS
requirements in a way that doesn't require OS simulation. This is also
something that's easy to do in on_system methods, so this adds a
`macos_requirements` array to `UsesOnSystem`, containing
`MacOSRequirement` objects created from the cask's macOS on_system
block conditions.
2025-06-08 00:57:22 -04:00
Sam Ford
3df8f70511
OnSystem: Add UsesOnSystem class
This adds a `UsesOnSystem` class to `OnSystem`, containing boolean
instance variables to indicate which types of on_system methods are
used in a formula or cask. This is intended as a replacement for
`@on_system_blocks_exist`, which doesn't allow us to determine what
kinds of on_system calls were used. This provides more granularity
but we can still use `@uses_on_system.present?` to determine whether
any on_system calls were used (and this doubles as a `nil` check in
`Formula`, as the `self.class` instance variable has to use a nilable
type).

The `UsesOnSystem` instance variables cover the current
`ARCH_OPTIONS` and `BASE_OS_OPTIONS`. At the moment, we mostly need
to tell whether there are macOS/Linux or Intel/ARM on_system calls,
so I've omitted instance variables for specific macOS version until
we have a need for them.

As a practical example, if you wanted to determine whether a cask
uses Linux on_system calls, you can call
`cask.uses_on_system.linux?`. The `linux` boolean will be `true` if
the cask has an `on_linux` block, an `on_system` block (which requires
Linux), or uses `os linux: ...`. This is something that would be
challenging to determine from outside of `OnSystem` but it's
relatively easy to collect the information in `OnSystem` methods and
make it available like this.
2025-06-07 17:58:12 -04:00
Sam Ford
bafa2ec126
OnSystem: add tests
`OnSystem` is exercised by other tests that include its modules but
this adds some baseline tests to ensure some of these methods work as
expected when tested in isolation. Between these added tests and
existing tests, we should have 100% coverage when run on Homebrew/brew
CI.
2025-06-06 15:09:35 -04:00
Sam Ford
2d603b0c26
OnSystem: enable strict typing 2025-06-06 15:09:35 -04:00
Rylan Polster
1f37a11b79
Merge pull request #20051 from Homebrew/internal-api-bare-minimum
Reduce the internal formula API to contain the bare minimum data
2025-06-06 16:45:40 +00:00
Mike McQuaid
fda164535e
Merge pull request #20059 from Homebrew/improve_caveats_completions
Improve completions (and elisp) output in caveats
2025-06-06 16:44:33 +00:00
Mike McQuaid
ff710f8191
Improve completions (and elisp) output in caveats
Instead of repeatedly outputting the same identical messages across
multiple packages and repeating them all for every package after they
were all installed: just output the identical messages in the final
caveats output instead.
2025-06-06 17:09:28 +01:00
Mike McQuaid
e7f667c198
cask_loader: improve error handling.
Handle weird edge cases where we try to read a cask from invalid paths.
2025-06-06 14:19:00 +01:00
Rylan Polster
73b64390b3
Use existing Utils::Bottles::Collector#specification_for method 2025-06-05 12:38:15 -04:00
Rylan Polster
e83dc1cb3c
Fallback to older bottle hashes when viable 2025-06-05 11:32:47 -04:00
Eric Knibbe
0c4672a323
Merge pull request #20055 from Homebrew/cop-cask-url-verified
rubocops/cask/url: put keyword parameters on a new line
2025-06-05 15:32:32 +00:00
Eric Knibbe
c75122c694
rubocops/cask/url: put keyword parameters on a new line 2025-06-05 10:53:34 -04:00
Mike McQuaid
5fe43ed3f2
brew (bundle|) sh: use user's configuration but override prompts.
This was more painful that I expected but will allow `brew bundle sh`
and `brew sh` to use the user's configuration but use our custom prompt
for Bash and ZSH.
2025-06-05 15:43:34 +01:00
Rylan Polster
e47bc2fb86
Use hashes of arrays instead 2025-06-05 03:15:44 -04:00
Rylan Polster
b44ec56267
Reduce the internal formula API to contain the bare minimum data 2025-06-05 02:08:29 -04:00
Rylan Polster
71c8174136
Add undocumented HOMEBREW_USE_INTERNAL_API switch 2025-06-04 16:29:43 -04:00
Rylan Polster
da624601bb
os/mac/pkgconfig/15: update expat version 2025-06-04 15:46:41 -04:00
Mike McQuaid
68ef29fb5c
Merge pull request #20045 from Homebrew/fix-sharded-api
Fix sharded API structure to match existing API
2025-06-04 07:58:26 +00:00
Mike McQuaid
e825ceea0a
Merge pull request #20041 from Homebrew/mcp_server
Add `brew mcp-server`: a MCP server for Homebrew.
2025-06-04 07:58:01 +00:00
Rylan Polster
fa45209f09
Fix sharded API structure to match existing API 2025-06-03 16:58:47 -04:00
Eric Knibbe
3dc9e88542
parser: show related env var in switch description 2025-06-03 13:57:42 -04:00
Rylan Polster
c03f70f1dc
Refactor OnSystem and SimulateSystem bottle tag handling 2025-06-03 11:57:17 -04:00
Mike McQuaid
76c4eb60ee
test/cmd: add more shell tests.
This should help ensure that these don't regress.
2025-06-03 15:24:19 +01:00
Mike McQuaid
f9471f9591
Add brew mcp-server: a MCP server for Homebrew.
Add a new `brew mcp-server` command for a Model Context Protocol (MCP)
server for Homebrew. This integrates with AI/LLM tools like Claude,
Claude Code and Cursor.

It currently supports the calls needed/used by the MCP Inspector and
Cursor (where I've tested it).

It provides as `tools` the subcommands output by `brew help` but should
be fairly straightforward to add more in future.

It is implemented in a slightly strange way (a standalone Ruby command
called from a shell command) as MCP servers need a faster startup time
than a normal Homebrew Ruby command allows and fail if they don't get
it.

There are a few Ruby libraries available but, given how relatively
simplistic the implementation is, it didn't feel worthwhile to use and
vendor them.
2025-06-03 15:22:33 +01:00
Rylan Polster
0f03757e8f
Shard JSON API by OS/Arch combination 2025-06-02 23:06:02 -04:00
Mike McQuaid
7c5affa824
brew.sh: move sudo reset timestamp.
Let's move this from `bin/brew` to make things like e.g. `brew --prefix`
or `brew shellenv` not reset the sudo timestamp.

This is still in a place that ensures that e.g. no untrusted formula or
tap code has been run yet so should have no security implications but
provide mild usability improvements.
2025-06-02 15:09:27 +01:00
Eric Knibbe
cd6777fc73
audits: quote and reword problem description text 2025-05-30 23:49:26 -04:00
Mike McQuaid
e71b1473b8
formula_creator: tweak variable name 2025-05-30 14:55:50 +01:00
Anatoli Babenia
87e57368d4 create: explain file header length logic 2025-05-30 11:12:36 +03:00
Anatoli Babenia
d860fa1fa8 create: fix archive check if HTML starts with spaces 2025-05-30 11:12:36 +03:00
Bevan Kay
6278ac1801
Merge branch 'master' into cabal 2025-05-29 22:44:20 +10:00
botantony
9425734b4f
autobump_constants: add :requires_manual_review reason
Signed-off-by: botantony <antonsm21@gmail.com>
2025-05-27 21:48:58 +02:00
Kristján Oddsson
972414cec7 add a T.must after fetching tap 2025-05-27 16:55:00 +00:00
Kristján Oddsson
7476f09672 format 2025-05-27 16:43:54 +00:00
Kristján Oddsson
0480411c6f
use conditional assignment operator
Co-authored-by: Bo Anderson <mail@boanderson.me>
2025-05-27 16:35:50 +00:00
Kristján Oddsson
24d9524bbd remove T.must to avoid full fetch 2025-05-27 16:01:35 +00:00
Kristján Oddsson
9e05995299 move git fetch before getting origin_branch_name 2025-05-27 14:54:57 +00:00
Mike McQuaid
2131d70265
workflows/pkg-installer: fix release upload.
- Get the release tag from the installer path.
- Remove unnecessary `gh` installation.
- Remove failing test that I can't fix.
2025-05-27 11:47:00 +01:00
Mike McQuaid
1035024b83
Revert "feat: allow env for write_jar_script" 2025-05-26 17:19:48 +01:00
Sean Molenaar
f420f0f63d
Merge pull request #19946 from Homebrew/SMillerDev-patch-1
feat: allow env for write_jar_script
2025-05-26 14:36:15 +00:00
Sean Molenaar
81ea767ea3
Update Library/Homebrew/extend/pathname.rb 2025-05-26 21:17:05 +09:00
Bevan Kay
d416755560
Merge pull request #20005 from gibfahn/bump_write_only
bump-pr: respect --write-only flag and skip git operations
2025-05-26 08:41:55 +00:00
Mike McQuaid
a2894caceb
Merge pull request #20004 from Homebrew/formula-creator-ruby-rework
formula_creator: Update Ruby template
2025-05-26 07:41:51 +00:00
Mike McQuaid
3f15e0eef0
dev-cmd/bump-formula-pr: fix style. 2025-05-26 08:40:14 +01:00
Daeho Ro
24cd62140d
feat: add _ to powershell completion filename 2025-05-25 00:15:26 +09:00
Gibson Fahnestock
97acfb94ce
bump-pr: respect --write-only flag and skip git operations
The flag used to work well, but at some point started to run more and
more git actions. We use this to update formula and casks in other
homebrew taps, and it works well except for this issue.
2025-05-24 13:14:00 +01:00
Patrick Linnane
5ee4e609ac
formula_creator: Update Ruby template
Signed-off-by: Patrick Linnane <patrick@linnane.io>
2025-05-23 20:58:02 -07:00