3353 Commits

Author SHA1 Message Date
Kevin
c44e053847
Merge pull request #17242 from Homebrew/fix-cask-source-file-path-loading-issues
Fix cask source file path loading issues
2024-05-08 18:28:04 -07:00
Jason Karns
1f1a8b6c11
Add Brewfile documentation to tap-new readme template
It would be helpful for taps to document how they are to be used with `Brewfile`.

Adding documentation for formulae installation to the generated tap readme would help ensure that new taps have this helpful documentation in their repos from the start.
2024-05-08 14:20:51 -04:00
Sean Molenaar
a43b7464c2 feat: add generated SPDX file on bottling 2024-05-07 20:33:22 +02:00
Mike McQuaid
222fe8ef0b
Homebrew 4.3.0 deprecation/disable/removals.
The usual pass of deprecating/disabling/removing code for the next
minor Homebrew release.
2024-05-07 12:18:04 +01:00
apainintheneck
ffc503f1d0 Fix cask source file path loading issues
There are two big changes here. Both have to do with how we want
to load casks in different scenarios. One also is related to formulae.

1. Prevent loading casks & formulae outside of taps for specific commands.

There are certain commands like `bump`, `bump-*-pr`, `livecheck` and `audit`
where it really makes no sense to try and run things if the specified formulae
or cask is not in a tap. A new `#to_formulae_and_casks_with_taps` method was
added to the `CLI::NamedArgs` class to allow us to easily grab and validate
formulae and casks from named arguments.

2. Always load the source file path when loading casks with the path loader.

There was an edge case where all JSON cask files were being loaded without
setting the source file path because most of the work was handed off to the
API loader where that normally would make more sense. Now we set that when
calling the API loader which solves the problem. This improves the user
experience of people using the `--cache` and `fetch` commands in certain
edge cases. Hopefully it makes the user experience a bit more consistent.

A regression test was added for this point.
2024-05-06 23:34:23 -07:00
Eric Knibbe
3d985d082e
cmd/generate-cask-api: include cask renames 2024-05-03 19:16:32 -04:00
Mike McQuaid
b5b37d8c80
Merge pull request #17204 from Homebrew/ruby_scripts_to_utils_files
Library/Homebrew: move stdin ruby scripts to files under `utils`.
2024-05-02 10:44:00 +01:00
Mike McQuaid
bc0f5ee62a
Library/Homebrew: move stdin ruby scripts to files under utils.
This avoids can avoid UID/EUID related issues with Ruby scripts passed
over `stdin` clashing with Ruby security features.

It's also just a bit nicer to have Ruby scripts in files instead.

While we're here:
- refactor some shared logic into a new `setup-gem-home-bundle-gemfile`
  function in `ruby.sh`
- do some general cleanup of `lock.sh`
- prioritise `flock` over `python` in `lock.sh`
2024-05-02 10:33:42 +01:00
Markus Reiter
480e264d9a
Lint Ruby docs. 2024-05-01 11:35:21 +02:00
Markus Reiter
caf87c0336
Warn about undocumented non-private APIs. 2024-05-01 11:35:20 +02:00
Mike McQuaid
60657d382b
Merge pull request #17185 from Homebrew/install_bundler_gems_consistently
Call `Homebrew.install_bundler_gems!` more consistently.
2024-04-30 12:17:24 +01:00
Mike McQuaid
4ffcd8a110
Various improvements for brew command
- Add a (large) speedup by moving some logic to Bash for the typical
  case of a normal or dev-cmd, Bash or Ruby command.
- Make `brew command` a non-developer command, I don't think it makes
  sense to consider it something needed for developing Homebrew.
- Update the manpage/tests/RBI accordingly.

Co-authored-by: Carlo Cabrera <30379873+carlocab@users.noreply.github.com>
2024-04-30 11:38:19 +01:00
Mike McQuaid
aa6ea4be83
Call Homebrew.install_bundler_gems! more consistently.
- Call `Homebrew.install_bundler_gems!` as early as possible
- Always call `Homebrew.install_bundler_gems!` in `dev-cmd` rather than
  in `Library/Homebrew` helpers method (to ensure we don't accidentally
  call this for non-dev-cmd commands)
