337 Commits

Author SHA1 Message Date
Mike McQuaid
6e20cedb67
Don't filter the environment for brew bundle (exec|env|sh)
It's both unexpected and undesirable for `brew bundle (exec|env|sh)` to
filter the environment and makes these tools less useful.

Not filtering the environment, though, causes issues with the
`brew bundle sh` shell. Fix this up and, while we're here, also improve
the formatting for both `zsh` and `bash` (the default) to use nicer and
more consistent prompts and colours.

To simplify this, consolidate some logic in a new
`Utils::Shell.shell_with_prompt` method and add tests for it and a
similar notice for `brew bundle sh`.

Finally, avoid printing out the notice when `HOMEBREW_NO_ENV_HINTS` is
set.
2025-03-24 13:37:25 +00:00
Heath Stewart
42caf20fa4
Add PowerShell (pwsh) completion support
Resolves #19403
2025-03-02 18:17:38 -08:00
Bo Anderson
fed5321969
Rename aarch64_linux tag to arm64_linux 2025-02-01 13:03:58 +01:00
Caleb Xu
2373b6d586
utils: add check_binary_linkage function 2025-01-23 11:26:38 -05: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
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
Rui Chen
79ed2c6e61
chore: fix typos
Signed-off-by: Rui Chen <rui@chenrui.dev>
2024-12-28 15:53:35 -05: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
Michael Cho
f82c58383c
utils/inreplace: allow non-global substitution
Also increase test coverage
2024-10-29 20:15:47 -04:00
Ruoyu Zhong
5a6203a285
test/utils/github_spec: fix artifact URL test
This does the same as dcba7f356d (#15619) and unblocks CI.
2024-10-15 03:01:45 +08:00
Michael Cho
d1dc3b2206
utils/shared_audits: GitHub urls can have '.' in repo and '/' in tag 2024-08-27 11:39:50 -04:00
Mike McQuaid
81d26f8059
Merge pull request #18169 from cho-m/spdx-case-sensitive 2024-08-27 09:28:55 +01:00
Michael Cho
cccab0d9a9
utils/shared_audits: allow subgroups in gitlab url 2024-08-26 23:07:31 -04:00
Michael Cho
82fbbcc88b
utils/spdx: fix invalid SPDX syntax for symbols
Also use more common uppercase operators for backwards compatibility
2024-08-26 13:55:37 -04:00
William Woodruff
419d4f7ab6
curl_spec: use deep_dup
Signed-off-by: William Woodruff <william@yossarian.net>
2024-07-13 15:36:34 -04:00
William Woodruff
695f080ba8
Revert "curl_spec: remove no-op Marshal use"
This reverts commit f3847d263f69a9a36e004c75c4969f939a66de3b.
2024-07-13 15:33:16 -04:00
William Woodruff
f3847d263f
curl_spec: remove no-op Marshal use
Signed-off-by: William Woodruff <william@yossarian.net>
2024-07-13 14:38:57 -04:00
Rylan Polster
e28d455154
autoremove: skip formulae where installed_on_request is nil 2024-06-28 21:57:47 -04:00
Kevin
c3c1528611
Revert "Use cp -c when copying files" 2024-06-17 21:17:10 -07:00
Mike McQuaid
a883f14b72
autoremove: don't remove formulae that were built from source
When a formula was built from source, it should not be removed by
`brew autoremove` as it will take a while to be installed again.

Fixes https://github.com/Homebrew/brew/issues/17433
2024-06-14 17:26:28 +01:00
Mike McQuaid
1e0add6d66
Merge pull request #17373 from tesaguri/cp-reflink 2024-06-13 08:57:20 +01:00
Leo Heitmann Ruiz
4ac57d85b2 Read ZDOTDIR environment variable 2024-06-12 16:53:43 +02:00
Daiki Mizukami
e4fefc94eb
Utils::Copy: Fix tests for generic OS 2024-06-12 19:30:04 +09:00
Daiki Mizukami
028cfe1ea6
Utils::Cp: Rename to Utils::Copy
As per review feedback:

https://github.com/Homebrew/brew/pull/17373#discussion_r1633217748
2024-06-11 20:31:34 +09:00
Daiki Mizukami
4edbbfd794
Utils::Cp: Add tests 2024-06-11 20:27:37 +09:00
Issy Long
808cfda92d
dev-cmd/contributions: Fix the date range behaviour
- This was broken (I did have a commit SHA for the breakage but I can't find it now) since `from` and `args.from` are different variables (one can be nil, the other has a default value).
- So it was reporting very high counts because, despite the message, the `from` restriction was not being passed to `count_repo_commits`.
2024-05-28 13:58:41 +01:00
Markus Reiter
480e264d9a
Lint Ruby docs. 2024-05-01 11:35:21 +02:00
Markus Reiter
caf87c0336
Warn about undocumented non-private APIs. 2024-05-01 11:35:20 +02:00
Markus Reiter
0b56d0be4a
Document Tab.for_keg and use Keg#tab where possible. 2024-04-28 20:50:13 +02:00
Mike McQuaid
28c3215dba
analytics: support command and test-bot analytics.
These are used to analyse which commands are used and the
success/failure rate of official taps using `brew test-bot`.
2024-04-25 17:38:04 +01:00
Ruoyu Zhong
916b37388d
Revert "Revert "os/linux/elf: avoid using ldd for listing dynamic dependencies"" 2024-04-24 02:23:13 +08:00
Ruoyu Zhong
0df71ea6a3
utils/github: support globbing artifacts 2024-04-17 03:34:42 +08:00
Ruoyu Zhong
852c5acb65
Revert "os/linux/elf: avoid using ldd for listing dynamic dependencies" 2024-04-16 02:50:12 +08:00
Caleb Xu
4b0e950736
utils/path: add child_of? method 2024-04-13 19:35:29 -04:00
apainintheneck
226239da4c tests: remove unnecessary cache clearing
This PR removes all remaining unnecessary cache clearing in tests
from the codebase since we now clear all cachable classes between
tests making this functionally unnecessary.

Original PR to automatically clear caches:
- https://github.com/Homebrew/brew/pull/16746

I also moved the `Utils::Analytics` module to use cachable so
that we don't have to clear caches specifically in tests anymore.
2024-03-31 18:38:03 -07:00
Douglas Eichelberger
fde7d380f7 Don't include FileUtils everywhere 2024-03-30 19:10:56 -07:00
Michael Cho
d04c5ad4f8
test/utils/github_spec: filter further to fix test failure
Signed-off-by: Michael Cho <michael@michaelcho.dev>
2024-03-19 17:01:04 -04: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
Mike McQuaid
9259c345cc
utils/analytics: general cleanup.
We have plans to add analytics for commands and `brew test-bot`

This requires a certain amount of refactoring which I've done here.

There was also a bunch of legacy `*_influx_?` usage from when we used
both InfluxDB and Google Analytics that made sense to clean up and
excessive indirection.
2024-03-07 15:19:04 +00:00
Markus Reiter
e3a102efd4
Make Tap::new private. 2024-03-06 15:10:14 +01:00
Douglas Eichelberger
26eda5a303
git grep -l '^describe' | xargs gsed -i 's|^describe|RSpec.describe|g' 2024-02-19 13:57:27 +00:00
Mike McQuaid
3707c90ce1
Merge pull request #16439 from arianf/fix-non-ghcr
Fixes `openjdk_dep_name_if_applicable` when not using `CurlGitHubPackagesDownloadStrategy`
2024-01-31 11:43:28 +00:00
Douglas Eichelberger
e00d066d87 Replace Time refinement with Timer Util 2024-01-29 18:50:12 -08:00
Arian Faurtosh
9088cf9be0 Fixes openjdk_dep_name_if_applicable when not using CurlGitHubPackagesDownloadStrategy
When installing a formula, `FormulaInstaller` calls `#pour`, which in turn calls:

6f20c0300a/Library/Homebrew/formula_installer.rb (L1260)

This `tab` is expected to have `#runtime_dependencies`, and it typically will because most packages come from http://ghcr.io

6f20c0300a/Library/Homebrew/utils/bottles.rb (L111)

Any `DownloadStrategy` that does not match `CurlGitHubPackagesDownloadStrategy` will lead here:
6f20c0300a/Library/Homebrew/software_spec.rb (L463)

Causing this branch to be executed for creating the `tab`:
6f20c0300a/Library/Homebrew/utils/bottles.rb (L119)

This causes a slight issue because `openjdk_dep_name_if_applicable` calls `keg.runtime_dependencies` when it's still `nil`.

6f20c0300a/Library/Homebrew/keg_relocate.rb (L134-L140)

And if it's blank, it won't do the regex replacement on `@@HOMEBREW_JAVA@@`, resulting in the following error when running `Kafka`:

```console
$ tail -f /opt/homebrew/var/log/kafka/kafka_output.log
/opt/homebrew/Cellar/kafka/3.6.0/libexec/bin/kafka-run-class.sh: line 346: /opt/homebrew/@@HOMEBREW_JAVA@@/bin/java: No such file or directory
/opt/homebrew/Cellar/kafka/3.6.0/libexec/bin/kafka-run-class.sh: line 346: exec: /opt/homebrew/@@HOMEBREW_JAVA@@/bin/java: cannot execute: No such file or directory
```

As mentioned by: https://github.com/orgs/Homebrew/discussions/2530#discussioncomment-2002374

> Installing Java-dependent formulae from bottle mirrors doesn't work properly at the moment. The issue is that brew needs the manifest in order to correctly replace @@HOMEBREW_JAVA@@ but brew only knows how to fetch manifests from ghcr.io.
> Pull requests to fix this welcome.

This should fix this issue, by getting the `runtime_dependencies` directly from the formula for those cases that it can't get it from https://ghcr.io or tabfile

```ruby
f_runtime_deps = formula.runtime_dependencies(read_from_tab: false)
tab.runtime_dependencies = Tab.runtime_deps_hash(formula, f_runtime_deps)
```
2024-01-29 15:57:55 -08:00
Douglas Eichelberger
0852e1d7b6 Refactor away String#indent 2024-01-08 13:36:45 -08:00
Bo Anderson
5692c8ecbf
Fix style violations under newer RuboCop 2023-12-14 05:47:12 +00:00
Eric Knibbe
77c23df526
dependency: disable renamed formula warning 2023-12-11 14:14:52 -05:00
Mike McQuaid
35369e1009
utils/svn_spec: change remote used in test.
GitHub is dropping their Subversion support so let's move to an Apache
Subversion server instead.
2023-12-05 14:20:12 -05:00
Bo Anderson
71f558229a
Test on Ruby 3.1 2023-09-29 04:46:16 +01:00