217 Commits
Author SHA1 Message Date
Sam Ford 7b23bc64e5 Curl: Rename :status to :status_code
The return hash from `#curl_http_content_headers_and_checksum`
contains a `:status`, which is the status code of the last response.
This string value comes from `#parse_curl_response`, where the key is
`:status_code` instead.

Aligning these keys technically allows us to pass either of these
hashes to the `#url_protected_by_*` methods, as both contain
`:status_code` and `:headers` in the expected format.
2022-05-25 16:50:02 -04:00
Sam Ford 40b8fd3406 url_protected_by_*: Check multiple headers
Before `#parse_curl_output` was introduced and related methods were
updated to use it, `#url_protected_by_cloudflare?` and
`#url_protected_by_incapsula?` were checking a string of all the
headers from a response and using a regex to check related header
values.

However, when `#curl_http_content_headers_and_checksum` was updated
to use `#parse_curl_output` internally, the `:headers` value became
a hash generated by `#parse_curl_response`. The `#url_protected_by_*`
methods were updated to work with the hash value but this wasn't able
to fully replicate the previous behavior because
`#parse_curl_response` was only keeping the last instance of a given
header (maintaining pre-existing behavior). This is an issue for
these methods because they check `Set-Cookie` headers and there can
be multiple instances of this header in a response.

This commit updates these methods to handle an array of strings in
addition to the existing string support. This change ensures that
these methods properly check all `Set-Cookie` headers, effectively
reinstating the previous behavior.

Past that, this updates one of the early return values in
`#url_protected_by_cloudflare?` to be `false` instead of an implicit
`nil`. After adding a type signature to this method, it became clear
that it wasn't always returning a boolean value and this fixes it.
2022-05-06 10:51:26 -04:00
Sam Ford 94449d07c0 parse_curl_response: Handle duplicate headers
`Curl#parse_curl_response` only includes the last instance of a given
header in its `:headers` hash (replicating pre-existing behavior).
This is a problem for headers like `Set-Cookie`, which can appear more
than once in a response.

This commit addresses the issue by collecting duplicate headers into
an array instead. Headers that only appear once in the response will
still have a string value but headers that appear more than once will
be an array of strings. Whenever headers from `#parse_curl_response`
are used (directly or indirectly), it's important to conditionally
handle the expected types.
2022-05-06 10:51:22 -04:00
Sam Ford 9171eb2e16 Curl: Add methods to parse response 2022-04-20 23:47:51 -04:00
Michka Popoff a5c29fff2d utils/github.rb: convert pr to integer
Follow up adter #13124

I made the choice to convert the pr variable to an integer
at the very end and adjust the tests.

It would be maybe more consistent to work with an integer
everywhere, but this needs a more careful analysis and we
are in a hurry to fix the homberew-core upload CI

