1738 Commits

Author SHA1 Message Date
Issy Long
599616e8e0
Apply easy to understand Sorbet typing corrections
Co-authored-by: Mike McQuaid <mike@mikemcquaid.com>
2025-01-22 22:01:34 +00:00
Issy Long
7a88125df0
The Style/AvoidDoubleNegation RuboCop is insistent 2025-01-22 22:01:34 +00:00
Issy Long
975a707b3c
Bump some utils/ files to Sorbet typed: strict 2025-01-22 22:01:34 +00:00
Sam Ford
d8125322e1
Curl: expand test coverage
This adds more tests to `curl_spec.rb` to increase test coverage.
This brings almost all of the methods that don't make network
requests up to 100% line and branch coverage (the exception being
some guards in `parse_curl_output` that shouldn't happen under
normal circumstances).

In the process of writing more tests for `parse_curl_response`, I
made some tweaks to remove checks for conditions that shouldn't ever
be true (e.g., `match["code"]` isn't optional, so it will be present
if `HTTP_STATUS_LINE_REGEX` matches) and to refactor some others. I
contributed this method a while back (9171eb2), so this is me coming
back to clarify some behavior.
2025-01-14 08:14:39 -05:00
Sam Ford
cf22382921
Curl: use typed: strict
This upgrades `utils/curl.rb` to `typed: strict`, which requires
a number of changes to pass `brew typecheck`. The most
straightforward are adding type signatures to methods, adding type
annotations (e.g., `T.let`) to variables that need them, and ensuring
that methods always use the expected return type.

I had to refactor areas where we call a `Utils::Curl` method and use
array destructuring on a `SystemCommand::Result` return value
(e.g., `output, errors, status = curl_output(...)`), as Sorbet
doesn't understand implicit array conversion. As suggested by Markus,
I've switched these areas to use `#stdout`, `#stderr`, and `#status`.
This requires the use of an intermediate variable (`result`) in some
cases but this was a fairly straightforward substitution.

I also had to refactor how `Cask::URL::BlockDSL::PageWithURL` works.
It currently uses `page.extend PageWithURL` to add a `url` attribute
but this reworks it to subclass `SimpleDelegator` and use an
`initialize` method instead. This achieves the same goal but in a way
that Sorbet can understand.
2025-01-14 08:14:39 -05:00
Issy Long
6ada9a9665
Add clarifying comments to rubocop:disables
- Needed for PR 18842 that adds a `DisableComment` RuboCop to ensure that all RuboCop disables have comments.
2025-01-12 16:59:07 +00:00
Issy Long
268f801038
Bump more files to Sorbet typed: strict 2025-01-11 00:11:27 +00:00
Daeho Ro
05b97cdc48
fix prerelease check to allow standard release 2024-12-27 19:22:04 +09:00
Daeho Ro
d50e872fd8
update prerelease check to allow standard release 2024-12-25 20:52:38 +09:00
Daeho Ro
ce25ac7be6
update prerelease check to allow standard release 2024-12-25 16:57:07 +09:00
Michael Cho
e9671db2d3
utils/github: handle over 30 changed files 2024-12-13 22:41:21 -05:00
Douglas Eichelberger
9e3e1e1847 Namespace some top-level constants 2024-12-11 11:04:55 -08:00
Bo Anderson
ccdf39ff4e
dev-cmd/tap-new: improve handling of multi-user setups 2024-12-10 05:24:10 +00:00
Ruoyu Zhong
a8a6a5bdb7
utils/service: simplify 2024-12-04 03:09:11 +08:00
Ruoyu Zhong
15146b2b67
utils/service: add systemd_quote helper
We need a way to escape systemd command lines properly as systemd treats
unrecognised escape sequences as separate literal characters. This helper
function does that.
2024-12-04 02:57:08 +08:00
Patrick Linnane
d04430d1a5
brew style --fix
Signed-off-by: Patrick Linnane <patrick@linnane.io>
2024-11-26 14:09:13 -08:00
Elijah Olmos
ba4dfb2664
Update Library/Homebrew/utils/github.rb
Co-authored-by: Mike McQuaid <mike@mikemcquaid.com>
2024-11-17 15:06:34 -07:00
Elijah Olmos
3922140f9a
push uncommitted code 2024-11-15 18:07:48 -07:00
Elijah Olmos
d068496aa5
chore: remove debug statement 2024-11-15 17:49:10 -07:00
Elijah Olmos
4653d5889e
fix: too_many_open_prs() fails without SSO access 2024-11-15 16:25:06 -07:00
Carlo Cabrera
1fbe4366a0
Support setting GIT_COMMITTER_NAME and GIT_COMMITTER_EMAIL
Our autobump workflow sets the author and committer to the user who
triggered the workflow, defaulting to @BrewTestBot for scheduled runs.