2024-04-30 10:39:35 +01:00
Mike McQuaid
65f3df92d2
install-bundler-gems: change_privilege when necessary.
This ensures that gems are able to be installed when using e.g.
`ruby -I` in their installation scripts.
2024-04-30 09:21:12 +01:00
Markus Reiter
0b56d0be4a
Document Tab.for_keg and use Keg#tab where possible. 2024-04-28 20:50:13 +02:00
Markus Reiter
0f0055ede4
Make documentation @api private by default. 2024-04-26 19:04:20 +02:00
Mike McQuaid
b5f857b627
Merge pull request #17081 from alebcay/formula-offline-phases
Support for opt-in network isolation in build/test sandboxes
2024-04-23 08:30:10 +01:00
Caleb Xu
934398dd9a
test: conditionally deny network access in sandbox 2024-04-22 22:39:45 -04:00
Douglas Eichelberger
7bfa552702 Individually namespace args for each command 2024-04-21 16:51:31 -07:00
Douglas Eichelberger
11720132bb cleanup 2024-04-21 14:34:55 -07:00
Douglas Eichelberger
cb71938fff Enable strict typing in CLI::Parser 2024-04-21 14:16:25 -07:00
Ruoyu Zhong
ea37708591
dev-cmd/tap-new: simplify 2024-04-19 23:14:35 +08:00
Ruoyu Zhong
82ad03fe28
dev-cmd/tap-new: various improvements
1. Update `actions/cache` to `v4`.
2. Unset GitHub Packages tokens if unused.
3. Quote shell variables.
2024-04-19 11:10:29 +08:00
Ruoyu Zhong
7e43853216
dev-cmd/tap-new: fix GitHub Packages user
It should be `github.repository_owner` rather than `github.actor`.
2024-04-19 11:09:58 +08:00
Ruoyu Zhong
adbe6edc84
dev-cmd/tap-new: use actions/upload-artifact@v4 2024-04-19 11:09:56 +08:00
Ruoyu Zhong
54a5690391
dev-cmd/tap-new: throw an error when tap is installed 2024-04-19 11:02:25 +08:00
Issy Long
4c64193b9b
Set HOMEBREW_DEBUG when running brew tests --debug
- This will cause the "debug" gem to be required in `spec_helper.rb`, so we can do interactive debugging.
2024-04-17 23:26:40 +01:00
Issy Long
073e739005
Use the debug gem from portable Ruby
- This is cleaner than vendoring a whole bunch of new gems and pinning `psych`.
- Thanks for the pointer, Bo!
- It doesn't work, though?

```
❯ brew tests --only=migrator --debug
Error: cannot load such file -- debug/debug.so
Warning: Removed Sorbet lines from backtrace!
Rerun with `--verbose` to see the original backtrace
/opt/homebrew/Library/Homebrew/vendor/portable-ruby/3.1.4/lib/ruby/gems/3.1.0/gems/debug-1.6.3/lib/debug/frame_info.rb:16:in `require'
/opt/homebrew/Library/Homebrew/vendor/portable-ruby/3.1.4/lib/ruby/gems/3.1.0/gems/debug-1.6.3/lib/debug/frame_info.rb:16:in `rescue in <module:DEBUGGER__>'
/opt/homebrew/Library/Homebrew/vendor/portable-ruby/3.1.4/lib/ruby/gems/3.1.0/gems/debug-1.6.3/lib/debug/frame_info.rb:13:in `<module:DEBUGGER__>'
/opt/homebrew/Library/Homebrew/vendor/portable-ruby/3.1.4/lib/ruby/gems/3.1.0/gems/debug-1.6.3/lib/debug/frame_info.rb:3:in `<top (required)>'
/opt/homebrew/Library/Homebrew/vendor/portable-ruby/3.1.4/lib/ruby/gems/3.1.0/gems/debug-1.6.3/lib/debug/session.rb:31:in `require_relative'
/opt/homebrew/Library/Homebrew/vendor/portable-ruby/3.1.4/lib/ruby/gems/3.1.0/gems/debug-1.6.3/lib/debug/session.rb:31:in `<top (required)>'
/opt/homebrew/Library/Homebrew/vendor/portable-ruby/3.1.4/lib/ruby/gems/3.1.0/gems/debug-1.6.3/lib/debug.rb:3:in `require_relative'
/opt/homebrew/Library/Homebrew/vendor/portable-ruby/3.1.4/lib/ruby/gems/3.1.0/gems/debug-1.6.3/lib/debug.rb:3:in `<top (required)>'
/opt/homebrew/Library/Homebrew/dev-cmd/tests.rb:48:in `require'
/opt/homebrew/Library/Homebrew/dev-cmd/tests.rb:48:in `run'
/opt/homebrew/Library/Homebrew/brew.rb:89:in `<main>'
```
2024-04-17 23:26:40 +01:00
Issy Long
621e51a6c9
Don't require "debug" in brew tests - it's in our RSpec config 2024-04-17 22:25:12 +01:00
Issy Long
1daeb5bee0
Set up the debug gem for test debugging
- This processed that we'd requested a debugger, but didn't drop us into
  a debugging console until I
  [stopped the stdin disablement](https://github.com/Homebrew/brew/issues/16708#issuecomment-1953483970).

Usage:

```
❯ git diff
diff --git a/Library/Homebrew/test/migrator_spec.rb b/Library/Homebrew/test/migrator_spec.rb
index 87fadd5e95..db4700810a 100644
--- a/Library/Homebrew/test/migrator_spec.rb
+++ b/Library/Homebrew/test/migrator_spec.rb
@@ -69,6 +69,8 @@ RSpec.describe Migrator do
       tab.source["tap"] = "homebrew/core"
       tab.write

