Skip to content
Snippets Groups Projects
Commit 2b90995c authored by Jack Nagel's avatar Jack Nagel
Browse files

Only populate the report with formula paths

parent 197a12c9
No related branches found
No related tags found
No related merge requests found
......@@ -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)
......
......@@ -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
......@@ -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
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