Skip to content

Commit

Permalink
update: Don't report formulae that are moved within a tap but not ren…
Browse files Browse the repository at this point in the history
…amed (#480)
  • Loading branch information
jawshooah authored and UniqMartin committed Jul 16, 2016
1 parent 91d32e7 commit 4abdeb7
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 4 deletions.
8 changes: 6 additions & 2 deletions Library/Homebrew/cmd/update-report.rb
Original file line number Diff line number Diff line change
Expand Up @@ -209,8 +209,12 @@ def report
end
@report[:M] << tap.formula_file_to_name(src)
when /^R\d{0,3}/
@report[:D] << tap.formula_file_to_name(src) if tap.formula_file?(src)
@report[:A] << tap.formula_file_to_name(dst) if tap.formula_file?(dst)
src_full_name = tap.formula_file_to_name(src)
dst_full_name = tap.formula_file_to_name(dst)
# Don't report formulae that are moved within a tap but not renamed
next if src_full_name == dst_full_name
@report[:D] << src_full_name
@report[:A] << dst_full_name
end
end

Expand Down
2 changes: 2 additions & 0 deletions Library/Homebrew/test/fixtures/updater_fixture.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ update_git_diff_output_with_formula_rename: |
update_git_diff_output_with_restructured_tap: |
R100 git.rb Formula/git.rb
R100 lua.rb Formula/lua.rb
update_git_diff_output_with_formula_rename_and_restructuring: |
R100 xchat.rb Formula/xchat2.rb
update_git_diff_simulate_homebrew_php_restructuring: |
R100 Formula/git.rb Abstract/git.rb
R100 Formula/lua.rb Abstract/lua.rb
Expand Down
20 changes: 18 additions & 2 deletions Library/Homebrew/test/test_update_report.rb
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,23 @@ def test_update_homebrew_with_restructured_tap
tap.path.join("Formula").mkpath

perform_update("update_git_diff_output_with_restructured_tap")
assert_equal %w[foo/bar/git foo/bar/lua], @hub.select_formula(:A)
assert_empty @hub.select_formula(:A)
assert_empty @hub.select_formula(:D)
assert_empty @hub.select_formula(:R)
ensure
tap.path.parent.rmtree
end

def test_update_homebrew_with_formula_rename_and_restructuring
tap = Tap.new("foo", "bar")
@reporter = ReporterMock.new(tap)
tap.path.join("Formula").mkpath
tap.stubs(:formula_renames).returns("xchat" => "xchat2")

perform_update("update_git_diff_output_with_formula_rename_and_restructuring")
assert_empty @hub.select_formula(:A)
assert_empty @hub.select_formula(:D)
assert_equal [%w[foo/bar/xchat foo/bar/xchat2]], @hub.select_formula(:R)
ensure
tap.path.parent.rmtree
end
Expand All @@ -98,7 +113,8 @@ def test_update_homebrew_simulate_homebrew_php_restructuring

perform_update("update_git_diff_simulate_homebrew_php_restructuring")
assert_empty @hub.select_formula(:A)
assert_equal %w[foo/bar/git foo/bar/lua], @hub.select_formula(:D)
assert_empty @hub.select_formula(:D)
assert_empty @hub.select_formula(:R)
ensure
tap.path.parent.rmtree
end
Expand Down

0 comments on commit 4abdeb7

Please sign in to comment.