694 Commits

Author SHA1 Message Date
Harry Marr
49e2cf9f92
Extract supports_partial_clone_sparse_checkout? 2022-10-20 15:45:33 -04:00
Harry Marr
99504c4474
Use blank? rather than nil?
Co-authored-by: Mike McQuaid <mike@mikemcquaid.com>
2022-10-20 15:45:33 -04:00
Harry Marr
1472259e1d
Appease rubocop 2022-10-20 15:45:33 -04:00
Harry Marr
7df90eb7e1
Support git partial clones with sparse checkouts 2022-10-20 15:45:32 -04:00
nthumann
f54de5a848
Fix curl_output for curl download strategy 2022-10-16 22:30:16 +02:00
Bo Anderson
9b99594753
Preliminary compatibility fixes for Ruby 3 2022-10-11 02:53:27 +01:00
Carlo Cabrera
e1ba143d88
download_strategy: replace bazaar with breezy
Bazaar is no longer maintained, and Breezy seems to be a drop-in
replacement.

I've tested the commands used in the download strategy and they seem to
work.

We need this in order to properly deprecate the `bazaar` formula.

See Homebrew/homebrew-core#106848.
2022-07-29 17:02:39 +08:00
Alexander Bayandin
4e8cc524c5 Clean up GitHub headers 2022-07-24 11:44:16 +00:00
Bo Anderson
02164a35db
Use ORIGINAL_PATHS over envs; reject nil PATH 2022-06-17 19:47:57 +01:00
Gordon Bleux
bcfd20e1b9 change cURL download behaviour for HOMEBREW_ARTIFACT_DOMAIN.
instead of prefixing and/or replacing data in URLs, the
*HOMEBREW_ARTIFACT_DOMAIN* environment variable only replaces
the bottle base URL. this causes URLs from Casks and other assets
to be no longer affected by this feature.

closes #13226
closes #13222
closes #13227
2022-06-11 08:24:50 +02:00
Sam Ford
3f7d9f82fc
#curl_download: default try_partial to false
When its `try_partial` argument is `true`, `#curl_download` makes a
`HEAD` request before downloading the file using `#curl`. Currently
`try_partial` defaults to `true`, so any `#curl_download` call that
doesn't explicitly specify `try_partial: false` will make a `HEAD`
request first. This can potentially involve several requests if the
URL redirects, so it can be a bit of unnecessary overhead when a
partial download isn't needed.

Partial downloads are generally only useful when we're working with
larger files, however there's currently only one place in brew where
`#curl_download` is used and this is the case:
`CurlDownloadStrategy`. The other `#curl_download` calls are fetching
smaller [text] files and don't need to support partial downloads.

This commit changes the default `try_partial` value to `false`,
making partial downloads opt-in rather than opt-out.

We want `try_partial` to continue to default to `true` in
`CurlDownloadStrategy` and there are various ways to accomplish this.
In this commit, I've chosen to update its `#initialize` method to
accept a `try_partial` argument that defaults to `true`, as this
value can also be used in classes that inherit from
`CurlDownloadStrategy` (e.g., `HomebrewCurlDownloadStrategy`). This
instance variable is passed to `#curl_download` in related methods,
effectively maintaining the previous `try_partial: true` value, while
also allowing this value to be overridden when necessary.

Other uses of `#curl_download` in brew are
`Formulary::FromUrlLoader#load_file` and
`Cask::CaskLoader::FromURILoader#load`, which did not provide a
`try_partial` argument but should have been using
`try_partial: false`. With the `try_partial: false` default in this
commit, these calls are now fine without a `try_partial` argument.

