Handle tap file renames that remove a file from the formula directory

This commit is contained in:
Jack Nagel 2014-07-31 15:54:03 -05:00
parent 5a94cfc4a3
commit b160cc9bb6
3 changed files with 20 additions and 5 deletions

View File

@ -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

View File

@ -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

View File

@ -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