This can be confusing for maintainers when GitHub shows up as
"Unverified" because the commit is signed with @BrewTestBot's key.[^1]

Let's fix that by configuring our autobump workflow to always commit as
@BrewTestBot, so that the committer matches the GPG signature. To do
that, we need to add support for setting `GIT_COMMITTER_NAME` and
`GIT_COMMITTER_EMAIL`.

[^1]: See, for example, Homebrew/homebrew-core#197234.
2024-11-11 18:45:38 +08:00
Douglas Eichelberger
521c463e36
Manually resolve Style/SafeNavigationChainLength violations 2024-11-05 16:44:12 +00:00
Douglas Eichelberger
ffb15ffcf5
brew style --fix 2024-11-05 16:44:12 +00:00
Michael Cho
f82c58383c
utils/inreplace: allow non-global substitution
Also increase test coverage
2024-10-29 20:15:47 -04:00
Bo Anderson
ddfe04a601
Merge pull request #18516 from Homebrew/lockf-macos-15
utils/lock: use new lockf where available
2024-10-25 03:09:12 +01:00
Sam Ford
4ed2eb6811
curl: handle multiple Content-Type headers
`#curl_http_content_headers_and_checksum` contains code that works
with a `Content-Type` header in a response but it expects there to
always be only one header in the response. This is normally a
reasonable assumption but we've come across a server that is giving
a response with multiple `Content-Type` headers in the response, so
this produces an error and causes `brew audit` to fail when checking
the URL.

This works around the issue by naively using the last `Content-Type`
header in the response when there's more than one. It's not something
that should normally occur but this will handle the situation when it
does.
2024-10-19 18:02:06 -04:00
Carlo Cabrera
7a8f9fa489
extend/kernel: fix duplicate messages in GitHub Actions
Calls to `opoo` and `onoe` produce duplicate `Warning:` and `Error:`
messages in CI logs because we print something to stdout and print an
annotation. Annotations also produce `Error:` and `Warning:` lines in
the log.

Let's fix this by skipping printing the message if we've already printed
an annotation.
2024-10-14 12:15:24 +08:00
Bo Anderson
60a963a07e
utils/lock: use new lockf where available 2024-10-05 19:17:08 +01:00
Michael Cho
43ee408793
utils/curl: workaround curl bug for --head --request GET
The `curl --head --request GET` causes a full download to happen on
`curl` from 8.7.0 to 8.9.1[^1] which causes poor UX due to slow
Cask downloads that can take almost twice as long as they should.

[^1]: https://github.com/Homebrew/brew/issues/18213
2024-10-05 14:05:59 -04:00
Patrick Linnane
c2e2b23c50
brew style --fix
Signed-off-by: Patrick Linnane <patrick@linnane.io>
2024-10-02 10:03:12 -07:00
Bevan Kay
53e8739d24
utils/shared_audits: audit deprecate/disable reasons 2024-09-30 23:11:44 +10:00
Bob Lail
c752c00ac6 brew vendor-gems: commit updates. 2024-09-27 14:44:40 -07:00
Bo Anderson
567f5eb4be
Allow sockets to use longer paths on macOS 2024-09-27 04:37:03 +01: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
Mike McQuaid
1c390093f8
Revert "Limit usage of GitHub Actions Annotations" 2024-09-16 16:52:03 +01:00
Carlo Cabrera
c6e2cd9037
Limit usage of GitHub Actions Annotations
- only use annotations for `opoo` and `onoe` if
  `HOMEBREW_GITHUB_ACTIONS` is set. This will make using `brew` less
  noisy in GitHub Actions for third parties. See
  Homebrew/discussions#5602.