The only other use of `#curl_download` in brew is
`SPDX#download_latest_license_data!`. These calls were previously
using `try_partial: false` but we can now omit this argument with
the new `false` default (aligning with the above).
2022-04-22 14:23:08 -04:00
Sam Ford
9355da5291
DownloadStrategy: Use #curl_response_last_location 2022-04-20 23:47:51 -04:00
Issy Long
94d8bd5d32
download_strategy: In regexps, only allow valid hostname characters
> This regular expression has an unrestricted wildcard '.+?' which may cause 'googlecode\.com/svn' to be matched anywhere in the URL, outside the hostname.
2022-04-15 16:45:42 +01:00
Bo Anderson
389fa4287d
Merge pull request #13110 from Bo98/ignore-resolved-query
download_strategy: ignore query strings when parsing resolved URLs
2022-04-11 18:23:23 +01:00
Bo Anderson
36b98019e8
download_strategy: strip query string from basename 2022-04-11 15:20:56 +01:00
Bo Anderson
a50db1378e
download_strategy: ignore query strings when parsing resolved URLs 2022-04-11 15:17:29 +01:00
Mike McQuaid
04938efc24
Unify GitHub Packages authorization logic in brew.sh. 2022-01-27 15:44:34 +00:00
Zach Auten
7b2666eb9a
Add basic auth to curl download strategy, HOMEBREW_DOCKER_REGISTRY_TOKEN env variable 2022-01-06 09:41:09 -05:00
Bob Lail
68245e0f60 Silence the detachedHead warning when ref_type is a revision
The PR that added this #8622 didn't actually resolve the problem because you see the warning when the `@ref_type` you've specified is a `:revision` (not a `:branch` or `:tag`).

The output looks like this:
```
==> Checking out revision 3b3527f5050270cf1acd280691b09b5abe130e73
Note: switching to '3b3527f5050270cf1acd280691b09b5abe130e73'

You are in 'detached HEAD' state. You can look around, make experimental
changes and commit them, and you can discard any commits you make in this
state without impacting any branches by switching back to a branch.

If you want to create a new branch to retain commits you create, you may
do so (now or later) by using -c with the switch command. Example:

   git switch -c <new-branch-name>

Or undo this operation with:

   git switch -

Turn off this advice by setting config variable advice.detachedHead to false
```
2021-12-02 11:07:39 -06:00
Mike McQuaid
11c5f8f05a
Improve discovery of some environment variables
There's a few bits of functionality that Homebrew has changed over the
years, makes sense as a sensible default but some people find really
annoying:

- automatically running `brew update`
- automatically running `brew cleanup`
- automatically upgrading outdated dependents
- automatically reinstalling broken dependents

For each of these: let's improve the documentation of the commands
whose behaviour is changed and the environment variables themselves.
2021-11-25 09:10:59 +00:00
EricFromCanada
093e6e11da
svn: add flags if needed for :trust_cert or remote_exists? 2021-11-09 13:56:40 -05:00
Bob Lail
dd3b0d244f Memoize GitHubGitDownloadStrategy#default_branch
and then remove `yield_self` from `default_refspec` in favor of relying on `default_branch`'s memoization
2021-10-25 08:19:14 -05:00
Bob Lail
b7426b4d51 When using git fetch origin to pull resources from GitHub, pull the default branch instead of all refs 2021-10-22 12:05:39 -05:00
Bob Lail
701a1661d2 fix: Allow specifying :revision for resources downloaded from Git repos whose default branch is not named master
### Background
Given a repo that does not have branch named `master` and a formula like this:
```ruby
class Example < Formula
  stable do
    url "https://github.com/user/example.git", revision: "e8b123de62e0faec283c3253c6ea5495a332007e"
  end
end
```

Homebrew was executing this when the cached location did not exist:
```
git clone https://github.com/user/example.git /path/to/cache
```
(which would work)

and this when the cached location did exist:
```
git -C /path/to/cache config remote.origin.fetch +refs/heads/master:refs/remotes/origin/master
git -C /path/to/cache fetch origin
```
(which would always fail with `fatal: couldn't find remote ref refs/heads/master`)