Fixes:
2022-04-11T20:19:34.1395885Z [31mError:[0m : Variable $pr of type Int! was provided invalid value
2022-04-11T20:19:34.1398279Z /home/linuxbrew/.linuxbrew/Homebrew/Library/Homebrew/utils/github/api.rb:261:in `open_graphql'
2022-04-11T20:19:34.1399774Z /home/linuxbrew/.linuxbrew/Homebrew/Library/Homebrew/utils/github.rb:310:in `get_workflow_run'
2022-04-11T20:19:34.1403699Z /home/linuxbrew/.linuxbrew/Homebrew/Library/Homebrew/dev-cmd/pr-pull.rb:418:in `block (4 levels) in pr_pull'
2022-04-11T20:19:34.1405233Z /home/linuxbrew/.linuxbrew/Homebrew/Library/Homebrew/dev-cmd/pr-pull.rb:417:in `each'
2022-04-11T20:19:34.1406723Z /home/linuxbrew/.linuxbrew/Homebrew/Library/Homebrew/dev-cmd/pr-pull.rb:417:in `block (3 levels) in pr_pull'
2022-04-11T20:19:34.1408112Z /home/linuxbrew/.linuxbrew/Homebrew/Library/Homebrew/vendor/portable-ruby/2.6.8/lib/ruby/2.6.0/fileutils.rb:128:in `chdir'
2022-04-11T20:19:34.1408986Z /home/linuxbrew/.linuxbrew/Homebrew/Library/Homebrew/vendor/portable-ruby/2.6.8/lib/ruby/2.6.0/fileutils.rb:128:in `cd'
2022-04-11T20:19:34.1409813Z /home/linuxbrew/.linuxbrew/Homebrew/Library/Homebrew/dev-cmd/pr-pull.rb:400:in `block (2 levels) in pr_pull'
2022-04-11T20:19:34.1410671Z /home/linuxbrew/.linuxbrew/Homebrew/Library/Homebrew/vendor/portable-ruby/2.6.8/lib/ruby/2.6.0/tmpdir.rb:93:in `mktmpdir'
2022-04-11T20:19:34.1411495Z /home/linuxbrew/.linuxbrew/Homebrew/Library/Homebrew/dev-cmd/pr-pull.rb:399:in `block in pr_pull'
2022-04-11T20:19:34.1412250Z /home/linuxbrew/.linuxbrew/Homebrew/Library/Homebrew/dev-cmd/pr-pull.rb:388:in `each'
2022-04-11T20:19:34.1413056Z /home/linuxbrew/.linuxbrew/Homebrew/Library/Homebrew/dev-cmd/pr-pull.rb:388:in `pr_pull'
2022-04-11 22:38:42 +02:00
Bo Anderson 3e75b165ae utils/github: rewrite get_workflow_run using GraphQL 2022-04-11 20:35:03 +01:00
Issy Long cb2a09e65e Fix (auto-correct) more RSpec/BeNil offenses
- The `RSpec/BeEq` auto-corrections made more `RSpec/BeNil` offenses, so another go of `brew style --only=RSpec/BeNil --fix\` is needed.
2022-03-01 00:36:37 +00:00
Issy Long 72e48024f0 Fix (auto-correct) RuboCop Rspec/BeEq offenses 2022-03-01 00:10:14 +00:00
Issy Long 6b76fd012a Fix (auto-correct) RuboCop RSpec/BeNil offenses 2022-03-01 00:10:10 +00:00
Niklas Higi 00f209e16e Recommend interactive usage of fish_add_path
Since the `fish_add_path` command modifies a universal Fish variable
(which is automatically persisted to a file) it's unnecessary to run it
again every time a new shell is opened.
2022-02-05 16:29:09 +01:00
Carlo Cabrera 2b60a99d4a Revert "shebang: raise error if no rewriting"
This is causing failures when attempting to rewrite shebangs during the
cleanup stage of `brew install`.

See, for example, Homebrew/homebrew-core#94323,
Homebrew/homebrew-core#94321.

This reverts commit 7e6be5eb44.
2022-02-02 20:44:03 +08:00
Branch Vincent 7e6be5eb44 shebang: raise error if no rewriting 2022-02-01 00:17:50 -05:00
Mike McQuaid b09f421027 repology: always use Homebrew curl.
This seems to be required even with TLSv1.3 support now.

Also, while we're here, improve the error handling/output.
2022-01-03 13:17:12 +00:00
Steve Peters d53dab62c9 bump-revision: add --remove-bottle-block option
This removes a bottle block for the specified formulae
while bumping the revision.
2021-12-26 03:42:39 -08:00
Rylan Polster 2e6b6ab3a2 Fix style 2021-12-24 21:15:21 -05:00
Rylan Polster 7656c09184 Only check for Rosetta on macOS 2021-12-05 13:03:38 -05:00
Nipunn Koorapati 30c4663066 Fix analytics string to test for CI 2021-12-04 12:29:31 -05:00
Rylan Polster b58551cd67 Control for CPU type and Rosetta in os_arch_prefix_ci tests 2021-12-03 22:29:10 -05:00
Nipunn Koorapati e2fc14b0b7 Fix analytics_spec.rb test to pass when run from M1 2021-12-03 20:14:17 -05:00
XuehaiPan d1aac8857a tests/utils/git_spec: update tests for ensure_formula_installed! 2021-11-24 00:30:26 +08:00
Carlo Cabrera 105d1f9cfc utils/github/actions: make file a mandatory argument
An annotation is pretty useless if you don't specify a file to place the
annotation on, so let's just require it.
2021-11-16 23:42:03 +08:00
EricFromCanada c952ea7358 bump: fix tests 2021-10-25 15:55:11 -04:00
EricFromCanada 811d0fa0bd bump: add option to retrieve a subset of results
Plus a few fixes for output.
2021-10-19 20:14:39 -04:00
Bo Anderson 30b24cf4ad Use HOMEBREW_CURL universally, including formulae 2021-10-04 02:03:04 +01:00
Bo Anderson b55498269f Revamp APIs around bottle specifications 2021-09-20 15:02:05 +01:00
fn ⌃ ⌥ 0c3e49092c upgrade: use topological sort to upgrade formulae 2021-09-09 13:41:50 -07:00
Sam Ford d44979fa67 Curl#curl_args: Fix and refactor options 2021-09-07 14:13:17 -04:00
Nanda H Krishna 5ccfbcd1d2 Autocorrect style issues with brew style --fix 2021-07-08 12:36:39 +05:30
Mike McQuaid 1680ddb267 utils/repology: temporarily disable functionality.
Doesn't work with system `curl` currently.
2021-06-30 09:20:56 +01:00
Michael Cho d304c84f2a test/utils/github_spec: fix artifact number 2021-06-25 11:36:13 -07:00
Alexander Bayandin d55cbeac78 github_spec: Update PR number with unexpired artifacts 2021-06-24 13:29:44 +01:00
Sam Ford 0752d25125 OS::Mac: Move version methods into ::Version 2021-06-23 09:03:46 -04:00
Misty De Meo c0a02442d9 Revert "language/java: use shortened brew paths"
This reverts commits 318175cfe2,
e7ab760392 and
3b35af63f6 (PR #11537).
2021-06-17 20:29:43 -07:00
Misty De MeoandGitHub 3cf5c3239f Merge pull request #11544 from mistydemeo/fix_tests
Fix a pair of tests on Apple silicon
2021-06-16 03:15:06 -07:00
Misty De Meo 93ea8b6350 Analytics spec: avoid ARM-specific strings 2021-06-15 20:35:21 -07:00
Caleb Xu 318175cfe2 Utils: add shortened_brew_path 2021-06-15 09:58:46 -04:00
Mike McQuaid b914411ac8 Delete Bintray code
Remove all code related to Bintray. It no longer works so there's no
point keeping it around.

Some of this could arguably be deprecated/disabled first/instead but:
I'm not sure I see the sense in keeping stuff around that's known to be
broken.
2021-05-12 13:37:18 +01:00
David Xia 7920006020 fix: use recommended way of updating Fish shell $PATH
fixes https://github.com/Homebrew/brew/issues/8965

See Fish docs https://fishshell.com/docs/current/tutorial.html#path.

> A faster way is to use the `fish_add_path function`... The advantage is that
> you don't have to go mucking around in files: just run this once at the
> command line, and it will affect the current session and all future instances
> too.
>
> Or you can modify `$fish_user_paths` yourself, but you should be careful not
> to append to it unconditionally in config.fish, or it will grow longer and
> longer.
2021-05-08 21:19:19 -07:00
John Bampton 1691e615fe Fix spelling 2021-05-08 11:20:01 +10:00
Bo Anderson 20d86c0185 Refactor some tag handling into a Utils::Bottles::Tag class 2021-04-08 17:23:57 +01:00
hyuraku 178ae750b9 utils/github: set default args to search_code 2021-02-26 21:31:30 +09:00
Kenneth Chew edead95768 utils/spdx: correctly detect non-deprecated licenses with plus 2021-02-23 16:28:24 -05: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
nandahkrishna 24bb6040a7 dev-cmd/bump: add cask support 2021-02-17 00:42:07 +05:30
Bo Anderson f5c075d668 test/utils/git_spec: fix cherry pick test with older git 2021-02-10 17:36:46 +00:00
nandahkrishna 0474fe6093 dev-cmd/update-maintainers: add tests 2021-02-08 23:33:25 +05:30
Mike McQuaid e65e310fd0 Fix brew style 2021-01-29 20:56:59 +00:00
EricFromCanada a427de5bee capitalization fixes
"curl" is the binary, while "cURL" is the umbrella project.
2021-01-26 15:36:44 -05:00
nandahkrishna e2ddf9894a Refactor brew bump 2021-01-24 19:10:46 +05:30
Seeker bd25e7da2a utils/git_repository: add ::git_branch and ::git_commit_message 2021-01-20 17:34:54 -08:00