- if we've already called `puts_annotation_if_env_set`, then we no
  longer need to print the message to `$stderr`. The message from the
  annotation already show up in the GitHub Actions log, so printing to
  `$stderr` just leads to duplicate messages in the log.

While we're here, let's make sure to forward the `file:` and `line:`
kwargs of `puts_annotation_if_env_set` to the `Annotation` constructor.
2024-09-15 11:31:54 +08:00
Mike McQuaid
c8e8aa5600
Merge pull request #17756 from reitermarkus/concurrent-downloads
Implement concurrent downloads in `brew fetch`.
2024-09-09 08:41:11 +01:00
Bo Anderson
d8d9151c8c
Merge pull request #18283 from Homebrew/annotation-titles
github/actions: fix annotation title handling
2024-09-09 02:55:16 +01:00
Carlo Cabrera
54383d1c5f
github/actions: fix annotation title handling
We currently generate invalid workflow commands when we create
annotations with a `title` but no `file`. Let's fix that.

While we're here, let's improve handling of `title`s with `:`s. We
cannot use `title`s with `::` since GitHub Actions uses this as a
separator for different fields between a workflow command.

Let's also make sure `metadata` never ends in a `:` to avoid confusing
the GitHub Actions command parser about where the `::` separator is
meant to be.
2024-09-08 17:56:04 +08:00
Sam Ford
c2f0bacec8
Curl#curl_headers: Work with 56 exit_status
I previously added the 8 curl exit code (weird server reply) to the
list of non-success exit codes that `#curl_headers` will handle.
We're now seeing failures with a 56 exit code (failure in receiving
network data), where the server returns a 4xx response for a `HEAD`
request but the same request using `GET` works as expected (e.g.,
casks like `beeper`, `get-api`, `odrive`, `ui`, etc.).

This adds 56 to the list of exit codes in `#curl_headers`, so a
response with a 4xx HTTP status will be automatically retried using
`GET`.
2024-09-07 10:25:47 -04:00
Markus Reiter
9fd4c97fac
Add method for moving cursor up and to the beginning. 2024-09-04 22:54:29 +02:00
Markus Reiter
984cde114a
Move escape codes to Tty. 2024-09-04 22:54:28 +02:00
Markus Reiter
0cafa83f8a
Simplify Tty methods. 2024-09-04 22:54:26 +02:00
Markus Reiter
a114575663
Fix wrong terminal size. 2024-09-04 22:54:25 +02:00
Markus Reiter
6434533ff5
Remove Whirly and show concurrent downloads. 2024-09-04 22:54:24 +02:00
Bo Anderson
176ec0c6aa
utils/github: use x-access-token 2024-09-04 06:14:32 +01:00
Bo Anderson
e4896f3440
list.sh: support column output 2024-09-03 04:11:29 +01:00
Carlo Cabrera
cd5cf4e2c8
Merge pull request #18214 from Homebrew/audit-result-keyword 2024-09-02 16:14:30 +08:00
Carlo Cabrera
c73d08c75b
Update comment re #nil? vs #blank? 2024-09-02 16:02:35 +08:00
Adam Blazczak
245c93785a Fix SyntaxError introduced by a refactor in bc0f5ee
$ brew update
==> Updating Homebrew...
To restore the stashed changes to /usr/local/Homebrew, run:
  cd /usr/local/Homebrew && git stash pop
  File "<string>", line 1
    import fcntl; fcntl.flock(, fcntl.LOCK_EX | fcntl.LOCK_NB)
                              ^
SyntaxError: invalid syntax

Introduced on May 2, 2024 with bc0f5ee62a
2024-09-01 10:40:23 -07:00