Skip to content
Snippets Groups Projects
Commit 9a94a77f authored by phinze's avatar phinze Committed by Jack Nagel
Browse files

Properly define tapped formulae in update


A tapped formula is a ruby file present:

  - in the root of the tap
  - in directory of the tap called Formula
  - in a directory of the tap called HomebrewFormula

And nowhere else. This corrects an overzealous definition of tapped
formula in the updater. (the correct definition has been in Pathname
since e613cbe5783cea2abb8100b56c22126a1ab6b9f2)

Refs Homebrew/homebrew#19743.
Closes Homebrew/homebrew#21087.

Signed-off-by: default avatarJack Nagel <jacknagel@gmail.com>
parent 81984411
No related branches found
No related tags found
No related merge requests found
...@@ -146,11 +146,24 @@ class Report < Hash ...@@ -146,11 +146,24 @@ class Report < Hash
def tapped_formula_for key def tapped_formula_for key
fetch(key, []).map do |path| fetch(key, []).map do |path|
case path when %r{^Library/Taps/(\w+-\w+/.*)} case path when %r{^Library/Taps/(\w+-\w+/.*)}
Pathname.new($1) relative_path = $1
if valid_formula_location?(relative_path)
Pathname.new(relative_path)
end
end end
end.compact end.compact
end end
def valid_formula_location?(relative_path)
ruby_file = /\A.*\.rb\Z/
parts = relative_path.split('/')[1..-1]
[
parts.length == 1 && parts.first =~ ruby_file,
parts.length == 2 && parts.first == 'Formula' && parts.last =~ ruby_file,
parts.length == 2 && parts.first == 'HomebrewFormula' && parts.last =~ ruby_file,
].any?
end
def new_tapped_formula def new_tapped_formula
tapped_formula_for :A tapped_formula_for :A
end end
......
...@@ -25,3 +25,9 @@ update_git_diff_output_with_formulae_changes: | ...@@ -25,3 +25,9 @@ update_git_diff_output_with_formulae_changes: |
:100644 100644 cc176d388507c7ed9381a36fd42ae0feceaad593 6a7a2385d89a12b5c7369fa0a87980b285ee5fd8 M Library/Homebrew/utils.rb :100644 100644 cc176d388507c7ed9381a36fd42ae0feceaad593 6a7a2385d89a12b5c7369fa0a87980b285ee5fd8 M Library/Homebrew/utils.rb
:100644 100644 d1d9c62e6280bcb06c8b884c188d7bd37f8754e3 4aa0473705264cac864bd09f8a9d419d805e4774 M README :100644 100644 d1d9c62e6280bcb06c8b884c188d7bd37f8754e3 4aa0473705264cac864bd09f8a9d419d805e4774 M README
:100644 100644 c0084b02faf7ab04abcffb3d5688e9d7c1ff7ae8 25cae981801e21cde048cd28747241d18093ca71 M bin/brew :100644 100644 c0084b02faf7ab04abcffb3d5688e9d7c1ff7ae8 25cae981801e21cde048cd28747241d18093ca71 M bin/brew
update_git_diff_output_with_tapped_formulae_changes: |
:100644 100644 9dde0708e2db78e1aa697782bd2ab2ddfd8da984 ee0a81cbe3757e9a4b5aab1c41457f65fed9f258 M Library/Contributions/brew_bash_completion.sh
:100644 100644 741f11dcd29ec909a94fa54df4bcdd2c1d5bb47b 7535134e865994e8ad66ba02a924a1e6c1271b9e A Library/Taps/someuser-sometap/Formula/antiword.rb
:100644 100644 741f11dcd29ec909a94fa54df4bcdd2c1d5bb47b 7535134e865994e8ad66ba02a924a1e6c1271b9e A Library/Taps/someuser-sometap/HomebrewFormula/lua.rb
:100644 100644 741f11dcd29ec909a94fa54df4bcdd2c1d5bb47b 7535134e865994e8ad66ba02a924a1e6c1271b9e A Library/Taps/someuser-sometap/custom-formula.rb
:100644 100644 741f11dcd29ec909a94fa54df4bcdd2c1d5bb47b 7535134e865994e8ad66ba02a924a1e6c1271b9e A Library/Taps/someuser-sometap/lib/not-a-formula.rb
...@@ -102,4 +102,28 @@ class UpdaterTests < Test::Unit::TestCase ...@@ -102,4 +102,28 @@ class UpdaterTests < Test::Unit::TestCase
assert_equal %w{ shapelib }, report.select_formula(:R) assert_equal %w{ shapelib }, report.select_formula(:R)
end end
end end
def test_update_homebrew_with_tapped_formula_changes
diff_output = fixture('update_git_diff_output_with_tapped_formulae_changes')
HOMEBREW_REPOSITORY.cd do
updater = UpdaterMock.new
updater.in_repo_expect("git checkout -q master")
updater.in_repo_expect("git rev-parse -q --verify HEAD", "1234abcd")
updater.in_repo_expect("git config core.autocrlf false")
updater.in_repo_expect("git pull -q origin refs/heads/master:refs/remotes/origin/master")
updater.in_repo_expect("git rev-parse -q --verify HEAD", "3456cdef")
updater.in_repo_expect("git diff-tree -r --raw -M85% 1234abcd 3456cdef", diff_output)
updater.pull!
report = Report.new
report.merge!(updater.report)
assert updater.expectations_met?
assert_equal [
Pathname('someuser-sometap/Formula/antiword.rb'),
Pathname('someuser-sometap/HomebrewFormula/lua.rb'),
Pathname('someuser-sometap/custom-formula.rb'),
], report.tapped_formula_for(:A)
end
end
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