Utils::Cp: Remove copy
prefix from method name
As per review feedback: https://github.com/Homebrew/brew/pull/17373#pullrequestreview-2104523770 Co-authored-by: Mike McQuaid <mike@mikemcquaid.com>
This commit is contained in:
parent
d9239faad3
commit
b2ddeecdd9
@ -109,7 +109,7 @@ module Cask
|
||||
if target.writable?
|
||||
source.children.each { |child| FileUtils.move(child, target/child.basename) }
|
||||
else
|
||||
::Utils::Cp.copy_recursive_with_attributes(source.children, target, sudo: true, command:)
|
||||
::Utils::Cp.recursive_with_attributes(source.children, target, sudo: true, command:)
|
||||
end
|
||||
Quarantine.copy_xattrs(source, target, command:)
|
||||
source.rmtree
|
||||
@ -118,7 +118,7 @@ module Cask
|
||||
else
|
||||
# default sudo user isn't necessarily able to write to Homebrew's locations
|
||||
# e.g. with runas_default set in the sudoers (5) file.
|
||||
::Utils::Cp.copy_recursive_with_attributes(source, target, sudo: true, command:)
|
||||
::Utils::Cp.recursive_with_attributes(source, target, sudo: true, command:)
|
||||
source.rmtree
|
||||
end
|
||||
|
||||
@ -162,7 +162,7 @@ module Cask
|
||||
source.dirname.mkpath
|
||||
|
||||
# `Utils::Cp` preserves extended attributes between copies.
|
||||
::Utils::Cp.copy_recursive_with_attributes(target, source, sudo: !source.parent.writable?, command:)
|
||||
::Utils::Cp.recursive_with_attributes(target, source, sudo: !source.parent.writable?, command:)
|
||||
|
||||
delete(target, force:, command:, **options)
|
||||
end
|
||||
|
@ -227,7 +227,7 @@ class Pathname
|
||||
else
|
||||
dst.dirname.mkpath
|
||||
dst = yield(self, dst) if block_given?
|
||||
Utils::Cp.copy_with_attributes(self, dst)
|
||||
Utils::Cp.with_attributes(self, dst)
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -21,7 +21,7 @@ module UnpackStrategy
|
||||
|
||||
sig { override.params(unpack_dir: Pathname, basename: Pathname, verbose: T::Boolean).returns(T.untyped) }
|
||||
def extract_to_dir(unpack_dir, basename:, verbose:)
|
||||
Utils::Cp.copy_with_attributes path, unpack_dir/basename
|
||||
Utils::Cp.with_attributes path, unpack_dir/basename
|
||||
quiet_flags = verbose ? [] : ["-q"]
|
||||
system_command! "bunzip2",
|
||||
args: [*quiet_flags, unpack_dir/basename],
|
||||
|
@ -22,7 +22,7 @@ module UnpackStrategy
|
||||
sig { override.params(unpack_dir: Pathname, basename: Pathname, verbose: T::Boolean).returns(T.untyped) }
|
||||
def extract_to_dir(unpack_dir, basename:, verbose:)
|
||||
path.children.each do |child|
|
||||
Utils::Cp.copy_recursive_with_attributes (child.directory? && !child.symlink?) ? "#{child}/." : child,
|
||||
Utils::Cp.recursive_with_attributes (child.directory? && !child.symlink?) ? "#{child}/." : child,
|
||||
unpack_dir/child.basename,
|
||||
verbose:
|
||||
end
|
||||
|
@ -21,7 +21,7 @@ module UnpackStrategy
|
||||
|
||||
sig { override.params(unpack_dir: Pathname, basename: Pathname, verbose: T::Boolean).returns(T.untyped) }
|
||||
def extract_to_dir(unpack_dir, basename:, verbose:)
|
||||
Utils::Cp.copy_with_attributes path, unpack_dir/basename
|
||||
Utils::Cp.with_attributes path, unpack_dir/basename
|
||||
quiet_flags = verbose ? [] : ["-q"]
|
||||
system_command! "gunzip",
|
||||
args: [*quiet_flags, "-N", "--", unpack_dir/basename],
|
||||
|
@ -25,7 +25,7 @@ module UnpackStrategy
|
||||
|
||||
sig { override.params(unpack_dir: Pathname, basename: Pathname, verbose: T::Boolean).returns(T.untyped) }
|
||||
def extract_to_dir(unpack_dir, basename:, verbose:)
|
||||
Utils::Cp.copy_with_attributes path, unpack_dir/basename
|
||||
Utils::Cp.with_attributes path, unpack_dir/basename
|
||||
quiet_flags = verbose ? [] : ["-q"]
|
||||
system_command! "lzip",
|
||||
args: ["-d", *quiet_flags, unpack_dir/basename],
|
||||
|
@ -25,7 +25,7 @@ module UnpackStrategy
|
||||
|
||||
sig { override.params(unpack_dir: Pathname, basename: Pathname, verbose: T::Boolean).returns(T.untyped) }
|
||||
def extract_to_dir(unpack_dir, basename:, verbose:)
|
||||
Utils::Cp.copy_with_attributes path, unpack_dir/basename
|
||||
Utils::Cp.with_attributes path, unpack_dir/basename
|
||||
quiet_flags = verbose ? [] : ["-q"]
|
||||
system_command! "unlzma",
|
||||
args: [*quiet_flags, "--", unpack_dir/basename],
|
||||
|
@ -24,7 +24,7 @@ module UnpackStrategy
|
||||
|
||||
sig { override.params(unpack_dir: Pathname, basename: Pathname, verbose: T::Boolean).returns(T.untyped) }
|
||||
def extract_to_dir(unpack_dir, basename:, verbose: false)
|
||||
Utils::Cp.copy_with_attributes path, unpack_dir/basename.sub(/^[\da-f]{64}--/, ""), verbose:
|
||||
Utils::Cp.with_attributes path, unpack_dir/basename.sub(/^[\da-f]{64}--/, ""), verbose:
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -25,7 +25,7 @@ module UnpackStrategy
|
||||
|
||||
sig { override.params(unpack_dir: Pathname, basename: Pathname, verbose: T::Boolean).returns(T.untyped) }
|
||||
def extract_to_dir(unpack_dir, basename:, verbose:)
|
||||
Utils::Cp.copy_with_attributes path, unpack_dir/basename
|
||||
Utils::Cp.with_attributes path, unpack_dir/basename
|
||||
quiet_flags = verbose ? [] : ["-q"]
|
||||
system_command! "unxz",
|
||||
args: [*quiet_flags, "-T0", "--", unpack_dir/basename],
|
||||
|
@ -25,7 +25,7 @@ module UnpackStrategy
|
||||
|
||||
sig { override.params(unpack_dir: Pathname, basename: Pathname, verbose: T::Boolean).returns(T.untyped) }
|
||||
def extract_to_dir(unpack_dir, basename:, verbose:)
|
||||
Utils::Cp.copy_with_attributes path, unpack_dir/basename
|
||||
Utils::Cp.with_attributes path, unpack_dir/basename
|
||||
quiet_flags = verbose ? [] : ["-q"]
|
||||
system_command! "unzstd",
|
||||
args: [*quiet_flags, "-T0", "--rm", "--", unpack_dir/basename],
|
||||
|
@ -17,7 +17,7 @@ module Utils
|
||||
command: T.class_of(SystemCommand),
|
||||
).returns(SystemCommand::Result)
|
||||
}
|
||||
def copy_with_attributes(source, target, sudo: false, verbose: false, command: SystemCommand)
|
||||
def with_attributes(source, target, sudo: false, verbose: false, command: SystemCommand)
|
||||
# On macOS, `cp -p` guarantees to preserve extended attributes (including quarantine
|
||||
# information) in addition to file mode. Other implementations like coreutils does not
|
||||
# necessarily guarantee the same behavior, but that is fine because we don't really need to
|
||||
@ -34,7 +34,7 @@ module Utils
|
||||
command: T.class_of(SystemCommand),
|
||||
).returns(SystemCommand::Result)
|
||||
}
|
||||
def copy_recursive_with_attributes(source, target, sudo: false, verbose: false, command: SystemCommand)
|
||||
def recursive_with_attributes(source, target, sudo: false, verbose: false, command: SystemCommand)
|
||||
command.run! "cp", args: ["-pR", *extra_flags, *source, target], sudo:, verbose:
|
||||
end
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user