Merge pull request #7316 from bayandin/fix-bump-revision

bump-revision: fix handling formula with stable block
This commit is contained in:
Mike McQuaid 2020-04-26 13:31:45 +01:00 committed by GitHub
commit a7fdc7046f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -42,7 +42,14 @@ module Homebrew
[checksum.hash_type, checksum.hexdigest]
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
<<~EOS
#{hash_type} "#{old_hash}"
@ -53,8 +60,12 @@ module Homebrew
:revision => "#{formula_spec.specs[:revision]}"
EOS
end
replacement = old + " revision 1\n"
replacement = if stable_block_given
"revision 1\n " + old
else
old + " revision 1\n"
end
else
old = "revision #{current_revision}"
replacement = "revision #{current_revision+1}"