bottle: improve bottle commit writing.

This commit is contained in:
Mike McQuaid 2014-01-31 19:07:49 +01:00
parent 7ed97b14fd
commit d83ed0d793

View File

@ -207,19 +207,20 @@ module Homebrew extend self
if ARGV.include? '--write' if ARGV.include? '--write'
f = Formula.factory formula_name f = Formula.factory formula_name
has_bottle_block = f.class.bottle.checksums.any? update_or_add = nil
inreplace f.path do |s| inreplace f.path do |s|
if has_bottle_block if s.include? 'bottle do'
s.sub!(/ bottle do.+?end\n/m, output) update_or_add = 'add'
string = s.sub!(/ bottle do.+?end\n/m, output)
odie 'Bottle block replacement failed!' unless string
else else
s.sub!(/( (url|sha1|sha256|head|version) '\S*'\n+)+/m, '\0' + output + "\n") update_or_add = 'update'
string = s.sub!(/( (url|sha1|sha256|head|version) '\S*'\n+)+/m, '\0' + output + "\n")
odie 'Bottle block addition failed!' unless string
end end
end end
update_or_add = has_bottle_block ? 'update' : 'add'
system 'git', 'diff'
safe_system 'git', 'commit', '--no-edit', '--verbose', safe_system 'git', 'commit', '--no-edit', '--verbose',
"--message=#{f.name}: #{update_or_add} #{f.version} bottle.", "--message=#{f.name}: #{update_or_add} #{f.version} bottle.",
'--', f.path '--', f.path