Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Retry curl requests 3 times by default. #7196

Merged
merged 1 commit into from
Mar 20, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions Library/Homebrew/manpages/brew.1.md.erb
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,7 @@ Note that environment variables must have a value set to be detected. For exampl

* `HOMEBREW_CURL_RETRIES`:
If set, Homebrew will pass the given retry count to `--retry` when invoking `curl`(1).
By default, `curl`(1) is invoked with `--retry 3`.

* `HOMEBREW_DEBUG`:
If set, any commands that can emit debugging information will do so.
Expand Down
8 changes: 6 additions & 2 deletions Library/Homebrew/test/utils/curl_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,13 @@
expect(curl_args("foo").first).not_to eq("-q")
end

it "returns --retry when HOMEBREW_CURL_RETRIES is set" do
ENV["HOMEBREW_CURL_RETRIES"] = "3"
it "uses `--retry 3` when HOMEBREW_CURL_RETRIES is unset" do
expect(curl_args("foo").join(" ")).to include("--retry 3")
end

it "uses the given value for `--retry` when HOMEBREW_CURL_RETRIES is set" do
ENV["HOMEBREW_CURL_RETRIES"] = "10"
expect(curl_args("foo").join(" ")).to include("--retry 10")
end
end
end
3 changes: 2 additions & 1 deletion Library/Homebrew/utils/curl.rb
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@ def curl_args(*extra_args, show_output: false, user_agent: :default)
args << "--silent" unless $stdout.tty?
end

args << "--retry" << ENV["HOMEBREW_CURL_RETRIES"] if ENV["HOMEBREW_CURL_RETRIES"]
# When changing the default value, the manpage has to be updated.
args << "--retry" << (ENV["HOMEBREW_CURL_RETRIES"] || "3")

args + extra_args
end
Expand Down
1 change: 1 addition & 0 deletions docs/Manpage.md
Original file line number Diff line number Diff line change
Expand Up @@ -1200,6 +1200,7 @@ Note that environment variables must have a value set to be detected. For exampl

* `HOMEBREW_CURL_RETRIES`:
If set, Homebrew will pass the given retry count to `--retry` when invoking `curl`(1).
By default, `curl`(1) is invoked with `--retry 3`.

* `HOMEBREW_DEBUG`:
If set, any commands that can emit debugging information will do so.
Expand Down
2 changes: 1 addition & 1 deletion manpages/brew.1
Original file line number Diff line number Diff line change
Expand Up @@ -1496,7 +1496,7 @@ If set, Homebrew will pass \fB\-\-verbose\fR when invoking \fBcurl\fR(1)\.
.
.TP
\fBHOMEBREW_CURL_RETRIES\fR
If set, Homebrew will pass the given retry count to \fB\-\-retry\fR when invoking \fBcurl\fR(1)\.
If set, Homebrew will pass the given retry count to \fB\-\-retry\fR when invoking \fBcurl\fR(1)\. By default, \fBcurl\fR(1) is invoked with \fB\-\-retry 3\fR\.
.
.TP
\fBHOMEBREW_DEBUG\fR
Expand Down