15 Commits

Author SHA1 Message Date
Markus Reiter
969005a505
Prevent race condition when deleting lock files. 2024-11-24 01:29:42 +01:00
Markus Reiter
4bd75d4235
Fix incorrect download locking. 2024-11-24 00:03:31 +01:00
Issy Long
45978435e7
rubocop: Use Sorbet/StrictSigil as it's better than comments
- Previously I thought that comments were fine to discourage people from
  wasting their time trying to bump things that used `undef` that Sorbet
  didn't support. But RuboCop is better at this since it'll complain if
  the comments are unnecessary.

- Suggested in https://github.com/Homebrew/brew/pull/18018#issuecomment-2283369501.

- I've gone for a mixture of `rubocop:disable` for the files that can't
  be `typed: strict` (use of undef, required before everything else, etc)
  and `rubocop:todo` for everything else that should be tried to make
  strictly typed. There's no functional difference between the two as
  `rubocop:todo` is `rubocop:disable` with a different name.

- And I entirely disabled the cop for the docs/ directory since
  `typed: strict` isn't going to gain us anything for some Markdown
  linting config files.

- This means that now it's easier to track what needs to be done rather
  than relying on checklists of files in our big Sorbet issue:

```shell
$ git grep 'typed: true # rubocop:todo Sorbet/StrictSigil' | wc -l
    268
```

- And this is confirmed working for new files:

```shell
$ git status
On branch use-rubocop-for-sorbet-strict-sigils
Untracked files:
  (use "git add <file>..." to include in what will be committed)
        Library/Homebrew/bad.rb
        Library/Homebrew/good.rb

nothing added to commit but untracked files present (use "git add" to track)

$ brew style
Offenses:

bad.rb:1:1: C: Sorbet/StrictSigil: Sorbet sigil should be at least strict got true.
^^^^^^^^^^^^^

1340 files inspected, 1 offense detected
```
2024-08-12 15:24:27 +01:00
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
Markus Reiter
0f0055ede4
Make documentation @api private by default. 2024-04-26 19:04:20 +02:00
Steve Peters
116fd5928c lock_file: better message if too many open files
Recommend using `ulimit -n` to increase maximum
number of open files.
2023-03-06 17:17:48 -08:00
Seeker
b9854bd4cf rubocops: add unless_multiple_conditions 2021-01-08 10:33:54 -08:00
Markus Reiter
24ae318a3d Move type annotations into files. 2020-10-10 14:59:39 +02:00
Markus Reiter
b7e96e6096 Document LockFile. 2020-08-26 03:13:58 +02:00
Mike McQuaid
36dbad3922
Add frozen_string_literal to all files. 2019-04-20 13:27:36 +09:00
Markus Reiter
e9b9ea49a1 Update to RuboCop 0.59.1. 2018-09-17 03:45:59 +02:00
Mike McQuaid
7615d3a812
Improve writable directory handling
Consolidate the handling of which directories need to exist and which
need to be writable. Additionally, add a fatal check for formula
installations to ensure that any directories that need to be writable
are so before attempting an installation.

Fixes #4626.
2018-09-06 18:38:43 +01:00
Markus Reiter
bfd76a06ca Add per-cask/formula lockfile cleanup. 2018-08-09 16:46:39 +02:00
Markus Reiter
fd97e88b99 Use LockFile instead of Hbc::Utils::file_locked?. 2017-05-25 06:18:52 +02:00
Markus Reiter
060af0a26a Rename FormulaLock to LockFile. 2017-05-25 06:18:52 +02:00