Use -- to separate download name and version.
This commit is contained in:
parent
76243269c0
commit
1003d722bd
@ -1,6 +1,7 @@
|
|||||||
require "compat/os/mac"
|
require "compat/os/mac"
|
||||||
require "compat/dependable"
|
require "compat/dependable"
|
||||||
require "compat/dependency_collector"
|
require "compat/dependency_collector"
|
||||||
|
require "compat/download_strategy"
|
||||||
require "compat/fileutils"
|
require "compat/fileutils"
|
||||||
require "compat/formula_support"
|
require "compat/formula_support"
|
||||||
require "compat/hbc"
|
require "compat/hbc"
|
||||||
|
|||||||
16
Library/Homebrew/compat/download_strategy.rb
Normal file
16
Library/Homebrew/compat/download_strategy.rb
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
class AbstractFileDownloadStrategy
|
||||||
|
# TODO: This can be removed after a month because downloads
|
||||||
|
# will be outdated anyways at that point.
|
||||||
|
module Compat
|
||||||
|
def initialize(url, name, version, **meta)
|
||||||
|
super
|
||||||
|
|
||||||
|
old_cached_location = @cache/"#{name}-#{version}#{ext}"
|
||||||
|
|
||||||
|
return unless old_cached_location.exist?
|
||||||
|
FileUtils.mv old_cached_location, cached_location, force: true
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
prepend Compat
|
||||||
|
end
|
||||||
@ -181,7 +181,7 @@ class AbstractFileDownloadStrategy < AbstractDownloadStrategy
|
|||||||
|
|
||||||
def initialize(url, name, version, **meta)
|
def initialize(url, name, version, **meta)
|
||||||
super
|
super
|
||||||
@cached_location = @cache/"#{name}-#{version}#{ext}"
|
@cached_location = @cache/"#{name}--#{version}#{ext}"
|
||||||
@temporary_path = Pathname.new("#{cached_location}.incomplete")
|
@temporary_path = Pathname.new("#{cached_location}.incomplete")
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@ -2,10 +2,10 @@ describe "brew fetch", :integration_test do
|
|||||||
it "downloads the Formula's URL" do
|
it "downloads the Formula's URL" do
|
||||||
setup_test_formula "testball"
|
setup_test_formula "testball"
|
||||||
|
|
||||||
expect(HOMEBREW_CACHE/"testball-0.1.tbz").not_to exist
|
expect(HOMEBREW_CACHE/"testball--0.1.tbz").not_to exist
|
||||||
|
|
||||||
expect { brew "fetch", "testball" }.to be_a_success
|
expect { brew "fetch", "testball" }.to be_a_success
|
||||||
|
|
||||||
expect(HOMEBREW_CACHE/"testball-0.1.tbz").to exist
|
expect(HOMEBREW_CACHE/"testball--0.1.tbz").to exist
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@ -238,13 +238,13 @@ describe CurlDownloadStrategy do
|
|||||||
subject { described_class.new(url, name, version, **specs).cached_location }
|
subject { described_class.new(url, name, version, **specs).cached_location }
|
||||||
|
|
||||||
context "when URL ends with file" do
|
context "when URL ends with file" do
|
||||||
it { is_expected.to eq(HOMEBREW_CACHE/"foo-.tar.gz") }
|
it { is_expected.to eq(HOMEBREW_CACHE/"foo--.tar.gz") }
|
||||||
end
|
end
|
||||||
|
|
||||||
context "when URL file is in middle" do
|
context "when URL file is in middle" do
|
||||||
let(:url) { "http://example.com/foo.tar.gz/from/this/mirror" }
|
let(:url) { "http://example.com/foo.tar.gz/from/this/mirror" }
|
||||||
|
|
||||||
it { is_expected.to eq(HOMEBREW_CACHE/"foo-.tar.gz") }
|
it { is_expected.to eq(HOMEBREW_CACHE/"foo--.tar.gz") }
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user