28144 Commits

Author SHA1 Message Date
apainintheneck
1bae81cba2 rubocops/service: add checks for custom service names
It now checks for two new edge cases.
1. Are the required methods defined in the block?
2. Is the `run` command defined if we're using methods other
   than `service_name` or `plist_name`?

It has also been updated to only get the list of method call nodes
once instead of doing it repeatedly for each cellar path check.
2023-05-13 14:53:01 -07:00
apainintheneck
1111706378 service: add custom service name DSL
The main thing is that this DSL allows us to provide an
interface that can be serialized to the JSON API.

Changes:
- Homebrew::Service
  - Adds `#service_name` and `#plist_name` methods
    - Each is now included in the `#serialize` method as well
  - Eval block on instantiation
    - Before we lazy evaluated this but the cost is not significant
      and it complicated the code a bunch. This only gets called
      during install, when evaluating caveats and in the `brew service`
      command. It skips this evaluation if the service block isn't there.
  - Add `#command?` helper to avoid `#command.blank?` and `#command.present?`
- Formula
  - `#service` now returns a service whenever it's called. This call is
    hidden behind a call to `#service?` most of the time anyway so this
    should be fine.
  - `#plist_name` and `#service_name` now call the methods of the same name
    on the service class. This should have already been in the service object
    to begin with and keeping these methods here helps preserve backwards
    compatibility with people who were overwriting these methods before.
- Caveats
  - Prefer `service#command?`
  - Add helpers for checking on service commands
    - This duplicates some of the work in `brew services`. Maybe we should
      merge that repo in at some point.
  - Check for installed service at `#plist_name` or `#service_name`. I think
    this should be used instead of `Keg#plist_installed?` which checked for any plist file.
    We should think about deprecating `#plist_installed?` in the future.
  - Stop using `ps aux | grep #{formula.plist_name}` to check for service files
    because it was inaccurate (it always returns true on my machine) because the grep
    process is started before the ps process.
  - Note: The behavior is the same as it was before. This means that caveats
    only show up for custom service files on install or if they're already installed.
    Otherwise it won't show up in `brew info`. This is because it has to check
    first if the service file has been installed.
- Utils::Service
  - Add utils for evaluating if a service is installed and running. This duplicates
    some of the work already found in `brew services`. We should seriously consider
    merging `brew services` with the main brew repo in the future since it's already
    tightly coupled to the code in the main repo.
- Formulary.load_formula_from_api
  - Be more explicit about which types can be deserialized into run params since
    it is now possible for run params to be nil.