+      binding.break
+
       expect do
         described_class.new(new_formula, "oldname")
       end.to raise_error(Migrator::MigratorDifferentTapsError)

issyl0 at pictor in /opt/homebrew on bye-byebug
❯ brew tests --only=migrator --debug
Randomized with seed 59158
1 process for 1 spec, ~ 1 spec per process
.==> Relinking newname
.==> Unlinking oldname
...==> Moving oldname versions to /private/tmp/homebrew-tests-20240403-85464-3uogqr/cellar/newname
....==> Migrating formula oldname to newname
==> Unlinking oldname
==> Moving oldname versions to /private/tmp/homebrew-tests-20240403-85464-3uogqr/cellar/newname
==> Relinking newname
....[67, 76] in ~/migrator_spec.rb
    67|       tab = Tab.empty
    68|       tab.tabfile = HOMEBREW_CELLAR/"oldname/0.1/INSTALL_RECEIPT.json"
    69|       tab.source["tap"] = "homebrew/core"
    70|       tab.write
    71|
=>  72|       binding.break
    73|
    74|       expect do
    75|         described_class.new(new_formula, "oldname")
    76|       end.to raise_error(Migrator::MigratorDifferentTapsError)
=>#0    block in <top (required)> (3 levels) at ~/migrator_spec.rb:72
  #1    [C] BasicObject#instance_exec at /opt/homebrew/Library/Homebrew/vendor/bundle/ruby/3.1.0/gems/rspec-core-3.13.0/lib/rspec/core/example.rb:263
  # and 68 frames (use `bt' command for all frames)
