Merge pull request #11271 from MikeMcQuaid/bottle_filename_handling
dev-cmd/bottle: improve filename handling.
This commit is contained in:
commit
c11067c5d6
@ -33,7 +33,7 @@ Metrics/PerceivedComplexity:
|
|||||||
Metrics/MethodLength:
|
Metrics/MethodLength:
|
||||||
Max: 260
|
Max: 260
|
||||||
Metrics/ModuleLength:
|
Metrics/ModuleLength:
|
||||||
Max: 600
|
Max: 610
|
||||||
Exclude:
|
Exclude:
|
||||||
- "test/**/*"
|
- "test/**/*"
|
||||||
|
|
||||||
|
@ -558,11 +558,11 @@ module Homebrew
|
|||||||
"prefix" => bottle.prefix,
|
"prefix" => bottle.prefix,
|
||||||
"cellar" => bottle_cellar.to_s,
|
"cellar" => bottle_cellar.to_s,
|
||||||
"rebuild" => bottle.rebuild,
|
"rebuild" => bottle.rebuild,
|
||||||
"date" => Pathname(local_filename).mtime.strftime("%F"),
|
"date" => Pathname(filename.to_s).mtime.strftime("%F"),
|
||||||
"tags" => {
|
"tags" => {
|
||||||
bottle_tag.to_s => {
|
bottle_tag.to_s => {
|
||||||
"filename" => filename.url_encode,
|
"filename" => filename.url_encode,
|
||||||
"local_filename" => local_filename,
|
"local_filename" => filename.to_s,
|
||||||
"sha256" => sha256,
|
"sha256" => sha256,
|
||||||
"formulae_brew_sh_path" => formulae_brew_sh_path,
|
"formulae_brew_sh_path" => formulae_brew_sh_path,
|
||||||
"tab" => tab.to_bottle_hash,
|
"tab" => tab.to_bottle_hash,
|
||||||
@ -581,9 +581,9 @@ module Homebrew
|
|||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
File.open(filename.json, "w") do |file|
|
json_path = Pathname(filename.json)
|
||||||
file.write JSON.pretty_generate json
|
json_path.unlink if json_path.exist?
|
||||||
end
|
json_path.write(JSON.pretty_generate(json))
|
||||||
end
|
end
|
||||||
|
|
||||||
def parse_json_files(filenames)
|
def parse_json_files(filenames)
|
||||||
@ -643,17 +643,25 @@ module Homebrew
|
|||||||
if all_bottle
|
if all_bottle
|
||||||
all_bottle_hash = nil
|
all_bottle_hash = nil
|
||||||
bottle_hash["bottle"]["tags"].each do |tag, tag_hash|
|
bottle_hash["bottle"]["tags"].each do |tag, tag_hash|
|
||||||
local_filename = tag_hash["local_filename"]
|
filename = Bottle::Filename.new(
|
||||||
local_json_filename = local_filename.sub(/\.tar\.gz$/, ".json")
|
formula_name,
|
||||||
|
bottle_hash["formula"]["pkg_version"],
|
||||||
|
tag,
|
||||||
|
bottle_hash["bottle"]["rebuild"],
|
||||||
|
)
|
||||||
|
|
||||||
if all_bottle_hash.nil?
|
if all_bottle_hash.nil?
|
||||||
all_filename = tag_hash["filename"].sub(tag, "all")
|
|
||||||
all_local_filename = local_filename.sub(tag, "all")
|
|
||||||
all_local_json_filename = local_json_filename.sub(tag, "all")
|
|
||||||
|
|
||||||
all_bottle_tag_hash = tag_hash.dup
|
all_bottle_tag_hash = tag_hash.dup
|
||||||
all_bottle_tag_hash["filename"] = all_filename
|
|
||||||
all_bottle_tag_hash["local_filename"] = all_local_filename
|
all_filename = Bottle::Filename.new(
|
||||||
|
formula_name,
|
||||||
|
bottle_hash["formula"]["pkg_version"],
|
||||||
|
"all",
|
||||||
|
bottle_hash["bottle"]["rebuild"],
|
||||||
|
)
|
||||||
|
|
||||||
|
all_bottle_tag_hash["filename"] = all_filename.url_encode
|
||||||
|
all_bottle_tag_hash["local_filename"] = all_filename.to_s
|
||||||
cellar = all_bottle_tag_hash.delete("cellar")
|
cellar = all_bottle_tag_hash.delete("cellar")
|
||||||
|
|
||||||
all_bottle_formula_hash = bottle_hash.dup
|
all_bottle_formula_hash = bottle_hash.dup
|
||||||
@ -662,16 +670,16 @@ module Homebrew
|
|||||||
|
|
||||||
all_bottle_hash = { formula_name => all_bottle_formula_hash }
|
all_bottle_hash = { formula_name => all_bottle_formula_hash }
|
||||||
|
|
||||||
puts "Copying #{local_filename} to #{all_local_filename}" if args.verbose?
|
puts "Copying #{filename} to #{all_filename}" if args.verbose?
|
||||||
FileUtils.cp local_filename, all_local_filename
|
FileUtils.cp filename.to_s, all_filename.to_s
|
||||||
|
|
||||||
all_local_json_path = Pathname(all_local_json_filename)
|
all_local_json_path = Pathname(filename.json)
|
||||||
all_local_json_path.unlink if all_local_json_path.exist?
|
all_local_json_path.unlink if all_local_json_path.exist?
|
||||||
all_local_json_path.write(JSON.pretty_generate(all_bottle_hash))
|
all_local_json_path.write(JSON.pretty_generate(all_bottle_hash))
|
||||||
end
|
end
|
||||||
|
|
||||||
puts "Removing #{local_filename} and #{local_json_filename}" if args.verbose?
|
puts "Removing #{filename} and #{filename.json}" if args.verbose?
|
||||||
FileUtils.rm_f [local_filename, local_json_filename]
|
FileUtils.rm_f [filename.to_s, filename.json]
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user