mirror of
https://github.com/Homebrew/brew.git
synced 2025-07-14 16:09:03 +08:00
Merge pull request #16540 from dduugg/systemcommand-scope
Require SystemCommand only where needed
This commit is contained in:
commit
b33373adb5
@ -7,6 +7,7 @@ require "utils/user"
|
|||||||
require "cask/artifact/abstract_artifact"
|
require "cask/artifact/abstract_artifact"
|
||||||
require "cask/pkg"
|
require "cask/pkg"
|
||||||
require "extend/hash/keys"
|
require "extend/hash/keys"
|
||||||
|
require "system_command"
|
||||||
|
|
||||||
module Cask
|
module Cask
|
||||||
module Artifact
|
module Artifact
|
||||||
@ -14,6 +15,8 @@ module Cask
|
|||||||
#
|
#
|
||||||
# @api private
|
# @api private
|
||||||
class AbstractUninstall < AbstractArtifact
|
class AbstractUninstall < AbstractArtifact
|
||||||
|
include SystemCommand::Mixin
|
||||||
|
|
||||||
ORDERED_DIRECTIVES = [
|
ORDERED_DIRECTIVES = [
|
||||||
:early_script,
|
:early_script,
|
||||||
:launchctl,
|
:launchctl,
|
||||||
|
@ -17,6 +17,7 @@ module Cask
|
|||||||
#
|
#
|
||||||
# @api private
|
# @api private
|
||||||
class Audit
|
class Audit
|
||||||
|
include SystemCommand::Mixin
|
||||||
include ::Utils::Curl
|
include ::Utils::Curl
|
||||||
extend Attrable
|
extend Attrable
|
||||||
|
|
||||||
|
@ -3,12 +3,15 @@
|
|||||||
|
|
||||||
require "development_tools"
|
require "development_tools"
|
||||||
require "cask/exceptions"
|
require "cask/exceptions"
|
||||||
|
require "system_command"
|
||||||
|
|
||||||
module Cask
|
module Cask
|
||||||
# Helper module for quarantining files.
|
# Helper module for quarantining files.
|
||||||
#
|
#
|
||||||
# @api private
|
# @api private
|
||||||
module Quarantine
|
module Quarantine
|
||||||
|
extend SystemCommand::Mixin
|
||||||
|
|
||||||
QUARANTINE_ATTRIBUTE = "com.apple.quarantine"
|
QUARANTINE_ATTRIBUTE = "com.apple.quarantine"
|
||||||
|
|
||||||
QUARANTINE_SCRIPT = (HOMEBREW_LIBRARY_PATH/"cask/utils/quarantine.swift").freeze
|
QUARANTINE_SCRIPT = (HOMEBREW_LIBRARY_PATH/"cask/utils/quarantine.swift").freeze
|
||||||
|
@ -11,6 +11,7 @@ require "utils/shell"
|
|||||||
require "system_config"
|
require "system_config"
|
||||||
require "cask/caskroom"
|
require "cask/caskroom"
|
||||||
require "cask/quarantine"
|
require "cask/quarantine"
|
||||||
|
require "system_command"
|
||||||
|
|
||||||
module Homebrew
|
module Homebrew
|
||||||
# Module containing diagnostic checks.
|
# Module containing diagnostic checks.
|
||||||
@ -48,6 +49,8 @@ module Homebrew
|
|||||||
|
|
||||||
# Diagnostic checks.
|
# Diagnostic checks.
|
||||||
class Checks
|
class Checks
|
||||||
|
include SystemCommand::Mixin
|
||||||
|
|
||||||
def initialize(verbose: true)
|
def initialize(verbose: true)
|
||||||
@verbose = verbose
|
@verbose = verbose
|
||||||
end
|
end
|
||||||
|
@ -7,6 +7,7 @@ require "unpack_strategy"
|
|||||||
require "lazy_object"
|
require "lazy_object"
|
||||||
require "cgi"
|
require "cgi"
|
||||||
require "lock_file"
|
require "lock_file"
|
||||||
|
require "system_command"
|
||||||
|
|
||||||
# Need to define this before requiring Mechanize to avoid:
|
# Need to define this before requiring Mechanize to avoid:
|
||||||
# uninitialized constant Mechanize
|
# uninitialized constant Mechanize
|
||||||
@ -28,6 +29,7 @@ class AbstractDownloadStrategy
|
|||||||
extend Forwardable
|
extend Forwardable
|
||||||
include FileUtils
|
include FileUtils
|
||||||
include Context
|
include Context
|
||||||
|
include SystemCommand::Mixin
|
||||||
|
|
||||||
# Extension for bottle downloads.
|
# Extension for bottle downloads.
|
||||||
#
|
#
|
||||||
|
@ -1,7 +1,11 @@
|
|||||||
# typed: true
|
# typed: true
|
||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
|
|
||||||
|
require "system_command"
|
||||||
|
|
||||||
class Keg
|
class Keg
|
||||||
|
include SystemCommand::Mixin
|
||||||
|
|
||||||
GENERIC_KEG_LINK_DIRECTORIES = (remove_const :KEG_LINK_DIRECTORIES).freeze
|
GENERIC_KEG_LINK_DIRECTORIES = (remove_const :KEG_LINK_DIRECTORIES).freeze
|
||||||
KEG_LINK_DIRECTORIES = (GENERIC_KEG_LINK_DIRECTORIES + ["Frameworks"]).freeze
|
KEG_LINK_DIRECTORIES = (GENERIC_KEG_LINK_DIRECTORIES + ["Frameworks"]).freeze
|
||||||
GENERIC_MUST_EXIST_SUBDIRECTORIES = (remove_const :MUST_EXIST_SUBDIRECTORIES).freeze
|
GENERIC_MUST_EXIST_SUBDIRECTORIES = (remove_const :MUST_EXIST_SUBDIRECTORIES).freeze
|
||||||
|
@ -5,6 +5,7 @@ require "context"
|
|||||||
require "resource"
|
require "resource"
|
||||||
require "metafiles"
|
require "metafiles"
|
||||||
require "extend/file/atomic"
|
require "extend/file/atomic"
|
||||||
|
require "system_command"
|
||||||
|
|
||||||
module DiskUsageExtension
|
module DiskUsageExtension
|
||||||
sig { returns(Integer) }
|
sig { returns(Integer) }
|
||||||
@ -77,6 +78,7 @@ end
|
|||||||
# Homebrew extends Ruby's `Pathname` to make our code more readable.
|
# Homebrew extends Ruby's `Pathname` to make our code more readable.
|
||||||
# @see https://ruby-doc.org/stdlib-2.6.3/libdoc/pathname/rdoc/Pathname.html Ruby's Pathname API
|
# @see https://ruby-doc.org/stdlib-2.6.3/libdoc/pathname/rdoc/Pathname.html Ruby's Pathname API
|
||||||
class Pathname
|
class Pathname
|
||||||
|
include SystemCommand::Mixin
|
||||||
include DiskUsageExtension
|
include DiskUsageExtension
|
||||||
|
|
||||||
# Moves a file from the original location to the {Pathname}'s.
|
# Moves a file from the original location to the {Pathname}'s.
|
||||||
|
@ -5,12 +5,14 @@ require "utils/curl"
|
|||||||
require "json"
|
require "json"
|
||||||
require "zlib"
|
require "zlib"
|
||||||
require "extend/hash/keys"
|
require "extend/hash/keys"
|
||||||
|
require "system_command"
|
||||||
|
|
||||||
# GitHub Packages client.
|
# GitHub Packages client.
|
||||||
#
|
#
|
||||||
# @api private
|
# @api private
|
||||||
class GitHubPackages
|
class GitHubPackages
|
||||||
include Context
|
include Context
|
||||||
|
include SystemCommand::Mixin
|
||||||
|
|
||||||
URL_DOMAIN = "ghcr.io"
|
URL_DOMAIN = "ghcr.io"
|
||||||
URL_PREFIX = "https://#{URL_DOMAIN}/v2/".freeze
|
URL_PREFIX = "https://#{URL_DOMAIN}/v2/".freeze
|
||||||
|
@ -137,7 +137,6 @@ rescue
|
|||||||
nil
|
nil
|
||||||
end.compact.freeze
|
end.compact.freeze
|
||||||
|
|
||||||
require "system_command"
|
|
||||||
require "exceptions"
|
require "exceptions"
|
||||||
require "utils"
|
require "utils"
|
||||||
|
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
|
|
||||||
require "open3"
|
require "open3"
|
||||||
|
require "system_command"
|
||||||
|
|
||||||
module Homebrew
|
module Homebrew
|
||||||
module Livecheck
|
module Livecheck
|
||||||
@ -24,6 +25,8 @@ module Homebrew
|
|||||||
#
|
#
|
||||||
# @api public
|
# @api public
|
||||||
class Git
|
class Git
|
||||||
|
extend SystemCommand::Mixin
|
||||||
|
|
||||||
# The priority of the strategy on an informal scale of 1 to 10 (from
|
# The priority of the strategy on an informal scale of 1 to 10 (from
|
||||||
# lowest to highest).
|
# lowest to highest).
|
||||||
PRIORITY = 8
|
PRIORITY = 8
|
||||||
|
@ -1,6 +1,8 @@
|
|||||||
# typed: true
|
# typed: true
|
||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
|
|
||||||
|
require "system_command"
|
||||||
|
|
||||||
module OS
|
module OS
|
||||||
module Mac
|
module Mac
|
||||||
# Class representing a macOS SDK.
|
# Class representing a macOS SDK.
|
||||||
@ -32,6 +34,7 @@ module OS
|
|||||||
# @api private
|
# @api private
|
||||||
class BaseSDKLocator
|
class BaseSDKLocator
|
||||||
extend T::Helpers
|
extend T::Helpers
|
||||||
|
include SystemCommand::Mixin
|
||||||
|
|
||||||
abstract!
|
abstract!
|
||||||
|
|
||||||
|
@ -3,6 +3,7 @@
|
|||||||
|
|
||||||
require "formula"
|
require "formula"
|
||||||
require "cask/cask_loader"
|
require "cask/cask_loader"
|
||||||
|
require "system_command"
|
||||||
|
|
||||||
# Helper module for validating syntax in taps.
|
# Helper module for validating syntax in taps.
|
||||||
#
|
#
|
||||||
@ -10,6 +11,7 @@ require "cask/cask_loader"
|
|||||||
module Readall
|
module Readall
|
||||||
class << self
|
class << self
|
||||||
include Cachable
|
include Cachable
|
||||||
|
include SystemCommand::Mixin
|
||||||
|
|
||||||
# TODO: remove this once the `MacOS` module is undefined on Linux
|
# TODO: remove this once the `MacOS` module is undefined on Linux
|
||||||
MACOS_MODULE_REGEX = /\b(MacOS|OS::Mac)(\.|::)\b/
|
MACOS_MODULE_REGEX = /\b(MacOS|OS::Mac)(\.|::)\b/
|
||||||
|
@ -3,12 +3,15 @@
|
|||||||
|
|
||||||
require "shellwords"
|
require "shellwords"
|
||||||
require "source_location"
|
require "source_location"
|
||||||
|
require "system_command"
|
||||||
|
|
||||||
module Homebrew
|
module Homebrew
|
||||||
# Helper module for running RuboCop.
|
# Helper module for running RuboCop.
|
||||||
#
|
#
|
||||||
# @api private
|
# @api private
|
||||||
module Style
|
module Style
|
||||||
|
extend SystemCommand::Mixin
|
||||||
|
|
||||||
# Checks style for a list of files, printing simple RuboCop output.
|
# Checks style for a list of files, printing simple RuboCop output.
|
||||||
# Returns true if violations were found, false otherwise.
|
# Returns true if violations were found, false otherwise.
|
||||||
def self.check_style_and_print(files, **options)
|
def self.check_style_and_print(files, **options)
|
||||||
|
@ -6,6 +6,7 @@ require "open3"
|
|||||||
require "plist"
|
require "plist"
|
||||||
require "shellwords"
|
require "shellwords"
|
||||||
|
|
||||||
|
require "context"
|
||||||
require "extend/io"
|
require "extend/io"
|
||||||
require "utils/timer"
|
require "utils/timer"
|
||||||
|
|
||||||
@ -405,7 +406,3 @@ class SystemCommand
|
|||||||
private :warn_plist_garbage
|
private :warn_plist_garbage
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
# Make `system_command` available everywhere.
|
|
||||||
# FIXME: Include this explicitly only where it is needed.
|
|
||||||
include SystemCommand::Mixin # rubocop:disable Style/MixinUsage
|
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
|
|
||||||
|
require "system_command"
|
||||||
|
|
||||||
describe SystemCommand do
|
describe SystemCommand do
|
||||||
describe "#initialize" do
|
describe "#initialize" do
|
||||||
subject(:command) do
|
subject(:command) do
|
||||||
@ -284,7 +286,7 @@ describe SystemCommand do
|
|||||||
|
|
||||||
it 'does not format `stderr` when it starts with \r' do
|
it 'does not format `stderr` when it starts with \r' do
|
||||||
expect do
|
expect do
|
||||||
system_command \
|
Class.new.extend(SystemCommand::Mixin).system_command \
|
||||||
"bash",
|
"bash",
|
||||||
args: [
|
args: [
|
||||||
"-c",
|
"-c",
|
||||||
@ -308,7 +310,7 @@ describe SystemCommand do
|
|||||||
end
|
end
|
||||||
|
|
||||||
it "does not interpret the executable as a shell line" do
|
it "does not interpret the executable as a shell line" do
|
||||||
expect(system_command(executable)).to be_a_success
|
expect(Class.new.extend(SystemCommand::Mixin).system_command(executable)).to be_a_success
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -2,14 +2,18 @@
|
|||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
|
|
||||||
require "tempfile"
|
require "tempfile"
|
||||||
|
require "system_command"
|
||||||
|
|
||||||
module UnpackStrategy
|
module UnpackStrategy
|
||||||
# Strategy for unpacking disk images.
|
# Strategy for unpacking disk images.
|
||||||
class Dmg
|
class Dmg
|
||||||
|
extend SystemCommand::Mixin
|
||||||
include UnpackStrategy
|
include UnpackStrategy
|
||||||
|
|
||||||
# Helper module for listing the contents of a volume mounted from a disk image.
|
# Helper module for listing the contents of a volume mounted from a disk image.
|
||||||
module Bom
|
module Bom
|
||||||
|
extend SystemCommand::Mixin
|
||||||
|
|
||||||
DMG_METADATA = Set.new(%w[
|
DMG_METADATA = Set.new(%w[
|
||||||
.background
|
.background
|
||||||
.com.apple.timemachine.donotpresent
|
.com.apple.timemachine.donotpresent
|
||||||
|
@ -4,6 +4,7 @@
|
|||||||
require "bundle_version"
|
require "bundle_version"
|
||||||
require "cask/cask"
|
require "cask/cask"
|
||||||
require "cask/installer"
|
require "cask/installer"
|
||||||
|
require "system_command"
|
||||||
|
|
||||||
module Homebrew
|
module Homebrew
|
||||||
# Check unversioned casks for updates by extracting their
|
# Check unversioned casks for updates by extracting their
|
||||||
@ -11,6 +12,8 @@ module Homebrew
|
|||||||
#
|
#
|
||||||
# @api private
|
# @api private
|
||||||
class UnversionedCaskChecker
|
class UnversionedCaskChecker
|
||||||
|
include SystemCommand::Mixin
|
||||||
|
|
||||||
sig { returns(Cask::Cask) }
|
sig { returns(Cask::Cask) }
|
||||||
attr_reader :cask
|
attr_reader :cask
|
||||||
|
|
||||||
|
@ -4,12 +4,16 @@
|
|||||||
require "open3"
|
require "open3"
|
||||||
|
|
||||||
require "utils/timer"
|
require "utils/timer"
|
||||||
|
require "system_command"
|
||||||
|
|
||||||
module Utils
|
module Utils
|
||||||
# Helper function for interacting with `curl`.
|
# Helper function for interacting with `curl`.
|
||||||
#
|
#
|
||||||
# @api private
|
# @api private
|
||||||
module Curl
|
module Curl
|
||||||
|
include SystemCommand::Mixin
|
||||||
|
extend SystemCommand::Mixin
|
||||||
|
|
||||||
# This regex is used to extract the part of an ETag within quotation marks,
|
# This regex is used to extract the part of an ETag within quotation marks,
|
||||||
# ignoring any leading weak validator indicator (`W/`). This simplifies
|
# ignoring any leading weak validator indicator (`W/`). This simplifies
|
||||||
# ETag comparison in `#curl_check_http_content`.
|
# ETag comparison in `#curl_check_http_content`.
|
||||||
|
@ -2,5 +2,4 @@
|
|||||||
|
|
||||||
module Utils::Curl
|
module Utils::Curl
|
||||||
include Kernel
|
include Kernel
|
||||||
requires_ancestor { SystemCommand::Mixin }
|
|
||||||
end
|
end
|
||||||
|
@ -1,12 +1,16 @@
|
|||||||
# typed: true
|
# typed: true
|
||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
|
|
||||||
|
require "system_command"
|
||||||
|
|
||||||
module Utils
|
module Utils
|
||||||
# Helper functions for querying Git information.
|
# Helper functions for querying Git information.
|
||||||
#
|
#
|
||||||
# @see GitRepository
|
# @see GitRepository
|
||||||
# @api private
|
# @api private
|
||||||
module Git
|
module Git
|
||||||
|
extend SystemCommand::Mixin
|
||||||
|
|
||||||
def self.available?
|
def self.available?
|
||||||
version.present?
|
version.present?
|
||||||
end
|
end
|
||||||
|
@ -11,7 +11,7 @@ require "system_command"
|
|||||||
#
|
#
|
||||||
# @api private
|
# @api private
|
||||||
module GitHub
|
module GitHub
|
||||||
include SystemCommand::Mixin
|
extend SystemCommand::Mixin
|
||||||
|
|
||||||
def self.check_runs(repo: nil, commit: nil, pull_request: nil)
|
def self.check_runs(repo: nil, commit: nil, pull_request: nil)
|
||||||
if pull_request
|
if pull_request
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
# typed: true
|
# typed: true
|
||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
|
|
||||||
|
require "system_command"
|
||||||
require "tempfile"
|
require "tempfile"
|
||||||
require "utils/shell"
|
require "utils/shell"
|
||||||
require "utils/formatter"
|
require "utils/formatter"
|
||||||
@ -32,6 +33,8 @@ module GitHub
|
|||||||
#
|
#
|
||||||
# @api private
|
# @api private
|
||||||
module API
|
module API
|
||||||
|
extend SystemCommand::Mixin
|
||||||
|
|
||||||
# Generic API error.
|
# Generic API error.
|
||||||
class Error < RuntimeError
|
class Error < RuntimeError
|
||||||
attr_reader :github_message
|
attr_reader :github_message
|
||||||
|
@ -9,6 +9,8 @@ module Utils
|
|||||||
# @api private
|
# @api private
|
||||||
module Tar
|
module Tar
|
||||||
class << self
|
class << self
|
||||||
|
include SystemCommand::Mixin
|
||||||
|
|
||||||
TAR_FILE_EXTENSIONS = %w[.tar .tb2 .tbz .tbz2 .tgz .tlz .txz .tZ].freeze
|
TAR_FILE_EXTENSIONS = %w[.tar .tb2 .tbz .tbz2 .tgz .tlz .txz .tZ].freeze
|
||||||
|
|
||||||
def available?
|
def available?
|
||||||
|
Loading…
x
Reference in New Issue
Block a user