Merge pull request #11293 from bluelabsio/latest-version-only

bottle: Only consider latest rebuild
This commit is contained in:
Mike McQuaid 2021-05-04 17:01:34 +01:00 committed by GitHub
commit 7c52c30312
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 23 deletions

View File

@ -333,10 +333,13 @@ module Homebrew
f.bottle_specification.rebuild
else
ohai "Determining #{f.full_name} bottle rebuild..."
versions = FormulaVersions.new(f)
rebuilds = versions.bottle_version_map("origin/master")[f.pkg_version]
rebuilds.pop if rebuilds.last.to_i.positive?
rebuilds.empty? ? 0 : rebuilds.max.to_i + 1
FormulaVersions.new(f).formula_at_revision("origin/HEAD") do |upstream_f|
if f.pkg_version == upstream_f.pkg_version
upstream_f.bottle_specification.rebuild + 1
else
0
end
end
end
filename = Bottle::Filename.create(f, bottle_tag.to_sym, rebuild)

View File

@ -30,7 +30,9 @@ class FormulaVersions
def rev_list(branch)
repository.cd do
Utils.popen_read("git", "rev-list", "--abbrev-commit", "--remove-empty", branch, "--", entry_name) do |io|
rev_list_cmd = ["git", "rev-list", "--abbrev-commit", "--remove-empty"]
rev_list_cmd << "--first-parent" if repository != CoreTap.instance.path
Utils.popen_read(*rev_list_cmd, branch, "--", entry_name) do |io|
yield io.readline.chomp until io.eof?
end
end
@ -56,22 +58,4 @@ class FormulaVersions
ensure
Homebrew.raise_deprecation_exceptions = false
end
def bottle_version_map(branch)
map = Hash.new { |h, k| h[k] = [] }
versions_seen = 0
rev_list(branch) do |rev|
formula_at_revision(rev) do |f|
bottle = f.bottle_specification
map[f.pkg_version] << bottle.rebuild unless bottle.checksums.empty?
versions_seen = (map.keys + [f.pkg_version]).uniq.length
end
return map if versions_seen > MAX_VERSIONS_DEPTH
rescue MacOSVersionError => e
odebug "#{e} in #{name} at revision #{rev}"
break
end
map
end
end