From d33241bc11054af79c45bd355bf58c7304e18882 Mon Sep 17 00:00:00 2001 From: Markus Reiter Date: Mon, 6 Aug 2018 15:02:52 +0200 Subject: [PATCH] Use `--` for bottles. --- Library/Homebrew/dev-cmd/bottle.rb | 4 +- Library/Homebrew/formula.rb | 2 +- Library/Homebrew/software_spec.rb | 16 +++-- Library/Homebrew/test/bottle_filename_spec.rb | 69 ++++++++++++------- Library/Homebrew/test/dev-cmd/bottle_spec.rb | 4 +- 5 files changed, 58 insertions(+), 37 deletions(-) diff --git a/Library/Homebrew/dev-cmd/bottle.rb b/Library/Homebrew/dev-cmd/bottle.rb index c6858d8096..d59af386c9 100644 --- a/Library/Homebrew/dev-cmd/bottle.rb +++ b/Library/Homebrew/dev-cmd/bottle.rb @@ -391,7 +391,7 @@ module Homebrew "rebuild" => bottle.rebuild, "tags" => { tag => { - "filename" => filename.to_s, + "filename" => filename.bintray, "sha256" => sha256, }, }, @@ -402,7 +402,7 @@ module Homebrew }, }, } - File.open("#{filename.prefix}.bottle.json", "w") do |file| + File.open(filename.json, "w") do |file| file.write JSON.generate json end end diff --git a/Library/Homebrew/formula.rb b/Library/Homebrew/formula.rb index 41e69fbc1c..6c06de3878 100644 --- a/Library/Homebrew/formula.rb +++ b/Library/Homebrew/formula.rb @@ -1617,7 +1617,7 @@ class Formula bottle_spec.collector.keys.each do |os| checksum = bottle_spec.collector[os] bottle_info["files"][os] = { - "url" => "#{bottle_spec.root_url}/#{Bottle::Filename.create(self, os, bottle_spec.rebuild)}", + "url" => "#{bottle_spec.root_url}/#{Bottle::Filename.create(self, os, bottle_spec.rebuild).bintray}", checksum.hash_type.to_s => checksum.hexdigest, } end diff --git a/Library/Homebrew/software_spec.rb b/Library/Homebrew/software_spec.rb index d0a104bb7a..4bb428659a 100644 --- a/Library/Homebrew/software_spec.rb +++ b/Library/Homebrew/software_spec.rb @@ -259,17 +259,21 @@ class Bottle end def to_s - prefix + suffix + "#{name}--#{version}#{extname}" end alias to_str to_s - def prefix - "#{name}-#{version}.#{tag}" + def json + "#{name}--#{version}.#{tag}.bottle.json" end - def suffix + def bintray + "#{name}-#{version}#{extname}" + end + + def extname s = rebuild.positive? ? ".#{rebuild}" : "" - ".bottle#{s}.tar.gz" + ".#{tag}.bottle#{s}.tar.gz" end end @@ -290,7 +294,7 @@ class Bottle checksum, tag = spec.checksum_for(Utils::Bottles.tag) filename = Filename.create(formula, tag, spec.rebuild) - @resource.url(build_url(spec.root_url, filename), + @resource.url(build_url(spec.root_url, filename.bintray), select_download_strategy(spec.root_url_specs)) @resource.version = formula.pkg_version @resource.checksum = checksum diff --git a/Library/Homebrew/test/bottle_filename_spec.rb b/Library/Homebrew/test/bottle_filename_spec.rb index 89f839ddec..bf96319c6f 100644 --- a/Library/Homebrew/test/bottle_filename_spec.rb +++ b/Library/Homebrew/test/bottle_filename_spec.rb @@ -2,36 +2,53 @@ require "formula" require "software_spec" describe Bottle::Filename do - specify "#prefix" do - expect(described_class.new("foo", "1.0", :tag, 0).prefix) - .to eq("foo-1.0.tag") - end + subject { described_class.new(name, version, tag, rebuild) } - specify "#suffix" do - expect(described_class.new("foo", "1.0", :tag, 0).suffix) - .to eq(".bottle.tar.gz") + let(:name) { "foo" } + let(:version) { "1.0" } + let(:tag) { :tag } + let(:rebuild) { 0 } - expect(described_class.new("foo", "1.0", :tag, 1).suffix) - .to eq(".bottle.1.tar.gz") - end + describe "#extname" do + its(:extname) { is_expected.to eq ".tag.bottle.tar.gz" } - specify "#to_s and #to_str" do - expected = "foo-1.0.tag.bottle.tar.gz" - - expect(described_class.new("foo", "1.0", :tag, 0).to_s) - .to eq(expected) - - expect(described_class.new("foo", "1.0", :tag, 0).to_str) - .to eq(expected) - end - - specify "::create" do - f = formula do - url "https://example.com/foo.tar.gz" - version "1.0" + context "when rebuild is 0" do + its(:extname) { is_expected.to eq ".tag.bottle.tar.gz" } end - expect(described_class.create(f, :tag, 0).to_s) - .to eq("formula_name-1.0.tag.bottle.tar.gz") + context "when rebuild is 1" do + let(:rebuild) { 1 } + its(:extname) { is_expected.to eq ".tag.bottle.1.tar.gz" } + end + end + + describe "#to_s and #to_str" do + its(:to_s) { is_expected.to eq "foo--1.0.tag.bottle.tar.gz" } + its(:to_str) { is_expected.to eq "foo--1.0.tag.bottle.tar.gz" } + end + + describe "#bintray" do + its(:bintray) { is_expected.to eq "foo-1.0.tag.bottle.tar.gz" } + end + + describe "#json" do + its(:json) { is_expected.to eq "foo--1.0.tag.bottle.json" } + + context "when rebuild is 1" do + its(:json) { is_expected.to eq "foo--1.0.tag.bottle.json" } + end + end + + describe "::create" do + subject { described_class.create(f, :tag, 0) } + + let(:f) { + formula do + url "https://example.com/foo.tar.gz" + version "1.0" + end + } + + its(:to_s) { is_expected.to eq "formula_name--1.0.tag.bottle.tar.gz" } end end diff --git a/Library/Homebrew/test/dev-cmd/bottle_spec.rb b/Library/Homebrew/test/dev-cmd/bottle_spec.rb index 1929908bda..b31f557bf2 100644 --- a/Library/Homebrew/test/dev-cmd/bottle_spec.rb +++ b/Library/Homebrew/test/dev-cmd/bottle_spec.rb @@ -21,11 +21,11 @@ describe "brew bottle", :integration_test do end expect { brew "bottle", "--no-rebuild", "testball" } - .to output(/testball-0\.1.*\.bottle\.tar\.gz/).to_stdout + .to output(/testball--0\.1.*\.bottle\.tar\.gz/).to_stdout .and not_to_output.to_stderr .and be_a_success ensure - FileUtils.rm_f Dir.glob("testball-0.1*.bottle.tar.gz") + FileUtils.rm_f Dir.glob("testball--0.1*.bottle.tar.gz") end end end