From b160cc9bb64561f28856864d20ce858cb0c26064 Mon Sep 17 00:00:00 2001 From: Jack Nagel Date: Thu, 31 Jul 2014 15:54:03 -0500 Subject: [PATCH] Handle tap file renames that remove a file from the formula directory --- Library/Homebrew/cmd/update.rb | 11 ++++++----- Library/Homebrew/test/fixtures/updater_fixture.yaml | 3 +++ Library/Homebrew/test/test_updater.rb | 11 +++++++++++ 3 files changed, 20 insertions(+), 5 deletions(-) diff --git a/Library/Homebrew/cmd/update.rb b/Library/Homebrew/cmd/update.rb index 5e7f34b623..467cc60f6a 100644 --- a/Library/Homebrew/cmd/update.rb +++ b/Library/Homebrew/cmd/update.rb @@ -174,16 +174,17 @@ class Updater if initial_revision && initial_revision != current_revision diff.each_line do |line| status, *paths = line.split + src, dst = paths.first, paths.last - next unless File.extname(paths.last) == ".rb" - next unless File.dirname(paths.last) == formula_directory + next unless File.extname(dst) == ".rb" + next unless paths.any? { |p| File.dirname(p) == formula_directory } case status when "A", "M", "D" - map[status.to_sym] << repository.join(paths.first) + map[status.to_sym] << repository.join(src) when /^R\d{0,3}/ - map[:D] << repository.join(paths.first) - map[:A] << repository.join(paths.last) + map[:D] << repository.join(src) if File.dirname(src) == formula_directory + map[:A] << repository.join(dst) if File.dirname(dst) == formula_directory end end end diff --git a/Library/Homebrew/test/fixtures/updater_fixture.yaml b/Library/Homebrew/test/fixtures/updater_fixture.yaml index 6038623e68..b12f9d447f 100644 --- a/Library/Homebrew/test/fixtures/updater_fixture.yaml +++ b/Library/Homebrew/test/fixtures/updater_fixture.yaml @@ -43,6 +43,9 @@ update_git_diff_output_with_changed_filetype: | update_git_diff_output_with_restructured_tap: | R100 git.rb Formula/git.rb R100 lua.rb Formula/lua.rb +update_git_diff_simulate_homebrew_php_restructuring: | + R100 Formula/git.rb Abstract/git.rb + R100 Formula/lua.rb Abstract/lua.rb update_git_diff_output_with_tap_formulae_changes: | M Rakefile M README.md diff --git a/Library/Homebrew/test/test_updater.rb b/Library/Homebrew/test/test_updater.rb index b08766ae2e..41824ebded 100644 --- a/Library/Homebrew/test/test_updater.rb +++ b/Library/Homebrew/test/test_updater.rb @@ -98,6 +98,17 @@ class UpdaterTests < Homebrew::TestCase perform_update("update_git_diff_output_with_restructured_tap") assert_equal %w{foo/bar/git foo/bar/lua}, @report.select_formula(:A) + assert_empty @report.select_formula(:D) + end + + def test_update_homebrew_simulate_homebrew_php_restructuring + repo = HOMEBREW_LIBRARY.join("Taps", "foo", "bar") + @updater = UpdaterMock.new(repo) + repo.join("Formula").mkpath + + perform_update("update_git_diff_simulate_homebrew_php_restructuring") + + assert_empty @report.select_formula(:A) assert_equal %w{foo/bar/git foo/bar/lua}, @report.select_formula(:D) end