This commit changes the value for `remote.origin.fetch` to `+refs/heads/*:refs/remotes/origin/*` which is [Git's default value for the refspec](https://git-scm.com/book/en/v2/Git-Internals-The-Refspec) anyway.

This may increase the latency of `git fetch origin` for formulae that use `:revision` because Git will now fetch all remote refs; but it does have the advantage of not being broken 🙂
2021-10-22 10:44:03 -05:00
Bo Anderson
5137244c92
download_strategy: adjust --insecure warning wording
Co-authored-by: Rylan Polster <rslpolster@gmail.com>
2021-10-04 20:04:50 +01:00
Bo Anderson
cb0a90262d
download_strategy: remove redundant conditional 2021-10-04 17:16:20 +01:00
Bo Anderson
5dc46a9e12
Use --insecure to download ca-certificates source where necessary 2021-10-04 16:37:44 +01:00
Kurt Raschke
f05f3ad345
Replace two calls to undefined silent_command! in FossilDownloadStrategy with command!
`FossilDownloadStrategy` attempts to call `silent_command!` in two places; this does not exist.
2021-09-08 00:09:31 -04:00
Sam Ford
f88966a8a5
Use curl options where appropriate 2021-09-07 14:13:19 -04:00
Bo Anderson
d756d05a23
Merge pull request #11871 from Bo98/headers-type
download_strategy: fix error when using custom headers with a redirect
2021-08-18 13:43:06 +01:00
Bo Anderson
de15cd6420
download_strategy: fix error when using custom headers with a redirect 2021-08-18 03:02:13 +01:00
Michka Popoff
07df4a7e70
Use Homebrew curl for audit and fetch when specified in the formula
Introduce new :using for urls
2021-08-17 13:35:55 +02:00
yahavi
285513fd65 Allow anonymous access in private registries 2021-08-04 18:52:52 +03:00
yahavi
d8d1922fec Error raised when no headers defined in curl download 2021-07-27 16:17:46 +03:00
yahavi
1116580502 Implement code review comment 2021-07-27 09:55:22 +03:00
yahavi
0335d8c0bc Fix code review comments + disable authorization on redirections 2021-07-26 19:07:23 +03:00
yahavi
cc12738f8e Allow anonymous access in private registries 2021-07-26 09:58:34 +03:00
yahavi
b8954030e3 Add support for private registry 2021-07-25 10:50:12 +03:00
Rylan Polster
9db79ce247
LocalBottleDownloadStrategy: extend Pourable 2021-06-10 14:51:19 -04:00
Mike McQuaid
2ce6cd5e81
brew style --fix 2021-05-18 11:58:44 +01:00
cnnrmnn
bab8f32405 Stop using shallow clones 2021-05-05 10:38:56 -04:00
Shaun Jackman
e160c4a401 GHCR: Authorization bearer requires a token 2021-04-07 20:42:12 -07:00
Mike McQuaid
cdaeee03c4
GitHub Packages cleanup
- `download_strategy`: only request image index JSON for downloading
  the manifest for the tab
- use a shared `OS` constant for the version of `glibc` we use in CI
- fix `skoepeo` typo
- ensure that blank hash values are deleted (again) rather than just
  `nil` ones
- use a shared `Hardware::CPU` constant for oldest CPU we're
  supporting/using on Intel 64-bit
- re-add comment to `software_spec`
2021-04-05 14:58:17 +01:00
Shaun Jackman
9c54259dfe CurlGitHubPackagesDownloadStrategy: Add Accept
Add HTTP header Accept: application/vnd.oci.image.index.v1+json
2021-04-04 00:56:22 -07:00
Markus Reiter
5cca3c5fd7
Mark cached_location and url public. 2021-04-03 20:10:33 +02:00
Markus Reiter
24c9b599a6
Revert "Revert "Merge pull request #10864 from reitermarkus/command-timeout""
This reverts commit 57b2660cae8cf43efd2b88d84a7174706328c001.
2021-04-03 20:10:32 +02:00
Mike McQuaid
8144fdef78
Simplify CurlGitHubPackagesDownloadStrategy usage 2021-04-01 17:37:16 +01:00
Mike McQuaid
7b9b9e16ec
download_strategy: fix whitespace. 2021-04-01 17:37:15 +01:00
Mike McQuaid
d8a2cf9efc
Write tabs to bottle JSON, optionally not bottle
- Write a subset of the tab required for bottles as an annotation.
- Add option on new bottle creation to skip writing tab into bottle
  and instead add it (and other useful metadata) to bottle JSON.
- Read formula information and tab from bottle JSON.
- Write prettier JSON to disk.
- Don't write `HEAD` to tab; this duplicates `HOMEBREW_VERSION`.
- Allow `brew bottle` to use `--json` to generate JSON files from a
  local bottle file.
2021-03-31 09:43:37 +01:00
Mike McQuaid
d36e99c17c
GitHub Packages tweaks
- cleanup comments from #10938
- fix download URL
- remove incorrect comment
2021-03-30 08:42:15 +01:00