bottle: determine revision more reliably

Closes Homebrew/homebrew#25100.
This commit is contained in:
Jack Nagel 2013-12-10 15:16:22 -06:00
parent 1d1bad98b7
commit 1b7718f6a7
2 changed files with 17 additions and 19 deletions

View File

@ -113,13 +113,14 @@ module Homebrew extend self
return ofail "Formula not installed with '--build-bottle': #{f.name}" return ofail "Formula not installed with '--build-bottle': #{f.name}"
end end
master_bottle_filenames = f.bottle_filenames 'origin/master' if ARGV.include? '--no-revision'
bottle_revision = -1 bottle_revision = 0
begin else
bottle_revision += 1 max = f.bottle_version_map('origin/master')[f.version].max
filename = bottle_filename(f, :tag => bottle_tag, :revision => bottle_revision) bottle_revision = max ? max + 1 : 0
end while not ARGV.include? '--no-revision' \ end
and master_bottle_filenames.include? filename
filename = bottle_filename(f, :tag => bottle_tag, :revision => bottle_revision)
if bottle_filename_formula_name(filename).empty? if bottle_filename_formula_name(filename).empty?
return ofail "Add a new regex to bottle_version.rb to parse the bottle filename." return ofail "Add a new regex to bottle_version.rb to parse the bottle filename."

View File

@ -41,20 +41,17 @@ class Formula
return versions return versions
end end
def bottle_filenames branch='HEAD' def bottle_version_map branch='HEAD'
filenames = [] map = Hash.new { |h, k| h[k] = [] }
rev_list(branch).each do |sha| rev_list(branch).each do |rev|
filename = formula_for_sha(sha) do |f| formula_for_sha(rev) do |f|
bottle_block = f.class.send(:bottle) bottle = f.class.send(:bottle)
unless bottle_block.checksums.empty? unless bottle.checksums.empty?
bottle_filename f, :revision => bottle_block.revision map[bottle.version] << bottle.revision
end end
end end
unless filenames.include? filename or filename.nil?
filenames << filename
end
end end
filenames map
end end
def pretty_relative_path def pretty_relative_path
@ -84,7 +81,7 @@ class Formula
def rev_list branch='HEAD' def rev_list branch='HEAD'
repository.cd do repository.cd do
`git rev-list --abbrev-commit #{branch} -- #{entry_name}`.split `git rev-list --abbrev-commit --remove-empty #{branch} -- #{entry_name}`.split
end end
end end