73 Commits

Author SHA1 Message Date
Mike McQuaid
e9f55a8f71
tests: default to API mode enabled.
While we're here, also add `brew tests --no-parallel` which I relied
on during testing.

Pretty much anywhere we rely on a stubbed formula on disk to work: we
need to disable the API.
2025-06-10 15:53:27 +01:00
Mike McQuaid
084ddca27a
Cleanup and fix homebrew-services migration 2025-03-13 15:22:01 +00:00
Mike McQuaid
94416e82f0
Add new odeprecated, odisabled, remove disabled code.
Prepare the usual deprecation cycle for Homebrew 4.4.0.
2024-09-24 10:15:34 +01:00
apainintheneck
62a4734c90 tap: add tests for formula_file? and cask_file? 2024-08-27 00:36:23 -07:00
apainintheneck
cd430c4d34 cmd/update-report: improve formula file validation
Currently, ruby files that are not in the Cask directory are
considered to be formulae if a Formula or HomebrewFormula directory
doesn't exist  which doesn't make sense. We know that these should
only be in a few directories so we can check for that explicitly.

Beyond that the `Tap#cask_file?` and `Tap.formula_file?` methods
were only used inside update-report so it doesn't make sense to
turn them into pathnames and expand things when we know that
each string will be a relative path from a tap that we can just
check with a regex.

This change will stop other tap changes like new commands or
changes to other directories like lib/ from showing up as new formulae.

I tried opening a PR for this a long time ago but I got busy
with other things and it got closed by the stale bot.

- https://github.com/Homebrew/brew/pull/15489
2024-08-25 18:32:04 -07:00
apainintheneck
a3e917afe1 Refactor method to remove extra tap requires
We were selectively requiring the tap.rb file in a few places for
performance reasons. The main method we were referencing was the
`Tap.cmd_directories` method which uses `Pathname` and the `TAP_DIRECTORY`
constant internally. `Tap.cmd_directories` is mostly used in the `Commands`
module and that is loaded very early on in the program so it made sense
to move that command to that module. To facilitate that I moved the
`TAP_DIRECTORY` constant to the top-level and renamed it to
`HOMEBREW_TAP_DIRECTORY`. It now lies in the tap_constants.rb file.

A nice bonus of this refactor is that it speeds up loading external
commands since the tap.rb file is no longer required by default in
those cases.
2024-08-10 13:49:10 -07: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
Carlo Cabrera
078a328e8e
tap: avoid class vars
Avoiding them also allows us to write proper tests.
2024-05-06 15:05:06 +01:00
Mike McQuaid
1474806527
Add more HOMEBREW_FORBIDDEN_* configuration
We already had `HOMEBREW_FORBIDDEN_LICENSES` but this commit adds
`HOMEBREW_FORBIDDEN_CASKS`, `HOMEBREW_FORBIDDEN_FORMULAE` and
`HOMEBREW_FORBIDDEN_TAPS` for also forbidding those.

Relatedly, add `HOMEBREW_FORBIDDEN_OWNER` and
`HOMEBREW_FORBIDDEN_OWNER_CONTACT` to allow customising these
messages.

There were no existing tests for `HOMEBREW_FORBIDDEN_LICENSES` so have
added more tests for all of these checks.

Co-authored-by: Bo Anderson <mail@boanderson.me>
2024-04-08 16:38:32 +01:00
Douglas Eichelberger
fde7d380f7 Don't include FileUtils everywhere 2024-03-30 19:10:56 -07:00
apainintheneck
74aea8e92d spec_helper: add :no_api test scope
This sets the HOMEBREW_NO_INSTALL_FROM_API environment variable
to prevent the selected tests from using the API. We will need
this as we transition to having the API be enabled by default
when running the tests but it's also nice as a sanity check
with the :needs_utils_curl scope in a few places.
2024-03-19 22:18:02 -07:00
apainintheneck
ad35db4b24 tests: fix tests that make unexpected network calls
These were found with the Utils::Curl check and just turning
off the network on my computer and running the entire test suite.
2024-03-18 20:57:35 -07:00
Douglas Eichelberger
820d320835 Remove and refactor rspec-its use 2024-03-17 22:47:37 -07:00
Mike McQuaid
b1990ed4b6
Merge pull request #16863 from apainintheneck/memoize-installed-tap-loading-v2
Memoize installed tap loading v2
2024-03-12 08:36:09 +00:00
apainintheneck
08442734ab s/Tap.reverse_tap_migrations_renames/Tap.tap_migration_oldnames/ 2024-03-09 10:27:22 -08:00
apainintheneck
e6a453a20d tap: add some tests
- Add tests for:
  - `Tap.each`
  - `Tap.installed`
  - `Tap.all`
  - `Tap#reverse_tap_migrations_renames`
  - `Tap.reverse_tap_migrations_renames`
2024-03-09 10:27:22 -08:00
Mike McQuaid
9ac31827a0
Various brew update behaviour improvements
- Output a message every time auto-update is run rather than a 3 second
  timer. This makes it more obvious that Homebrew isn't just sitting
  doing nothing for 2.9 seconds.
- Output a message when running `brew update` so Homebrew doesn't just
  sit there silently doing nothing.
- Update all taps when `brew update` is run, not just those hosted on
  GitHub. This makes it more obvious that people don't need to explictly
  run `brew update` "just in case".
- As a result of this, remove `brew tap --force-auto-update` as it's no
  longer necessary.
