37 Commits

Author SHA1 Message Date
Mike McQuaid
e3a1a9dccf
Improve locking UX
My experience recently playing around with our locking behaviour is
that, while mostly seamless and not seen by users, it's leaks
implementation details a bit too heavily.

As a result, the following improvements are in this commit:
- Ensure that, whenever possible, we tell the user the actual command
  that is holding a given lock instead of the lock name (an internal
  implementation detail)
- Make the locking error output a little more consistent and user
  friendly
- Add a `DownloadLock` class to simplify locking downloads
- Add a `HOMEBREW_LOCK_CONTEXT` variable to allow adding additional
  context for logging error messages
- Lock paths and leave deciding how this translates to lock names up
  to the locking code itself
- Lock the Cellar/Caskroom paths explicitly rather than implicitly

Co-authored-by: Carlo Cabrera <30379873+carlocab@users.noreply.github.com>
2024-07-30 17:51:02 +01:00
Douglas Eichelberger
820d320835 Remove and refactor rspec-its use 2024-03-17 22:47:37 -07:00
Mike McQuaid
ea2892f8ee
brew.rb: handle missing args. 2024-03-07 16:20:20 +00:00
Douglas Eichelberger
26eda5a303
git grep -l '^describe' | xargs gsed -i 's|^describe|RSpec.describe|g' 2024-02-19 13:57:27 +00:00
Sam Ford
578c935bcf
Formula, BuildError: Update type signatures
We're seeing type errors when building formulae that use something
like `xcodebuild ..., "-arch", Hardware::CPU.arch`, since `CPU.arch`
is a symbol. We've been addressing these issues by calling `#to_s` on
the value but there was some talk about simply expanding the type
signatures to accommodate anything that will be cast to a `String`.

There's maybe still an argument to be made for doing string conversion
in formulae but expanding the type signatures will resolve a number of
existing type errors if we simply want to rely on implicit type
casting.

Past that, this also updates the type signature for `BuildError` to
align with the `#system` signature changes, as we receive a type error
otherwise.
2023-09-13 19:16:04 -04:00
Eric Knibbe
b3ecd91f97
dev-cmd/edit: suggest tapping core repositories 2023-08-01 13:39:28 -04:00
Issy Long
935649abaf
Merge pull request #15263 from Homebrew/dependabot/bundler/Library/Homebrew/rubocop-rspec-2.20.0
build(deps): bump rubocop-rspec from 2.19.0 to 2.20.0 in /Library/Homebrew
2023-04-22 18:58:03 +01:00
Issy Long
4a87c624d7
Fix new RSpec/IndexedLet offenses 2023-04-22 01:02:38 +01: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
Issy Long
4a8384e8a8
rubocop: In-line disables of Lint/ConstantDefinitionInBlock 2023-02-19 16:33:22 +00:00
Douglas Eichelberger
259e4ae718 Enable RSpec/LeakyConstantDeclaration 2023-01-26 09:24:38 -08:00
Mike McQuaid
a7503ec713
Revert "Enable RSpec/LeakyConstantDeclaration" 2023-01-26 09:47:20 +00:00
Douglas Eichelberger
71e8135864 Enable RSpec/LeakyConstantDeclaration 2023-01-24 20:07:22 -08:00
Douglas Eichelberger
eeac95b98a Resolve exceptions_spec violation 2023-01-22 17:26:44 -08:00
Issy Long
6b76fd012a
Fix (auto-correct) RuboCop RSpec/BeNil offenses 2022-03-01 00:10:10 +00:00
nandahkrishna
e64f2d1fd4
test/exceptions_spec: add test for TapFormulaOrCaskUnavailableError 2021-03-12 01:28:20 +05:30
Bo Anderson
f079373d8c
utils/fork: handle termsig in safe_fork 2021-02-25 13:42:44 +00:00
Issy Long
e1ad07190e
rubocop: Fix RSpec/ContextWording offenses
- For some of these I changed `context` to `describe` as it fit better
  rather than contriving a "when", "with" or "without", or massively
  restructuring the tests.
2021-02-19 23:30:41 +00:00
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
Markus Reiter
7d9758a05e Fix RuboCop offenses. 2020-11-30 22:50:15 +01:00
Markus Reiter
da9289eff0 Add more type signatures. 2020-11-13 12:26:36 +01:00
Markus Reiter
24ae318a3d Move type annotations into files. 2020-10-10 14:59:39 +02:00
Misty De Meo
c06848c487
Fix printing MultipleVersionsInstalledError details
The refactor in 6e8f5d0958247e4b4d629866099ed2836a0e0863 means that the
exception no longer exposes the name of the package with multiple versions,
and as a result the rescuer is unable to print this information.

Because we now have a path in which MultipleVersionsInstalledError doesn't
have the name at all, we can't reasonably restore the old behaviour.
And since rack resolution happens purely internal to the function that
raises the exception, the caller has no way to know what name to use.
However, since the exception text gets printed anyway, we can just move
this text into the exception itself.

Fixes the following error:

```
Error: mpd has multiple installed versions
Error: undefined method `name' for #<MultipleVersionsInstalledError:0x00007fc6009d8870>
/usr/local/Homebrew/Library/Homebrew/cmd/uninstall.rb:137:in `rescue in uninstall'
/usr/local/Homebrew/Library/Homebrew/cmd/uninstall.rb:135:in `uninstall'
/usr/local/Homebrew/Library/Homebrew/brew.rb:119:in `<main>'
```
2020-09-09 11:56:53 -07:00
Mike McQuaid
fb0a6338b1
Remove more tap pinning code.
This was deprecated and removed a while ago.
2020-08-06 12:24:10 +01:00
William Ma
6e8f5d0958 Modify MultipleVersionsInstalledError to have a generic message 2020-07-03 18:25:49 -04:00
Jacob Middag
c6cb20a768
Fix frozen string bug 2019-10-11 09:34:43 +02:00
Mike McQuaid
36dbad3922
Add frozen_string_literal to all files. 2019-04-20 13:27:36 +09:00
Mike McQuaid
359fb27cfe
Manually fix RuboCop RSpec autofix failures. 2018-09-20 13:40:38 +01:00
Mike McQuaid
78eba5b815
Autofix RuboCop RSpec failures 2018-09-20 13:36:42 +01:00
Reto Kromer
d630f0885b more secure protocols 2018-08-06 16:23:07 +02:00
Markus Reiter
2452b27866 Refactor ErrorDuringExecution. 2018-07-19 16:41:27 +02:00
Mike McQuaid
5e1806e796 test: rubocop-rspec style auto-corrects.
There’s too many warnings to start enabling `rubocop-rspec` by default
but let’s at least apply the cleanups it does automatically.
2018-03-25 13:30:37 +01:00
Shaun Jackman
3ed832d4f0 BottleLoader: Use the formula stored in the bottle 2017-09-28 12:29:23 -07:00
Markus Reiter
279831fc0e Convert Exceptions test to spec. 2017-02-15 15:53:27 +01:00