mirror of
https://github.com/Homebrew/brew.git
synced 2025-07-14 16:09:03 +08:00
Create Utils::Curl
module and explicitly include it.
This commit is contained in:
parent
318091cccc
commit
ff653571b1
@ -11,6 +11,8 @@ require "lock_file"
|
|||||||
require "mechanize/version"
|
require "mechanize/version"
|
||||||
require "mechanize/http/content_disposition_parser"
|
require "mechanize/http/content_disposition_parser"
|
||||||
|
|
||||||
|
require "utils/curl"
|
||||||
|
|
||||||
# @abstract Abstract superclass for all download strategies.
|
# @abstract Abstract superclass for all download strategies.
|
||||||
#
|
#
|
||||||
# @api private
|
# @api private
|
||||||
@ -328,6 +330,8 @@ end
|
|||||||
#
|
#
|
||||||
# @api public
|
# @api public
|
||||||
class CurlDownloadStrategy < AbstractFileDownloadStrategy
|
class CurlDownloadStrategy < AbstractFileDownloadStrategy
|
||||||
|
include Utils::Curl
|
||||||
|
|
||||||
attr_reader :mirrors
|
attr_reader :mirrors
|
||||||
|
|
||||||
def initialize(url, name, version, **meta)
|
def initialize(url, name, version, **meta)
|
||||||
|
@ -1,15 +0,0 @@
|
|||||||
# typed: strict
|
|
||||||
|
|
||||||
module SharedAudits
|
|
||||||
def github(user, repo)
|
|
||||||
end
|
|
||||||
|
|
||||||
def gitlab(user, repo)
|
|
||||||
end
|
|
||||||
|
|
||||||
def bitbucket(user, repo)
|
|
||||||
end
|
|
||||||
|
|
||||||
def curl_output(*args, secrets: [], **options)
|
|
||||||
end
|
|
||||||
end
|
|
@ -3,6 +3,13 @@
|
|||||||
|
|
||||||
require "open3"
|
require "open3"
|
||||||
|
|
||||||
|
module Utils
|
||||||
|
# Helper function for interacting with `curl`.
|
||||||
|
#
|
||||||
|
# @api private
|
||||||
|
module Curl
|
||||||
|
module_function
|
||||||
|
|
||||||
def curl_executable
|
def curl_executable
|
||||||
@curl ||= [
|
@curl ||= [
|
||||||
ENV["HOMEBREW_CURL"],
|
ENV["HOMEBREW_CURL"],
|
||||||
@ -47,7 +54,9 @@ def curl_args(*extra_args, show_output: false, user_agent: :default)
|
|||||||
args + extra_args
|
args + extra_args
|
||||||
end
|
end
|
||||||
|
|
||||||
def curl_with_workarounds(*args, secrets: nil, print_stdout: nil, print_stderr: nil, verbose: nil, env: {}, **options)
|
def curl_with_workarounds(
|
||||||
|
*args, secrets: nil, print_stdout: nil, print_stderr: nil, verbose: nil, env: {}, **options
|
||||||
|
)
|
||||||
command_options = {
|
command_options = {
|
||||||
secrets: secrets,
|
secrets: secrets,
|
||||||
print_stdout: print_stdout,
|
print_stdout: print_stdout,
|
||||||
@ -118,7 +127,9 @@ def curl_download(*args, to: nil, partial: true, **options)
|
|||||||
0
|
0
|
||||||
end
|
end
|
||||||
|
|
||||||
curl("--location", "--remote-time", "--continue-at", continue_at.to_s, "--output", destination, *args, **options)
|
curl(
|
||||||
|
"--location", "--remote-time", "--continue-at", continue_at.to_s, "--output", destination, *args, **options
|
||||||
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
def curl_output(*args, **options)
|
def curl_output(*args, **options)
|
||||||
@ -259,3 +270,8 @@ end
|
|||||||
def http_status_ok?(status)
|
def http_status_ok?(status)
|
||||||
(100..299).cover?(status.to_i)
|
(100..299).cover?(status.to_i)
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
# FIXME: Include `Utils::Curl` explicitly everywhere it is used.
|
||||||
|
include Utils::Curl # rubocop:disable Style/MixinUsage
|
||||||
|
@ -7,6 +7,9 @@ require "utils/curl"
|
|||||||
#
|
#
|
||||||
# @api private
|
# @api private
|
||||||
module SharedAudits
|
module SharedAudits
|
||||||
|
include Utils::Curl
|
||||||
|
extend Utils::Curl
|
||||||
|
|
||||||
module_function
|
module_function
|
||||||
|
|
||||||
def github_repo_data(user, repo)
|
def github_repo_data(user, repo)
|
||||||
|
@ -1,12 +1,15 @@
|
|||||||
# typed: true
|
# typed: true
|
||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
|
|
||||||
|
require "utils/curl"
|
||||||
require "utils/github"
|
require "utils/github"
|
||||||
|
|
||||||
# Helper module for updating SPDX license data.
|
# Helper module for updating SPDX license data.
|
||||||
#
|
#
|
||||||
# @api private
|
# @api private
|
||||||
module SPDX
|
module SPDX
|
||||||
|
extend Utils::Curl
|
||||||
|
|
||||||
module_function
|
module_function
|
||||||
|
|
||||||
DATA_PATH = (HOMEBREW_DATA_PATH/"spdx").freeze
|
DATA_PATH = (HOMEBREW_DATA_PATH/"spdx").freeze
|
||||||
|
Loading…
x
Reference in New Issue
Block a user