ruby-changes:67424
From: David <ko1@a...>
Date: Tue, 31 Aug 2021 19:07:10 +0900 (JST)
Subject: [ruby-changes:67424] 8adc606271 (master): [rubygems/rubygems] Fix git repo initialization on a path with spaces
https://git.ruby-lang.org/ruby.git/commit/?id=8adc606271 From 8adc606271210acad490e93c47c3e1501407fb27 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20Rodr=C3=ADguez?= <deivid.rodriguez@r...> Date: Wed, 4 Aug 2021 08:40:56 +0200 Subject: [rubygems/rubygems] Fix git repo initialization on a path with spaces https://github.com/rubygems/rubygems/commit/a2d6e10192 --- lib/bundler/cli/gem.rb | 3 ++- spec/bundler/commands/newgem_spec.rb | 11 +++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/lib/bundler/cli/gem.rb b/lib/bundler/cli/gem.rb index c9794c4..43c3321 100644 --- a/lib/bundler/cli/gem.rb +++ b/lib/bundler/cli/gem.rb @@ -192,7 +192,8 @@ module Bundler https://github.com/ruby/ruby/blob/trunk/lib/bundler/cli/gem.rb#L192 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 01f8a5d..4ccf9be 100644 --- a/spec/bundler/commands/newgem_spec.rb +++ b/spec/bundler/commands/newgem_spec.rb @@ -52,6 +52,17 @@ RSpec.describe "bundle gem" do https://github.com/ruby/ruby/blob/trunk/spec/bundler/commands/newgem_spec.rb#L52 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 -- cgit v1.1 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/