diff options
author | David RodrÃguez <deivid.rodriguez@riseup.net> | 2021-08-04 08:40:56 +0200 |
---|---|---|
committer | Hiroshi SHIBATA <hsbt@ruby-lang.org> | 2021-08-31 19:06:14 +0900 |
commit | 8adc606271210acad490e93c47c3e1501407fb27 (patch) | |
tree | aeb33c52bbc6d22e2b9e8a3733d9bb65db0970c2 | |
parent | b6c082fd0951d22bc63582283d19f7c970829628 (diff) | |
download | ruby-8adc606271210acad490e93c47c3e1501407fb27.tar.gz |
[rubygems/rubygems] Fix git repo initialization on a path with spaces
https://github.com/rubygems/rubygems/commit/a2d6e10192
-rw-r--r-- | lib/bundler/cli/gem.rb | 3 | ||||
-rw-r--r-- | spec/bundler/commands/newgem_spec.rb | 11 |
2 files changed, 13 insertions, 1 deletions
diff --git a/lib/bundler/cli/gem.rb b/lib/bundler/cli/gem.rb index c9794c4003..43c3321053 100644 --- a/lib/bundler/cli/gem.rb +++ b/lib/bundler/cli/gem.rb @@ -192,7 +192,8 @@ module Bundler if use_git Bundler.ui.info "Initializing git repo in #{target}" - `git init #{target}` + require "shellwords" + `git init #{target.to_s.shellescape}` config[:git_default_branch] = File.read("#{target}/.git/HEAD").split("/").last.chomp end diff --git a/spec/bundler/commands/newgem_spec.rb b/spec/bundler/commands/newgem_spec.rb index 01f8a5daea..4ccf9be6a8 100644 --- a/spec/bundler/commands/newgem_spec.rb +++ b/spec/bundler/commands/newgem_spec.rb @@ -52,6 +52,17 @@ RSpec.describe "bundle gem" do gem_skeleton_assertions expect(bundled_app("#{gem_name}/.git")).not_to exist end + + context "on a path with spaces" do + before do + Dir.mkdir(bundled_app("path with spaces")) + end + + it "properly initializes git repo", :readline do + bundle "gem #{gem_name}", :dir => bundled_app("path with spaces") + expect(bundled_app("path with spaces/#{gem_name}/.git")).to exist + end + end end shared_examples_for "--mit flag" do |