(rdbg@/opt/homebrew/Library/Homebrew/vendor/bundle/ruby/3.1.0/bin/rspec#85464) p tab
(rdbg@/opt/homebrew/Library/Homebrew/vendor/bundle/ruby/3.1.0/bin/rspec#85464) p    # command(rdbg@/opt/homebrew/Library/Homebrew/vendor/bundle/ruby/3.1.0/bin/rspec#85464) p     # command t    # command ta    # command tab    # command(rdbg@/opt/homebrew/Library/Homebrew/vendor/bundle/ruby/3.1.0/bin/rspec#85464) p tab    # command
=> #<Tab:0x0000000107156be0 @aliases=[], @arch=nil, @built_as_bottle=false, @built_on={"os"=>"Macintosh", "os_version"=>"macOS 14", "cpu_family"=>"arm_firestorm_icestorm"}, @compiler=:clang, @homebrew_version="4.2.16-55-gc8f60ec-dirty", @installed_as_dependency=false, @installed_on_request=false, @loaded_from_api=false, @poured_from_bottle=false, @runtime_dependencies=nil, @source={"path"=>nil, "tap"=>"homebrew/core", "tap_git_head"=>nil, "spec"=>"stable", "versions"=>{"stable"=>nil, "head"=>nil, "version_scheme"=>0}}, @source_modified_time=0, @stdlib=nil, @tabfile=#<Pathname:/private/tmp/homebrew-tests-20240403-85464-3uogqr/cellar/oldname/0.1/INSTALL_RECEIPT.json>, @time=nil, @unused_options=[], @used_options=[]>
(rdbg@/opt/homebrew/Library/Homebrew/vendor/bundle/ruby/3.1.0/bin/rspec#85464)
```
2024-04-17 22:25:12 +01:00
Issy Long
11c1960729
Remove byebug since it doesn't work in tests anymore
- Byebug was introduced in [2020](https://github.com/Homebrew/brew/pull/7577) for hooking into tests for debugging.
- It does not work anymore in so far as it does not stop at breakpoints when following the instructions to trigger them in tests.
2024-04-17 22:24:21 +01:00
Ruoyu Zhong
4cf42f7c18
pr-pull: simplify 2024-04-17 07:37:02 +08:00
Ruoyu Zhong
dd92ad8e1b
Update default artifact pattern to avoid migration problems 2024-04-17 06:15:14 +08:00
Ruoyu Zhong
1a1a466e9d
pr-pull: support globbing artifacts
Artifact actions v3 is deprecated and will soon be unavailable [^1].
This adds support for v4 by allowing `brew pr-pull` to accept a glob
pattern for artifact names, like actions/download-artifact does [^2].

[^1]: https://github.blog/changelog/2024-04-16-deprecation-notice-v3-of-the-artifact-actions/
[^2]: https://github.com/actions/download-artifact/tree/v4/#usage
2024-04-17 03:36:43 +08:00
Mike McQuaid
c4f2f06675
dev-cmd/tests: fix when euid != uid.
Otherwise you get:
`ruby: no -r allowed while running setuid (SecurityError)`
2024-04-11 17:26:38 +01:00
Bo Anderson
073e35d4ba
dev-cmd/generate-*-api: ensure title is a string 2024-04-10 04:51:23 +01:00
Douglas Eichelberger
c404dd9a05 Update tapioca config 2024-04-08 11:58:34 -07:00
Mike McQuaid
27f47bafbc
dev-cmd/bump-cask-pr: use FromContentLoader when relevant.
When loading from `tmp_contents` in `bump-cask-pr` we're always loading
from the contents and not from a e.g. filename etc. As a result, skip
the detection of the correct loader (as the regex can be a bit flaky)
and instead use `FromContentLoader` directly.
2024-04-08 13:25:59 +01:00
Douglas Eichelberger
351f14f9f4 Add IRB H = Homebrew alias 2024-04-04 19:15:59 -07:00
Mike McQuaid
a1e24eeb5e
Merge pull request #17023 from Homebrew/bump_skip_repology
dev-cmd/bump: unconditionally skip Repology queries for now.
2024-04-04 09:55:29 +01:00
Mike McQuaid
acb7f45cfd
dev-cmd/bump: unconditionally skip Repology queries for now.
We've been blocked by Repology so let's stop querying them for now.

Fixes #17021.
2024-04-04 09:43:44 +01:00
Bo Anderson
27ca946c06
dev-cmd/typecheck: use EUID with sorbet 2024-04-04 08:47:32 +01:00
Douglas Eichelberger
6d716a7d69 Missed one 2024-04-01 12:09:20 -07:00
Mike McQuaid
df2c914b42
Merge pull request #16989 from cho-m/livecheck-throttle-audit-updates
formula_auditor: check livecheck throttle
2024-04-01 13:55:50 +01:00
Michael Cho
4b65052b22
dev-cmd/bump-formula-pr: deprecate throttled_formulae.json
Signed-off-by: Michael Cho <michael@michaelcho.dev>
2024-04-01 00:54:36 -04:00
Sam Ford
a4134125f2
livecheck: Clarify --extract-plist behavior
From the description of the `--extract-plist` option, it would seem
that the `ExtractPlist` strategy is only enabled when the option is
used. Instead, livecheck automatically enables the strategy if the
command is run on only one cask. This rewords descriptions of the
option to clarify the behavior.
2024-03-31 21:01:40 -04:00
Mike McQuaid
21dd3c263f
Merge pull request #16975 from Homebrew/ported-cmds
Begin porting non-dev commands to use AbstractCommand
2024-03-31 19:28:30 +01:00
Douglas Eichelberger
65f8420232 Make things private 2024-03-30 16:43:11 -07:00
Issy Long
9dfe11870e
Convert the EnvConfig RBI generator to a Tapioca compiler 2024-03-30 18:30:20 +00:00
Issy Long
a3932b44c0
Merge pull request #16899 from Homebrew/tapioca-compiler-for-tty-rbi
Convert the `utils/tty` RBI generator to a Tapioca compiler
2024-03-30 18:10:41 +00:00