Skip to content

Commit

Permalink
Fix using the gemspec DSL on a path with brackets in its name
Browse files Browse the repository at this point in the history
  • Loading branch information
deivid-rodriguez committed Sep 29, 2020
1 parent c0d38ce commit 7fe7e7b
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 3 deletions.
2 changes: 1 addition & 1 deletion bundler/lib/bundler/dsl.rb
Expand Up @@ -63,7 +63,7 @@ def gemspec(opts = nil)
development_group = opts[:development_group] || :development
expanded_path = gemfile_root.join(path)

gemspecs = Dir[File.join(expanded_path, "{,*}.gemspec")].map {|g| Bundler.load_gemspec(g) }.compact
gemspecs = Gem::Util.glob_files_in_dir("{,*}.gemspec", expanded_path).map {|g| Bundler.load_gemspec(g) }.compact
gemspecs.reject! {|s| s.name != name } if name
Index.sort_specs(gemspecs)
specs_by_name_and_version = gemspecs.group_by {|s| [s.name, s.version] }
Expand Down
2 changes: 1 addition & 1 deletion bundler/lib/bundler/source/path.rb
Expand Up @@ -171,7 +171,7 @@ def load_spec_files

if File.directory?(expanded_path)
# We sort depth-first since `<<` will override the earlier-found specs
Dir["#{expanded_path}/#{@glob}"].sort_by {|p| -p.split(File::SEPARATOR).size }.each do |file|
Gem::Util.glob_files_in_dir(@glob, expanded_path).sort_by {|p| -p.split(File::SEPARATOR).size }.each do |file|
next unless spec = load_gemspec(file)
spec.source = self

Expand Down
18 changes: 17 additions & 1 deletion bundler/spec/commands/install_spec.rb
Expand Up @@ -511,7 +511,7 @@
end

describe "when Bundler root contains regex chars" do
it "doesn't blow up" do
it "doesn't blow up when using the `gem` DSL" do
root_dir = tmp("foo[]bar")

FileUtils.mkdir_p(root_dir)
Expand All @@ -526,6 +526,22 @@

bundle :install, :dir => root_dir
end

it "doesn't blow up when using the `gemspec` DSL" do
root_dir = tmp("foo[]bar")

FileUtils.mkdir_p(root_dir)

build_lib "foo", :path => root_dir
gemfile = <<-G
gemspec
G
File.open("#{root_dir}/Gemfile", "w") do |file|
file.puts gemfile
end

bundle :install, :dir => root_dir
end
end

describe "when requesting a quiet install via --quiet" do
Expand Down

0 comments on commit 7fe7e7b

Please sign in to comment.