Skip to content
Snippets Groups Projects
Commit 0578ba0f authored by Mike McQuaid's avatar Mike McQuaid Committed by Xu Cheng
Browse files

install_renamed: handle recursive installs.


Closes Homebrew/homebrew#49845.

Signed-off-by: default avatarMike McQuaid <mike@mikemcquaid.com>
parent 6f9f3fae
No related branches found
No related tags found
No related merge requests found
...@@ -82,6 +82,7 @@ class Pathname ...@@ -82,6 +82,7 @@ class Pathname
src = Pathname(src) src = Pathname(src)
dst = join(new_basename) dst = join(new_basename)
dst = yield(src, dst) if block_given? dst = yield(src, dst) if block_given?
return unless dst
mkpath mkpath
......
...@@ -2,7 +2,8 @@ module InstallRenamed ...@@ -2,7 +2,8 @@ module InstallRenamed
def install_p(_, new_basename) def install_p(_, new_basename)
super do |src, dst| super do |src, dst|
if src.directory? if src.directory?
dst dst.install(src.children)
next
else else
append_default_if_different(src, dst) append_default_if_different(src, dst)
end end
......
...@@ -137,6 +137,16 @@ class PathnameTests < Homebrew::TestCase ...@@ -137,6 +137,16 @@ class PathnameTests < Homebrew::TestCase
assert_equal "a", File.read(@dst+@src.basename+@file.basename) assert_equal "a", File.read(@dst+@src.basename+@file.basename)
end end
def test_install_renamed_directory_recursive
@dst.extend(InstallRenamed)
(@dst+@dir.basename).mkpath
(@dst+@dir.basename+"another_file").write "a"
@dir.mkpath
(@dir+"another_file").write "b"
@dst.install @dir
assert_equal "b", File.read(@dst+@dir.basename+"another_file.default")
end
def test_cp_path_sub_file def test_cp_path_sub_file
@file.write "a" @file.write "a"
@file.cp_path_sub @src, @dst @file.cp_path_sub @src, @dst
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment