diff options
| -rw-r--r-- | Library/Homebrew/cmd/update.rb | 31 | ||||
| -rw-r--r-- | Library/Homebrew/test/fixtures/updater_fixture.yaml | 9 | ||||
| -rw-r--r-- | Library/Homebrew/test/test_updater.rb | 22 |
3 files changed, 43 insertions, 19 deletions
diff --git a/Library/Homebrew/cmd/update.rb b/Library/Homebrew/cmd/update.rb index d788bced6..ccb458e32 100644 --- a/Library/Homebrew/cmd/update.rb +++ b/Library/Homebrew/cmd/update.rb @@ -173,8 +173,18 @@ class Updater if initial_revision && initial_revision != current_revision diff.each_line do |line| - status, path = line.split - map[status.to_sym] << repository.join(path) + status, *paths = line.split + + next unless File.extname(paths.last) == ".rb" + next unless File.dirname(paths.last) == formula_directory + + case status + when "A", "M", "D" + map[status.to_sym] << repository.join(paths.first) + when /^R\d{0,3}/ + map[:D] << repository.join(paths.first) + map[:A] << repository.join(paths.last) + end end end @@ -183,12 +193,27 @@ class Updater private + def formula_directory + if repository == HOMEBREW_REPOSITORY + "Library/Formula" + elsif repository.join("Formula").directory? + "Formula" + elsif repository.join("HomebrewFormula").directory? + "HomebrewFormula" + else + "." + end + end + def read_current_revision `git rev-parse -q --verify HEAD`.chomp end def diff - Utils.popen_read("git", "diff-tree", "-r", "--name-status", "--diff-filter=AMD", initial_revision, current_revision) + Utils.popen_read( + "git", "diff-tree", "-r", "--name-status", "--diff-filter=AMDR", + "-M85%", initial_revision, current_revision + ) end def `(cmd) diff --git a/Library/Homebrew/test/fixtures/updater_fixture.yaml b/Library/Homebrew/test/fixtures/updater_fixture.yaml index f39f3a82b..641468c93 100644 --- a/Library/Homebrew/test/fixtures/updater_fixture.yaml +++ b/Library/Homebrew/test/fixtures/updater_fixture.yaml @@ -24,12 +24,6 @@ update_git_diff_output_with_formulae_changes: | M Library/Homebrew/utils.rb M README M bin/brew -update_git_diff_output_with_tapped_formulae_changes: | - M Library/Contributions/brew_bash_completion.sh - A Library/Taps/someuser/sometap/Formula/antiword.rb - A Library/Taps/someuser/sometap/HomebrewFormula/lua.rb - A Library/Taps/someuser/sometap/custom-formula.rb - A Library/Taps/someuser/sometap/lib/not-a-formula.rb update_git_diff_output_with_removed_formulae: | A Library/Formula/flac123.rb M Library/Formula/gdal.rb @@ -46,3 +40,6 @@ update_git_diff_output_with_changed_filetype: | D Library/Formula/libgsasl.rb M Library/Homebrew/cmd/update.rb M SUPPORTERS.md +update_git_diff_output_with_restructured_tap: | + R100 git.rb Formula/git.rb + R100 lua.rb Formula/lua.rb diff --git a/Library/Homebrew/test/test_updater.rb b/Library/Homebrew/test/test_updater.rb index 0806b3d7c..2942b42f2 100644 --- a/Library/Homebrew/test/test_updater.rb +++ b/Library/Homebrew/test/test_updater.rb @@ -85,16 +85,6 @@ class UpdaterTests < Homebrew::TestCase assert_equal %w{ antiword bash-completion ddrescue dict lua }, @report.select_formula(:A) end - def test_update_homebrew_with_tapped_formula_changes - perform_update(fixture('update_git_diff_output_with_tapped_formulae_changes')) - assert_predicate @updater, :expectations_met? - assert_equal [ - HOMEBREW_LIBRARY.join("Taps", "someuser/sometap/Formula/antiword.rb"), - HOMEBREW_LIBRARY.join("Taps", "someuser/sometap/HomebrewFormula/lua.rb"), - HOMEBREW_LIBRARY.join("Taps", "someuser/sometap/custom-formula.rb"), - ], @report.tapped_formula_for(:A) - end - def test_update_homebrew_with_removed_formulae perform_update(fixture('update_git_diff_output_with_removed_formulae')) assert_predicate @updater, :expectations_met? @@ -105,4 +95,16 @@ class UpdaterTests < Homebrew::TestCase perform_update(fixture('update_git_diff_output_with_changed_filetype')) assert_predicate @updater, :expectations_met? end + + def test_update_homebrew_with_restructured_tap + repo = HOMEBREW_LIBRARY.join("Taps", "foo", "bar") + @updater = UpdaterMock.new(repo) + repo.join("Formula").mkpath + + perform_update(fixture('update_git_diff_output_with_restructured_tap')) + + assert_predicate @updater, :expectations_met? + assert_equal %w{foo/bar/git foo/bar/lua}, @report.select_formula(:A) + assert_equal %w{foo/bar/git foo/bar/lua}, @report.select_formula(:D) + end end |
