667 Commits

Author SHA1 Message Date
Bo Anderson
6cf18e3810
download_strategy: fix bad unescaping in basename parsing 2023-04-18 13:42:34 +01:00
Markus Reiter
fbf474a3fd
Add curl_head method. 2023-04-06 10:22:24 +02:00
Mike McQuaid
ec15acf7dc
Revert "Remove --request GET workaround for HEAD requests." 2023-03-31 09:07:02 +01:00
Markus Reiter
c876530eff
Remove --request GET workaround for HEAD requests. 2023-03-30 05:02:51 +02:00
Mike McQuaid
d3d372d6f5
download_strategy: use another blank. 2023-03-21 12:19:06 +00:00
Mike McQuaid
fd0b3e8035
download_strategy: use blank. 2023-03-21 12:18:17 +00:00
Bevan Kay
f197f164c8
download_strategy: fix case where filename cannot be parsed 2023-03-21 09:12:07 +11:00
Douglas Eichelberger
b8aa619f2f brew style --fix 2023-03-15 18:21:41 -07:00
Douglas Eichelberger
827fc87cde Enable more typing 2023-03-15 14:29:15 -07:00
Harry Marr
bd1d668e2e
Create .git/info dir if it doesn't exist 2023-03-13 09:22:09 -05:00
Mike McQuaid
97b66d3ae7
download_strategy: add another presence check. 2023-03-08 12:49:25 +00:00
Gibson Fahnestock
160e7da779
download_strategy: handle incorrectly quoted filename* headers
Some servers erroneously double-quote the filename in the filename*
header. This is (as far as I can tell from the spec) a bug in the
server, and should be fixed there.

In general though using `""` as the filename seems like behaviour worth
handling in brew anyway, as there may be other places where the parser
returns an empty string.

Co-authored-by: Mike McQuaid <mike@mikemcquaid.com>
2023-03-08 01:28:39 +00:00
Markus Reiter
4f04e9e599
Add signatures for extraction functions. 2023-02-22 22:15:53 +01:00
Mike McQuaid
d292dbdc2b
Revert "Fix permissions before moving extracted files." 2023-02-20 17:20:57 +00:00
Markus Reiter
7c5b6fd10d
Add signatures for extraction methods. 2023-02-19 19:29:21 +01:00
Nanda H Krishna
75045e91f8
brew style --fix 2023-02-06 13:50:39 -05:00
Mike McQuaid
6a25229567
brew style --fix 2023-01-02 19:18:51 +00:00
Frederick Zhang
c27eed4606
Curl: Fix following redirections when base changes
Update base URL when there is an absolute location, so that following
relative locations are considered relative to the new base.

Consider below cURL output for https://example_one.com:

    HTTP/1.1 302 Moved Temporarily
    Location: https://example_two.com

    HTTP/1.1 302 Moved Temporarily
    Location: /foo/

    HTTP/1.1 200 OK

The final URL should be https://example_two.com/foo/ rather than
https://example_one.com/foo/.
2022-11-30 01:32:24 +11:00
hyuraku
43eca95ce4 reset require-utils/github location 2022-11-07 23:12:27 +09:00
hyuraku
80592f6013 move require-utils/github location 2022-11-06 23:32:46 +09:00
hyuraku
3f3a0b5469 move two methods from download_storategy to utils/github 2022-11-06 18:12:43 +09:00
Harry Marr
b11df3bef8
Singularise only_paths (now only_path) 2022-10-22 10:53:02 -04:00
Harry Marr
6219cd0a92
Use different cache tag for sparse checkouts 2022-10-20 15:47:26 -04:00
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