From 028cfe1ea63fd85748219eca53bfda8c0441e661 Mon Sep 17 00:00:00 2001 From: Daiki Mizukami Date: Tue, 11 Jun 2024 07:53:47 +0900 Subject: [PATCH] Utils::Cp: Rename to `Utils::Copy` As per review feedback: https://github.com/Homebrew/brew/pull/17373#discussion_r1633217748 --- Library/Homebrew/cask/artifact/moved.rb | 8 ++++---- Library/Homebrew/extend/os/{cp.rb => copy.rb} | 2 +- .../Homebrew/extend/os/mac/utils/{cp.rb => copy.rb} | 2 +- Library/Homebrew/extend/pathname.rb | 4 ++-- .../Homebrew/test/utils/{cp_spec.rb => copy_spec.rb} | 4 ++-- Library/Homebrew/unpack_strategy/bzip2.rb | 4 ++-- Library/Homebrew/unpack_strategy/directory.rb | 10 +++++----- Library/Homebrew/unpack_strategy/gzip.rb | 4 ++-- Library/Homebrew/unpack_strategy/lzip.rb | 4 ++-- Library/Homebrew/unpack_strategy/lzma.rb | 4 ++-- Library/Homebrew/unpack_strategy/uncompressed.rb | 4 ++-- Library/Homebrew/unpack_strategy/xz.rb | 4 ++-- Library/Homebrew/unpack_strategy/zstd.rb | 4 ++-- Library/Homebrew/utils/{cp.rb => copy.rb} | 4 ++-- 14 files changed, 31 insertions(+), 31 deletions(-) rename Library/Homebrew/extend/os/{cp.rb => copy.rb} (50%) rename Library/Homebrew/extend/os/mac/utils/{cp.rb => copy.rb} (98%) rename Library/Homebrew/test/utils/{cp_spec.rb => copy_spec.rb} (98%) rename Library/Homebrew/utils/{cp.rb => copy.rb} (97%) diff --git a/Library/Homebrew/cask/artifact/moved.rb b/Library/Homebrew/cask/artifact/moved.rb index f735e1e22c..084c3316fa 100644 --- a/Library/Homebrew/cask/artifact/moved.rb +++ b/Library/Homebrew/cask/artifact/moved.rb @@ -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) diff --git a/Library/Homebrew/extend/os/cp.rb b/Library/Homebrew/extend/os/copy.rb similarity index 50% rename from Library/Homebrew/extend/os/cp.rb rename to Library/Homebrew/extend/os/copy.rb index e35d5b123a..59dcc7da70 100644 --- a/Library/Homebrew/extend/os/cp.rb +++ b/Library/Homebrew/extend/os/copy.rb @@ -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? diff --git a/Library/Homebrew/extend/os/mac/utils/cp.rb b/Library/Homebrew/extend/os/mac/utils/copy.rb similarity index 98% rename from Library/Homebrew/extend/os/mac/utils/cp.rb rename to Library/Homebrew/extend/os/mac/utils/copy.rb index ec430b7dc5..40e8ad4fc5 100644 --- a/Library/Homebrew/extend/os/mac/utils/cp.rb +++ b/Library/Homebrew/extend/os/mac/utils/copy.rb @@ -2,7 +2,7 @@ # frozen_string_literal: true module Utils - module Cp + module Copy class << self module MacOSOverride private diff --git a/Library/Homebrew/extend/pathname.rb b/Library/Homebrew/extend/pathname.rb index 529665123e..d0defa91d4 100644 --- a/Library/Homebrew/extend/pathname.rb +++ b/Library/Homebrew/extend/pathname.rb @@ -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 diff --git a/Library/Homebrew/test/utils/cp_spec.rb b/Library/Homebrew/test/utils/copy_spec.rb similarity index 98% rename from Library/Homebrew/test/utils/cp_spec.rb rename to Library/Homebrew/test/utils/copy_spec.rb index 1d25a51442..f95758efc0 100644 --- a/Library/Homebrew/test/utils/cp_spec.rb +++ b/Library/Homebrew/test/utils/copy_spec.rb @@ -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" } diff --git a/Library/Homebrew/unpack_strategy/bzip2.rb b/Library/Homebrew/unpack_strategy/bzip2.rb index 2ca92686b9..30ae554dff 100644 --- a/Library/Homebrew/unpack_strategy/bzip2.rb +++ b/Library/Homebrew/unpack_strategy/bzip2.rb @@ -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], diff --git a/Library/Homebrew/unpack_strategy/directory.rb b/Library/Homebrew/unpack_strategy/directory.rb index 23e20027cb..b8c841932a 100644 --- a/Library/Homebrew/unpack_strategy/directory.rb +++ b/Library/Homebrew/unpack_strategy/directory.rb @@ -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 diff --git a/Library/Homebrew/unpack_strategy/gzip.rb b/Library/Homebrew/unpack_strategy/gzip.rb index 8e2b869eeb..c343a173a5 100644 --- a/Library/Homebrew/unpack_strategy/gzip.rb +++ b/Library/Homebrew/unpack_strategy/gzip.rb @@ -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], diff --git a/Library/Homebrew/unpack_strategy/lzip.rb b/Library/Homebrew/unpack_strategy/lzip.rb index 8da8640088..f676e12509 100644 --- a/Library/Homebrew/unpack_strategy/lzip.rb +++ b/Library/Homebrew/unpack_strategy/lzip.rb @@ -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], diff --git a/Library/Homebrew/unpack_strategy/lzma.rb b/Library/Homebrew/unpack_strategy/lzma.rb index b9a8f4e2d4..85c0898aa5 100644 --- a/Library/Homebrew/unpack_strategy/lzma.rb +++ b/Library/Homebrew/unpack_strategy/lzma.rb @@ -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], diff --git a/Library/Homebrew/unpack_strategy/uncompressed.rb b/Library/Homebrew/unpack_strategy/uncompressed.rb index ae36bd17f5..ab2ba36fbf 100644 --- a/Library/Homebrew/unpack_strategy/uncompressed.rb +++ b/Library/Homebrew/unpack_strategy/uncompressed.rb @@ -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 diff --git a/Library/Homebrew/unpack_strategy/xz.rb b/Library/Homebrew/unpack_strategy/xz.rb index 94177c804f..77d4e85da7 100644 --- a/Library/Homebrew/unpack_strategy/xz.rb +++ b/Library/Homebrew/unpack_strategy/xz.rb @@ -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], diff --git a/Library/Homebrew/unpack_strategy/zstd.rb b/Library/Homebrew/unpack_strategy/zstd.rb index f1a89a4519..4c2571df2d 100644 --- a/Library/Homebrew/unpack_strategy/zstd.rb +++ b/Library/Homebrew/unpack_strategy/zstd.rb @@ -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], diff --git a/Library/Homebrew/utils/cp.rb b/Library/Homebrew/utils/copy.rb similarity index 97% rename from Library/Homebrew/utils/cp.rb rename to Library/Homebrew/utils/copy.rb index e29d2cecce..7833e69675 100644 --- a/Library/Homebrew/utils/cp.rb +++ b/Library/Homebrew/utils/copy.rb @@ -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(