bump-formula-pr: only validate tar files.

This commit is contained in:
ilovezfs 2018-01-24 04:22:11 -08:00
parent 4a1a8b86ac
commit 5a3555eeee

View File

@ -196,13 +196,18 @@ module Homebrew
resource.version = forced_version if forced_version
odie "No --version= argument specified!" unless resource.version
resource_path = resource.fetch
gnu_tar_gtar_path = HOMEBREW_PREFIX/"opt/gnu-tar/bin/gtar"
gnu_tar_gtar = gnu_tar_gtar_path if gnu_tar_gtar_path.executable?
tar = which("gtar") || gnu_tar_gtar || which("tar")
if Utils.popen_read(tar, "-tf", resource_path) =~ %r{/.*\.}
tar_file_extensions = %w[.tar .tb2 .tbz .tbz2 .tgz .tlz .txz .tZ]
if tar_file_extensions.any? { |extension| new_url.include? extension }
gnu_tar_gtar_path = HOMEBREW_PREFIX/"opt/gnu-tar/bin/gtar"
gnu_tar_gtar = gnu_tar_gtar_path if gnu_tar_gtar_path.executable?
tar = which("gtar") || gnu_tar_gtar || which("tar")
if Utils.popen_read(tar, "-tf", resource_path) =~ %r{/.*\.}
new_hash = resource_path.sha256
else
odie "#{resource_path} is not a valid tar file!"
end
else
new_hash = resource_path.sha256
elsif new_url.include? ".tar"
odie "#{formula}: no --url=/--#{hash_type}= arguments specified!"
end
end