2024-03-08 16:21:09 +00:00
Markus Reiter
be9c0b8787
Simplify TapConfig. 2024-03-07 15:31:37 +01:00
Mike McQuaid
026ca68c5c
Merge pull request #16834 from reitermarkus/tap-new-private
Make `Tap::new` private.
2024-03-06 15:33:25 +00:00
Markus Reiter
e3a102efd4
Make Tap::new private. 2024-03-06 15:10:14 +01:00
Markus Reiter
a851bb86ef
Add type signature for Tap::fetch. 2024-03-06 14:30:17 +01:00
Markus Reiter
e369689794
Add test for Tap#custom_remote?. 2024-03-04 15:32:27 +01:00
Markus Reiter
3da0f8c4a6
Fix loading casks/formulae from relative paths. 2024-03-01 04:05:15 +01:00
Markus Reiter
132a87aff5
Rename Tap#repo_var to Tap#repo_var_suffix. 2024-02-23 16:02:29 +01:00
Markus Reiter
ed07203f9e
Fix tap constants. 2024-02-22 22:03:54 +01:00
Douglas Eichelberger
26eda5a303
git grep -l '^describe' | xargs gsed -i 's|^describe|RSpec.describe|g' 2024-02-19 13:57:27 +00:00
Douglas Eichelberger
9075cbae62 brew style --fix 2023-04-21 09:58:50 -07:00
Douglas Eichelberger
ac1e6ded9a git grep -l '# typed: false' | xargs gsed -i 's|# typed: false||g' 2023-04-21 09:57:47 -07:00
Issy Long
3a83b5492c
rubocop: Clean up Style/BlockDelimiters excludes and autofix offenses
- The defaults of using "do ... end" for multi-line blocks everywhere is
  good, better than switching everything to braces everywhere.
2023-03-08 23:54:22 +00:00
Mike McQuaid
f280ce069b
Support loading formulae/casks from subdirectories
Previously, we required all formulae and casks to be in a specific
formula or cask directory but did not check any subdirectories.

This commit allows using subdirectories for official taps, the only
ones likely to be big enough to warrant sharding in this way and to
avoid potentially breaking backwards compatibility for existing taps.

This was inspired by the most recent issues with homebrew-cask.
2023-02-24 10:57:41 +00:00
Mike McQuaid
53c57d7a70
tap: return the default_remote if not installed.
Fixes #14656.
2023-02-16 12:25:28 +00:00
Mike McQuaid
59f4b5226a
tests: test on Ubuntu 18.04. 2022-11-09 14:45:43 +00:00
Mike McQuaid
7349c2b996
brew style --fix 2022-09-13 09:43:09 +01:00
xxyzz
2e899da7c7
Add --no-force-auto-update option to brew tap
Enable this option to delete `homebrew.forceautoupdate` git config option
2022-05-11 07:17:17 +08:00
Issy Long
6b76fd012a
Fix (auto-correct) RuboCop RSpec/BeNil offenses 2022-03-01 00:10:10 +00:00
XuehaiPan
63f2f6cca7 tap: allow to change tap remote with brew tap --custom-remote 2021-10-12 01:11:34 +08:00
Bo Anderson
f174d4363f
extend/pathname: limit write override to a refinement 2021-05-04 14:20:20 +01:00
Zach Auten
95c8f445fa Fix bump-formula-pr for taps with ssh remote url. 2021-04-22 22:02:09 -04:00
Rylan Polster
4e61f61a20
utils/github: handle non-standard tap remotes 2021-03-21 12:35:45 -04:00
Mike McQuaid
dc1fdc9f8d
Speedup brew --version.
Port `brew --version` to Bash to speed it up.

While we're here:
- remove (now) unused `Tap` Git methods
- use `--quiet` instead of `-q` to be more verbose

Benchmarks:
```
$ hyperfine --min-runs=3 --warmup=2 "git checkout origin/master; brew --version" "git checkout speedup_brew_version; brew --version"
Benchmark #1: git checkout origin/master; brew --version
  Time (mean ± σ):      2.083 s ±  0.004 s    [User: 396.8 ms, System: 597.2 ms]
  Range (min … max):    2.080 s …  2.088 s    3 runs

Benchmark #2: git checkout speedup_brew_version; brew --version
  Time (mean ± σ):     847.9 ms ±  35.2 ms    [User: 100.0 ms, System: 247.9 ms]
  Range (min … max):   824.1 ms … 888.3 ms    3 runs

Summary
  'git checkout speedup_brew_version; brew --version' ran
    2.46 ± 0.10 times faster than 'git checkout origin/master; brew --version'
```
2021-03-04 12:59:42 +00:00
nandahkrishna
f7c8810214
utils/github/api: remove 'api' from method names 2021-02-17 23:47:05 +05:30
nandahkrishna
56e0c3d9e8
Update GitHub API usage 2021-02-15 22:38:27 +05:30
Rylan Polster
d5d7b6c3db
style: remove RSpec/MultipleDescribes violations
Co-authored-by: Nanda H Krishna <nanda.harishankar@gmail.com>
2021-02-01 20:30:51 -05:00
Rylan Polster
af40e072b0
style: remove RSpec/NamedSubject violations 2021-02-01 20:30:51 -05:00
EricFromCanada
6fc116318e fixes for grammar and wording 2021-01-26 16:19:47 -05:00
Rylan Polster
f1f3fdc315 settings: add module for managing git config settings 2021-01-12 16:27:25 -05:00
Rylan Polster
e7b369273a completions: link official taps automatically 2021-01-11 12:27:57 -05:00
Rylan Polster
e9d09c4d8f tests: add and fix tests 2021-01-08 17:11:20 -05:00
Rylan Polster
8d5dc76284 Satisfy brew typecheck 2020-11-30 20:32:46 -05:00
Rylan Polster
f8ff0f465f tap: add tests for formula list methods 2020-11-30 18:18:50 -05:00