Utils::Cp: Rename to Utils::Copy
As per review feedback: https://github.com/Homebrew/brew/pull/17373#discussion_r1633217748
This commit is contained in:
parent
4edbbfd794
commit
028cfe1ea6
@ -3,7 +3,7 @@
|
|||||||
|
|
||||||
require "cask/artifact/relocated"
|
require "cask/artifact/relocated"
|
||||||
require "cask/quarantine"
|
require "cask/quarantine"
|
||||||
require "utils/cp"
|
require "utils/copy"
|
||||||
|
|
||||||
module Cask
|
module Cask
|
||||||
module Artifact
|
module Artifact
|
||||||
@ -109,7 +109,7 @@ module Cask
|
|||||||
if target.writable?
|
if target.writable?
|
||||||
source.children.each { |child| FileUtils.move(child, target/child.basename) }
|
source.children.each { |child| FileUtils.move(child, target/child.basename) }
|
||||||
else
|
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
|
end
|
||||||
Quarantine.copy_xattrs(source, target, command:)
|
Quarantine.copy_xattrs(source, target, command:)
|
||||||
source.rmtree
|
source.rmtree
|
||||||
@ -118,7 +118,7 @@ module Cask
|
|||||||
else
|
else
|
||||||
# default sudo user isn't necessarily able to write to Homebrew's locations
|
# default sudo user isn't necessarily able to write to Homebrew's locations
|
||||||
# e.g. with runas_default set in the sudoers (5) file.
|
# 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
|
source.rmtree
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -161,7 +161,7 @@ module Cask
|
|||||||
ohai "Backing #{self.class.english_name} '#{target.basename}' up to '#{source}'"
|
ohai "Backing #{self.class.english_name} '#{target.basename}' up to '#{source}'"
|
||||||
source.dirname.mkpath
|
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.
|
# This is required to preserve extended attributes between copies.
|
||||||
force_command: true)
|
force_command: true)
|
||||||
|
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
# typed: strict
|
# typed: strict
|
||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
|
|
||||||
require "extend/os/mac/utils/cp" if OS.mac?
|
require "extend/os/mac/utils/copy" if OS.mac?
|
||||||
@ -2,7 +2,7 @@
|
|||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
|
|
||||||
module Utils
|
module Utils
|
||||||
module Cp
|
module Copy
|
||||||
class << self
|
class << self
|
||||||
module MacOSOverride
|
module MacOSOverride
|
||||||
private
|
private
|
||||||
@ -6,7 +6,7 @@ require "resource"
|
|||||||
require "metafiles"
|
require "metafiles"
|
||||||
require "extend/file/atomic"
|
require "extend/file/atomic"
|
||||||
require "system_command"
|
require "system_command"
|
||||||
require "utils/cp"
|
require "utils/copy"
|
||||||
|
|
||||||
module DiskUsageExtension
|
module DiskUsageExtension
|
||||||
sig { returns(Integer) }
|
sig { returns(Integer) }
|
||||||
@ -227,7 +227,7 @@ class Pathname
|
|||||||
else
|
else
|
||||||
dst.dirname.mkpath
|
dst.dirname.mkpath
|
||||||
dst = yield(self, dst) if block_given?
|
dst = yield(self, dst) if block_given?
|
||||||
Utils::Cp.with_attributes(self, dst)
|
Utils::Copy.with_attributes(self, dst)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@ -1,9 +1,9 @@
|
|||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
|
|
||||||
require "system_command"
|
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(:path) { Pathname(Dir.mktmpdir) }
|
||||||
let(:source) { path/"source" }
|
let(:source) { path/"source" }
|
||||||
let(:target) { path/"target" }
|
let(:target) { path/"target" }
|
||||||
@ -1,7 +1,7 @@
|
|||||||
# typed: true
|
# typed: true
|
||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
|
|
||||||
require "utils/cp"
|
require "utils/copy"
|
||||||
|
|
||||||
module UnpackStrategy
|
module UnpackStrategy
|
||||||
# Strategy for unpacking bzip2 archives.
|
# 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) }
|
sig { override.params(unpack_dir: Pathname, basename: Pathname, verbose: T::Boolean).returns(T.untyped) }
|
||||||
def extract_to_dir(unpack_dir, basename:, verbose:)
|
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"]
|
quiet_flags = verbose ? [] : ["-q"]
|
||||||
system_command! "bunzip2",
|
system_command! "bunzip2",
|
||||||
args: [*quiet_flags, unpack_dir/basename],
|
args: [*quiet_flags, unpack_dir/basename],
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
# typed: true
|
# typed: true
|
||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
|
|
||||||
require "utils/cp"
|
require "utils/copy"
|
||||||
|
|
||||||
module UnpackStrategy
|
module UnpackStrategy
|
||||||
# Strategy for unpacking directories.
|
# Strategy for unpacking directories.
|
||||||
@ -22,10 +22,10 @@ module UnpackStrategy
|
|||||||
sig { override.params(unpack_dir: Pathname, basename: Pathname, verbose: T::Boolean).returns(T.untyped) }
|
sig { override.params(unpack_dir: Pathname, basename: Pathname, verbose: T::Boolean).returns(T.untyped) }
|
||||||
def extract_to_dir(unpack_dir, basename:, verbose:)
|
def extract_to_dir(unpack_dir, basename:, verbose:)
|
||||||
path.children.each do |child|
|
path.children.each do |child|
|
||||||
Utils::Cp.recursive_with_attributes (child.directory? && !child.symlink?) ? "#{child}/." : child,
|
Utils::Copy.recursive_with_attributes (child.directory? && !child.symlink?) ? "#{child}/." : child,
|
||||||
unpack_dir/child.basename,
|
unpack_dir/child.basename,
|
||||||
force_command: true,
|
force_command: true,
|
||||||
verbose:
|
verbose:
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
# typed: true
|
# typed: true
|
||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
|
|
||||||
require "utils/cp"
|
require "utils/copy"
|
||||||
|
|
||||||
module UnpackStrategy
|
module UnpackStrategy
|
||||||
# Strategy for unpacking gzip archives.
|
# 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) }
|
sig { override.params(unpack_dir: Pathname, basename: Pathname, verbose: T::Boolean).returns(T.untyped) }
|
||||||
def extract_to_dir(unpack_dir, basename:, verbose:)
|
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"]
|
quiet_flags = verbose ? [] : ["-q"]
|
||||||
system_command! "gunzip",
|
system_command! "gunzip",
|
||||||
args: [*quiet_flags, "-N", "--", unpack_dir/basename],
|
args: [*quiet_flags, "-N", "--", unpack_dir/basename],
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
# typed: true
|
# typed: true
|
||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
|
|
||||||
require "utils/cp"
|
require "utils/copy"
|
||||||
|
|
||||||
module UnpackStrategy
|
module UnpackStrategy
|
||||||
# Strategy for unpacking lzip archives.
|
# 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) }
|
sig { override.params(unpack_dir: Pathname, basename: Pathname, verbose: T::Boolean).returns(T.untyped) }
|
||||||
def extract_to_dir(unpack_dir, basename:, verbose:)
|
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"]
|
quiet_flags = verbose ? [] : ["-q"]
|
||||||
system_command! "lzip",
|
system_command! "lzip",
|
||||||
args: ["-d", *quiet_flags, unpack_dir/basename],
|
args: ["-d", *quiet_flags, unpack_dir/basename],
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
# typed: true
|
# typed: true
|
||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
|
|
||||||
require "utils/cp"
|
require "utils/copy"
|
||||||
|
|
||||||
module UnpackStrategy
|
module UnpackStrategy
|
||||||
# Strategy for unpacking LZMA archives.
|
# 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) }
|
sig { override.params(unpack_dir: Pathname, basename: Pathname, verbose: T::Boolean).returns(T.untyped) }
|
||||||
def extract_to_dir(unpack_dir, basename:, verbose:)
|
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"]
|
quiet_flags = verbose ? [] : ["-q"]
|
||||||
system_command! "unlzma",
|
system_command! "unlzma",
|
||||||
args: [*quiet_flags, "--", unpack_dir/basename],
|
args: [*quiet_flags, "--", unpack_dir/basename],
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
# typed: true
|
# typed: true
|
||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
|
|
||||||
require "utils/cp"
|
require "utils/copy"
|
||||||
|
|
||||||
module UnpackStrategy
|
module UnpackStrategy
|
||||||
# Strategy for unpacking uncompressed files.
|
# 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) }
|
sig { override.params(unpack_dir: Pathname, basename: Pathname, verbose: T::Boolean).returns(T.untyped) }
|
||||||
def extract_to_dir(unpack_dir, basename:, verbose: false)
|
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
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
# typed: true
|
# typed: true
|
||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
|
|
||||||
require "utils/cp"
|
require "utils/copy"
|
||||||
|
|
||||||
module UnpackStrategy
|
module UnpackStrategy
|
||||||
# Strategy for unpacking xz archives.
|
# 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) }
|
sig { override.params(unpack_dir: Pathname, basename: Pathname, verbose: T::Boolean).returns(T.untyped) }
|
||||||
def extract_to_dir(unpack_dir, basename:, verbose:)
|
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"]
|
quiet_flags = verbose ? [] : ["-q"]
|
||||||
system_command! "unxz",
|
system_command! "unxz",
|
||||||
args: [*quiet_flags, "-T0", "--", unpack_dir/basename],
|
args: [*quiet_flags, "-T0", "--", unpack_dir/basename],
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
# typed: true
|
# typed: true
|
||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
|
|
||||||
require "utils/cp"
|
require "utils/copy"
|
||||||
|
|
||||||
module UnpackStrategy
|
module UnpackStrategy
|
||||||
# Strategy for unpacking zstd archives.
|
# 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) }
|
sig { override.params(unpack_dir: Pathname, basename: Pathname, verbose: T::Boolean).returns(T.untyped) }
|
||||||
def extract_to_dir(unpack_dir, basename:, verbose:)
|
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"]
|
quiet_flags = verbose ? [] : ["-q"]
|
||||||
system_command! "unzstd",
|
system_command! "unzstd",
|
||||||
args: [*quiet_flags, "-T0", "--rm", "--", unpack_dir/basename],
|
args: [*quiet_flags, "-T0", "--rm", "--", unpack_dir/basename],
|
||||||
|
|||||||
@ -1,13 +1,13 @@
|
|||||||
# typed: true
|
# typed: true
|
||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
|
|
||||||
require "extend/os/cp"
|
require "extend/os/copy"
|
||||||
require "fileutils"
|
require "fileutils"
|
||||||
require "system_command"
|
require "system_command"
|
||||||
|
|
||||||
module Utils
|
module Utils
|
||||||
# Helper functions for copying files.
|
# Helper functions for copying files.
|
||||||
module Cp
|
module Copy
|
||||||
class << self
|
class << self
|
||||||
sig {
|
sig {
|
||||||
params(
|
params(
|
||||||
Loading…
x
Reference in New Issue
Block a user