- Update and add tests
2023-05-13 14:53:01 -07:00
Markus Reiter
4c3e8255cf
Compare Tag using standardized_arch. 2023-05-13 22:19:35 +02:00
Markus Reiter
023238a761
Simplify hash merge. 2023-05-13 22:18:17 +02:00
Markus Reiter
935c5efaf8
Use sudo for rmdir if necessary. 2023-05-13 06:46:59 +02:00
Markus Reiter
d7a0e260e8
Improve Cask::Utils.gain_permissions_remove for symlinks. 2023-05-13 03:54:48 +02:00
Markus Reiter
4e483c9a0e
Add test for Cask::Utils::gain_permissions_mkpath. 2023-05-13 03:42:00 +02:00
Markus Reiter
2c71d9dcd8
Use sudo for symlinks if necessary. 2023-05-13 03:42:00 +02:00
Markus Reiter
a1dd95d6ee
Merge pull request #15412 from JBYoshi/cask-upgrade/named-params
Fix typing on revert_upgrade().
2023-05-12 22:32:11 +02:00
JBYoshi
ad8ce82673
Fix typing on revert_upgrade().
Also adds several type signature checks to test for these errors.
2023-05-12 14:53:27 -05:00
Markus Reiter
a3231a03fa
Implement cask renames. 2023-05-12 21:17:30 +02:00
BrewTestBot
3852582d9f
Update RBI files for thor.
Autogenerated by the [vendor-gems](https://github.com/Homebrew/brew/blob/HEAD/.github/workflows/vendor-gems.yml) workflow.
2023-05-12 19:05:40 +00:00
BrewTestBot
3e588581de
brew vendor-gems: commit updates. 2023-05-12 19:00:59 +00:00
dependabot[bot]
aa47457378
Bump thor from 1.2.1 to 1.2.2 in /Library/Homebrew
Bumps [thor](https://github.com/rails/thor) from 1.2.1 to 1.2.2.
- [Release notes](https://github.com/rails/thor/releases)
- [Commits](https://github.com/rails/thor/compare/v1.2.1...v1.2.2)

---
updated-dependencies:
- dependency-name: thor
  dependency-type: indirect
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-05-12 18:57:36 +00:00
JBYoshi
b1c7f12fbb
Clean up allow and expect. 2023-05-12 09:57:12 -05:00
JBYoshi
4a3b8923f2
More test cleanup. 2023-05-12 09:52:57 -05:00
JBYoshi
0ddeba6de6
Merge remote-tracking branch 'origin/master' into cask-upgrade/wildcards 2023-05-12 09:46:01 -05:00
JBYoshi
d697037aca
Merge remote-tracking branch 'origin/master' into cask-upgrade/wildcards 2023-05-11 17:32:36 -05:00
JBYoshi
5e23a0563a
Switch base case expect() to allow(). 2023-05-11 17:10:41 -05:00
JBYoshi
7a108d3db0
Merge and_call_original instruction into expect() calls. 2023-05-11 17:09:27 -05:00
Markus Reiter
c5926241a8
Don't fail auditing empty tap. 2023-05-11 21:52:36 +02:00
JBYoshi
84ad387661
Clean up code for feedback. 2023-05-11 13:29:56 -05:00
JBYoshi
29c9921726
Also use / above. 2023-05-11 12:47:37 -05:00
JBYoshi
d0e64e2c57
Use / for path concatenation. 2023-05-11 12:46:05 -05:00
JBYoshi
a1780c842c
Improve unit test to make sure the sudo version is used. 2023-05-11 12:44:35 -05:00
Markus Reiter
5c9c089b68
Improve #to_str and #to_json for Version::NULL. 2023-05-11 19:16:42 +02:00
JBYoshi
2e8232de39
Replace wildcard copy with a loop over children.
Fixes one of the errors in https://github.com/orgs/Homebrew/discussions/4498 (specifically "cp: [...].app/*:
No such file or directory").
2023-05-11 11:47:16 -05:00
Bo Anderson
0daa4d98cf
cleanup: fix version error for cache items without a version 2023-05-11 13:44:26 +01:00
Mike McQuaid
082017e93d
Merge pull request #15402 from Bo98/tab-version-type-fix
tab: fix typing of versions
2023-05-11 13:08:25 +01:00
Bo Anderson
289fb5b393
tab: fix typing of versions 2023-05-11 12:33:27 +01:00
BrewTestBot
8d8e6e4eef
sorbet: Update RBI files.
Autogenerated by the [sorbet](https://github.com/Homebrew/brew/blob/master/.github/workflows/sorbet.yml) workflow.
2023-05-11 00:24:17 +00:00
Bo Anderson
fb31c5d5d6
cask/upgrade: improve error backtraces 2023-05-10 14:46:51 +01:00
Mike McQuaid
15244d8a7d
Merge pull request #15394 from Homebrew/sorbet-files-update
sorbet: Update RBI files.
2023-05-10 13:20:14 +01:00
Mike McQuaid
04866b6e39
Merge pull request #15392 from reitermarkus/remove-rubocop
Remove `NoDslVersion` cop.
2023-05-10 13:13:35 +01:00
Carlo Cabrera
0376c6c5c1
utils/github: use Pulls API to check open pull requests on CI
We currently use the search API to check for duplicate pull requests,
but this is not very reliable. Our `autobump.yml` workflow routinely
opens duplicate pull requests [1] because the search API often returns
incorrect results.

We can make this more reliable by using the Pulls API instead.
Unfortunately, querying the Pulls API is very slow (~10s vs less than a
second for the search API), so let's limit its usage to calls made
inside CI, which should help @BrewTestBot avoid opening duplicate PRs.
(Most recent dupes were authored by @BrewTestBot.)

[1] https://github.com/Homebrew/homebrew-core/pulls?q=is%3Apr+author%3ABrewTestBot+is%3Aunmerged+in%3Acomments+Duplicate
2023-05-10 13:08:32 +08:00
Carlo Cabrera
58067727f4
Merge pull request #15391 from carlocab/fetch-refactor
fetch: remove use of `args` from CLI parser
2023-05-10 10:26:40 +08:00
BrewTestBot
d5de908486
sorbet: Update RBI files.
Autogenerated by the [sorbet](https://github.com/Homebrew/brew/blob/master/.github/workflows/sorbet.yml) workflow.
2023-05-10 00:23:20 +00:00
Markus Reiter
46b9dba03c
Remove NoDslVersion cop. 2023-05-10 01:02:42 +02:00
Markus Reiter
f7168bf234
Merge pull request #15336 from reitermarkus/version-head-null
Merge `HeadVersion` and `NullVersion` into `Version`.
2023-05-10 01:01:21 +02:00
Carlo Cabrera
69c16739d2
fetch: remove use of args from CLI parser
See discussion at #15382.
2023-05-09 18:07:32 +08:00
Mike McQuaid
b3f7c6f7a5
Merge pull request #15390 from Bo98/update-report-no-ext-diff
cmd/update-report: don't invoke external diff tools
2023-05-09 08:34:35 +01:00
Mike McQuaid
e06475b9c4
Merge pull request #15388 from reitermarkus/rubocop-tests
Refactor RuboCop tests.
2023-05-09 08:33:40 +01:00
Markus Reiter
4b787fdee2
Retry curl_headers on 400 codes. 2023-05-09 07:40:15 +02:00
Markus Reiter
e493d0cb04
Rescue ErrorDuringExecution instead of changing curl_headers return type. 2023-05-09 07:25:00 +02:00
Bo Anderson
8e7d4a5bee
cmd/update-report: don't invoke external diff tools 2023-05-09 05:19:55 +01:00
Markus Reiter
8274920217
Rename OS::Mac::Version to MacOSVersion. 2023-05-09 05:08:38 +02:00
Sam Ford
16f3a05e45
Strategy#page_headers: Update for #curl_headers
`#curl_headers` was recently introduced into `Strategy#page_headers`
but only the call was modified and the method wasn't updated to
correctly work with the new return value, so all `HeaderMatch` checks
immediately started failing with an error.

This commit includes changes that return `#page_headers` to a working
state. I've removed the `result.assert_success!` call because it
prevents a few checks from being retried with `GET` (`firefox-cn`,
`krisp`, `prepros`).
2023-05-08 23:08:05 -04:00
Markus Reiter
02dbeb62fc
Refactor RuboCop tests. 2023-05-09 04:28:25 +02:00
BrewTestBot
77a25eed28
sorbet: Update RBI files.
Autogenerated by the [sorbet](https://github.com/Homebrew/brew/blob/master/.github/workflows/sorbet.yml) workflow.
2023-05-09 00:24:08 +00:00
Markus Reiter
4bbf120630
Add note about Version constructor. 2023-05-09 01:13:55 +02:00