Unverified Commit d1f32df4 authored by Scott Hain's avatar Scott Hain Committed by GitHub

Merge pull request #808 from ApicaSystem/fix-file-fetcher

Add ":file" to the list of supported sources
parents 68c30158 62e3a984
......@@ -292,7 +292,7 @@ module Omnibus
val = canonicalize_source(val)
extra_keys = val.keys - [
:git, :path, :url, # fetcher types
:git, :file, :path, :url, # fetcher types
:md5, :sha1, :sha256, :sha512, # hash type - common to all fetchers
:cookie, :warning, :unsafe, :extract, # used by net_fetcher
:options, # used by path_fetcher
......@@ -303,7 +303,7 @@ module Omnibus
"only include valid keys. Invalid keys: #{extra_keys.inspect}")
end
duplicate_keys = val.keys & [:git, :path, :url]
duplicate_keys = val.keys & [:git, :file, :path, :url]
unless duplicate_keys.size < 2
raise InvalidValue.new(:source,
"not include duplicate keys. Duplicate keys: #{duplicate_keys.inspect}")
......@@ -1053,6 +1053,8 @@ module Omnibus
:url
elsif source[:git]
:git
elsif source[:file]
:file
elsif source[:path]
:path
end
......
......@@ -824,6 +824,40 @@ module Omnibus
end
end
end
context "when given source is a local file path" do
let(:source) do
{
file: "../foo.tar.gz",
}
end
context "when relative_path is the same as name" do
let(:rel_path) { "software" }
it "for back-compat, changes fetch_dir" do
subject.send(:fetcher)
expect(subject.project_dir).to eq(File.expand_path("#{Config.source_dir}/software/software"))
end
it "sets the fetcher project_dir to project_dir" do
expect(subject.send(:fetcher).project_dir).to eq(File.expand_path("#{Config.source_dir}/software/software"))
end
end
context "when relative_path is different from name" do
let(:rel_path) { "foo" }
it "ignores back-compat and leaves fetch_dir alone" do
subject.send(:fetcher)
expect(subject.project_dir).to eq(File.expand_path("#{Config.source_dir}/software/foo"))
end
it "sets the fetcher project_dir to project_dir" do
expect(subject.send(:fetcher).project_dir).to eq(File.expand_path("#{Config.source_dir}/software/foo"))
end
end
end
end
describe "#canonicalize_source" do
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment