bump-revision: fix handling formula with stable block

This commit is contained in:
Alexander Bayandin 2020-04-09 15:57:43 +01:00
parent f6348f59a1
commit 7a4c1cc8ac

View File

@ -45,7 +45,14 @@ module Homebrew
[checksum.hash_type, checksum.hexdigest] [checksum.hash_type, checksum.hexdigest]
end end
old = if hash_type stable_block_given = formula.path.read.include? " stable do"
old = if stable_block_given
# insert replacement revision before stable block
<<~EOS
stable do
EOS
elsif hash_type
# insert replacement revision after hash # insert replacement revision after hash
<<~EOS <<~EOS
#{hash_type} "#{old_hash}" #{hash_type} "#{old_hash}"
@ -56,8 +63,12 @@ module Homebrew
:revision => "#{formula_spec.specs[:revision]}" :revision => "#{formula_spec.specs[:revision]}"
EOS EOS
end end
replacement = old + " revision 1\n"
replacement = if stable_block_given
"revision 1\n " + old
else
old + " revision 1\n"
end
else else
old = "revision #{current_revision}" old = "revision #{current_revision}"
replacement = "revision #{current_revision+1}" replacement = "revision #{current_revision+1}"