diff options
| author | Markus Reiter | 2017-08-08 19:26:33 +0200 |
|---|---|---|
| committer | GitHub | 2017-08-08 19:26:33 +0200 |
| commit | 1a30c165bfb82ae846e64c508f06455e0d3f285e (patch) | |
| tree | ab63c314bed39e41dfe47273902ca14c15515c23 /Library/Homebrew/dev-cmd | |
| parent | 93051b27d6886dae6df01544c86df579f21f6410 (diff) | |
| parent | ae4bafdb365cfa380d129b0a03bd99a1e4d960a4 (diff) | |
| download | brew-1a30c165bfb82ae846e64c508f06455e0d3f285e.tar.bz2 | |
Merge pull request #3026 from reitermarkus/refactor-download-strategies
Refactor download strategies.
Diffstat (limited to 'Library/Homebrew/dev-cmd')
| -rw-r--r-- | Library/Homebrew/dev-cmd/audit.rb | 8 | ||||
| -rw-r--r-- | Library/Homebrew/dev-cmd/mirror.rb | 10 | ||||
| -rw-r--r-- | Library/Homebrew/dev-cmd/pull.rb | 16 |
3 files changed, 16 insertions, 18 deletions
diff --git a/Library/Homebrew/dev-cmd/audit.rb b/Library/Homebrew/dev-cmd/audit.rb index 1f07fa89e..b3e0785a5 100644 --- a/Library/Homebrew/dev-cmd/audit.rb +++ b/Library/Homebrew/dev-cmd/audit.rb @@ -242,12 +242,10 @@ class FormulaAuditor def self.http_content_headers_and_checksum(url, hash_needed: false, user_agent: :default) max_time = hash_needed ? "600" : "25" - args = curl_args( - extra_args: ["--connect-timeout", "15", "--include", "--max-time", max_time, url], - show_output: true, - user_agent: user_agent, + output, = curl_output( + "--connect-timeout", "15", "--include", "--max-time", max_time, "--location", url, + user_agent: user_agent ) - output = Open3.popen3(*args) { |_, stdout, _, _| stdout.read } status_code = :unknown while status_code == :unknown || status_code.to_s.start_with?("3") diff --git a/Library/Homebrew/dev-cmd/mirror.rb b/Library/Homebrew/dev-cmd/mirror.rb index e2492203d..6445bc34c 100644 --- a/Library/Homebrew/dev-cmd/mirror.rb +++ b/Library/Homebrew/dev-cmd/mirror.rb @@ -25,9 +25,9 @@ module Homebrew "public_download_numbers": true, "public_stats": true} EOS - curl "--silent", "--fail", "-u#{bintray_user}:#{bintray_key}", - "-H", "Content-Type: application/json", - "-d", package_blob, bintray_repo_url + curl "--silent", "--fail", "--user", "#{bintray_user}:#{bintray_key}", + "--header", "Content-Type: application/json", + "--data", package_blob, bintray_repo_url puts end @@ -40,8 +40,8 @@ module Homebrew content_url = "https://api.bintray.com/content/homebrew/mirror" content_url += "/#{bintray_package}/#{f.pkg_version}/#{filename}" content_url += "?publish=1" - curl "--silent", "--fail", "-u#{bintray_user}:#{bintray_key}", - "-T", download, content_url + curl "--silent", "--fail", "--user", "#{bintray_user}:#{bintray_key}", + "--upload-file", download, content_url puts ohai "Mirrored #{filename}!" end diff --git a/Library/Homebrew/dev-cmd/pull.rb b/Library/Homebrew/dev-cmd/pull.rb index 9681bb2bc..dd2bc6270 100644 --- a/Library/Homebrew/dev-cmd/pull.rb +++ b/Library/Homebrew/dev-cmd/pull.rb @@ -228,7 +228,7 @@ module Homebrew "https://github.com/BrewTestBot/homebrew-#{tap.repo}/compare/homebrew:master...pr-#{issue}" end - curl "--silent", "--fail", "-o", "/dev/null", "-I", bottle_commit_url + curl "--silent", "--fail", "--output", "/dev/null", "--head", bottle_commit_url safe_system "git", "checkout", "--quiet", "-B", bottle_branch, orig_revision pull_patch bottle_commit_url, "bottle commit" @@ -303,7 +303,7 @@ module Homebrew extra_msg = @description ? "(#{@description})" : nil ohai "Fetching patch #{extra_msg}" puts "Patch: #{patch_url}" - curl patch_url, "-s", "-o", patchpath + curl_download patch_url, to: patchpath end def apply_patch @@ -433,10 +433,10 @@ module Homebrew end version = info.pkg_version ohai "Publishing on Bintray: #{package} #{version}" - curl "-w", '\n', "--silent", "--fail", - "-u#{creds[:user]}:#{creds[:key]}", "-X", "POST", - "-H", "Content-Type: application/json", - "-d", '{"publish_wait_for_secs": 0}', + curl "--write-out", '\n', "--silent", "--fail", + "--user", "#{creds[:user]}:#{creds[:key]}", "--request", "POST", + "--header", "Content-Type: application/json", + "--data", '{"publish_wait_for_secs": 0}', "https://api.bintray.com/content/homebrew/#{repo}/#{package}/#{version}/publish" true rescue => e @@ -587,7 +587,7 @@ module Homebrew # We're in the cache; make sure to force re-download loop do begin - curl url, "-o", filename + curl_download url, to: filename break rescue if retry_count >= max_curl_retries @@ -606,7 +606,7 @@ module Homebrew end def check_bintray_mirror(name, url) - headers = curl_output("--connect-timeout", "15", "--head", url)[0] + headers, = curl_output("--connect-timeout", "15", "--location", "--head", url) status_code = headers.scan(%r{^HTTP\/.* (\d+)}).last.first return if status_code.start_with?("2") opoo "The Bintray mirror #{url} is not reachable (HTTP status code #{status_code})." |
