Utils::Cp: Rename to Utils::Copy

As per review feedback:

https://github.com/Homebrew/brew/pull/17373#discussion_r1633217748
This commit is contained in:
Daiki Mizukami 2024-06-11 07:53:47 +09:00
parent 4edbbfd794
commit 028cfe1ea6
No known key found for this signature in database
GPG Key ID: 10478E598B944AA2
14 changed files with 31 additions and 31 deletions

View File

@ -3,7 +3,7 @@
require "cask/artifact/relocated"
require "cask/quarantine"
require "utils/cp"
require "utils/copy"
module Cask
module Artifact
@ -109,7 +109,7 @@ module Cask
if target.writable?
source.children.each { |child| FileUtils.move(child, target/child.basename) }
else
::Utils::Cp.recursive_with_attributes(source.children, target, force_command: true, sudo: true, command:)
::Utils::Copy.recursive_with_attributes(source.children, target, force_command: true, 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.recursive_with_attributes(source, target, force_command: true, sudo: true, command:)
::Utils::Copy.recursive_with_attributes(source, target, force_command: true, sudo: true, command:)
source.rmtree
end
@ -161,7 +161,7 @@ module Cask
ohai "Backing #{self.class.english_name} '#{target.basename}' up to '#{source}'"
source.dirname.mkpath
::Utils::Cp.recursive_with_attributes(target, source, sudo: !source.parent.writable?, command:,
::Utils::Copy.recursive_with_attributes(target, source, sudo: !source.parent.writable?, command:,
# This is required to preserve extended attributes between copies.
force_command: true)

View File

@ -1,4 +1,4 @@
# typed: strict
# frozen_string_literal: true
require "extend/os/mac/utils/cp" if OS.mac?
require "extend/os/mac/utils/copy" if OS.mac?

View File

@ -2,7 +2,7 @@
# frozen_string_literal: true
module Utils
module Cp
module Copy
class << self
module MacOSOverride
private

View File

@ -6,7 +6,7 @@ require "resource"
require "metafiles"
require "extend/file/atomic"
require "system_command"
require "utils/cp"
require "utils/copy"
module DiskUsageExtension
sig { returns(Integer) }
@ -227,7 +227,7 @@ class Pathname
else
dst.dirname.mkpath
dst = yield(self, dst) if block_given?
Utils::Cp.with_attributes(self, dst)
Utils::Copy.with_attributes(self, dst)
end
end

View File

@ -1,9 +1,9 @@
# frozen_string_literal: true
require "system_command"
require "utils/cp"
require "utils/copy"
RSpec.describe Utils::Cp do
RSpec.describe Utils::Copy do
let(:path) { Pathname(Dir.mktmpdir) }
let(:source) { path/"source" }
let(:target) { path/"target" }

View File

@ -1,7 +1,7 @@
# typed: true
# frozen_string_literal: true
require "utils/cp"
require "utils/copy"
module UnpackStrategy
# Strategy for unpacking bzip2 archives.
@ -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.with_attributes path, unpack_dir/basename
Utils::Copy.with_attributes path, unpack_dir/basename
quiet_flags = verbose ? [] : ["-q"]
system_command! "bunzip2",
args: [*quiet_flags, unpack_dir/basename],

View File

@ -1,7 +1,7 @@
# typed: true
# frozen_string_literal: true
require "utils/cp"
require "utils/copy"
module UnpackStrategy
# Strategy for unpacking directories.
@ -22,10 +22,10 @@ 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.recursive_with_attributes (child.directory? && !child.symlink?) ? "#{child}/." : child,
unpack_dir/child.basename,
force_command: true,
verbose:
Utils::Copy.recursive_with_attributes (child.directory? && !child.symlink?) ? "#{child}/." : child,
unpack_dir/child.basename,
force_command: true,
verbose:
end
end
end

View File

@ -1,7 +1,7 @@
# typed: true
# frozen_string_literal: true
require "utils/cp"
require "utils/copy"
module UnpackStrategy
# Strategy for unpacking gzip archives.
@ -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.with_attributes path, unpack_dir/basename
Utils::Copy.with_attributes path, unpack_dir/basename
quiet_flags = verbose ? [] : ["-q"]
system_command! "gunzip",
args: [*quiet_flags, "-N", "--", unpack_dir/basename],

View File

@ -1,7 +1,7 @@
# typed: true
# frozen_string_literal: true
require "utils/cp"
require "utils/copy"
module UnpackStrategy
# Strategy for unpacking lzip archives.
@ -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.with_attributes path, unpack_dir/basename
Utils::Copy.with_attributes path, unpack_dir/basename
quiet_flags = verbose ? [] : ["-q"]
system_command! "lzip",
args: ["-d", *quiet_flags, unpack_dir/basename],

View File

@ -1,7 +1,7 @@
# typed: true
# frozen_string_literal: true
require "utils/cp"
require "utils/copy"
module UnpackStrategy
# Strategy for unpacking LZMA archives.
@ -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.with_attributes path, unpack_dir/basename
Utils::Copy.with_attributes path, unpack_dir/basename
quiet_flags = verbose ? [] : ["-q"]
system_command! "unlzma",
args: [*quiet_flags, "--", unpack_dir/basename],

View File

@ -1,7 +1,7 @@
# typed: true
# frozen_string_literal: true
require "utils/cp"
require "utils/copy"
module UnpackStrategy
# Strategy for unpacking uncompressed files.
@ -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.with_attributes path, unpack_dir/basename.sub(/^[\da-f]{64}--/, ""), verbose:
Utils::Copy.with_attributes path, unpack_dir/basename.sub(/^[\da-f]{64}--/, ""), verbose:
end
end
end

View File

@ -1,7 +1,7 @@
# typed: true
# frozen_string_literal: true
require "utils/cp"
require "utils/copy"
module UnpackStrategy
# Strategy for unpacking xz archives.
@ -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.with_attributes path, unpack_dir/basename
Utils::Copy.with_attributes path, unpack_dir/basename
quiet_flags = verbose ? [] : ["-q"]
system_command! "unxz",
args: [*quiet_flags, "-T0", "--", unpack_dir/basename],

View File

@ -1,7 +1,7 @@
# typed: true
# frozen_string_literal: true
require "utils/cp"
require "utils/copy"
module UnpackStrategy
# Strategy for unpacking zstd archives.
@ -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.with_attributes path, unpack_dir/basename
Utils::Copy.with_attributes path, unpack_dir/basename
quiet_flags = verbose ? [] : ["-q"]
system_command! "unzstd",
args: [*quiet_flags, "-T0", "--rm", "--", unpack_dir/basename],

View File

@ -1,13 +1,13 @@
# typed: true
# frozen_string_literal: true
require "extend/os/cp"
require "extend/os/copy"
require "fileutils"
require "system_command"
module Utils
# Helper functions for copying files.
module Cp
module Copy
class << self
sig {
params(