diff options
| author | mimaki <[email protected]> | 2019-10-29 20:56:12 +0900 |
|---|---|---|
| committer | mimaki <[email protected]> | 2019-10-29 20:56:12 +0900 |
| commit | f68212cc7a1d992b588309718f86bcfce02708a4 (patch) | |
| tree | 505d42b531dcad5e3b0191a13c5e9f171e3a6986 /lib | |
| parent | 34f68d01049d5124a7137783f34b3c5884d27fbc (diff) | |
| download | mruby-f68212cc7a1d992b588309718f86bcfce02708a4.tar.gz mruby-f68212cc7a1d992b588309718f86bcfce02708a4.zip | |
Fix file/directory name parameter for `git` command.
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/mruby/build/command.rb | 18 | ||||
| -rw-r--r-- | lib/mruby/lockfile.rb | 10 |
2 files changed, 22 insertions, 6 deletions
diff --git a/lib/mruby/build/command.rb b/lib/mruby/build/command.rb index 6e41e3db2..0a6d6b818 100644 --- a/lib/mruby/build/command.rb +++ b/lib/mruby/build/command.rb @@ -24,6 +24,14 @@ module MRuby target end + def shellquote(s) + if ENV['OS'] == 'Windows_NT' + "\"#{s}\"" + else + "#{s}" + end + end + NotFoundCommands = {} private @@ -278,9 +286,9 @@ module MRuby @command = 'git' @flags = %w[] @clone_options = "clone %{flags} %{url} %{dir}" - @pull_options = "--git-dir '%{repo_dir}/.git' --work-tree '%{repo_dir}' pull" - @checkout_options = "--git-dir '%{repo_dir}/.git' --work-tree '%{repo_dir}' checkout %{checksum_hash}" - @reset_options = "--git-dir '%{repo_dir}/.git' --work-tree '%{repo_dir}' reset %{checksum_hash}" + @pull_options = "--git-dir #{shellquote("%{repo_dir}/.git")} --work-tree #{shellquote("%{repo_dir}")} pull" + @checkout_options = "--git-dir #{shellquote("%{repo_dir}/.git")} --work-tree #{shellquote("%{repo_dir}")} checkout %{checksum_hash}" + @reset_options = "--git-dir #{shellquote("%{repo_dir}/.git")} --work-tree #{shellquote("%{repo_dir}")} reset %{checksum_hash}" end def run_clone(dir, url, _flags = []) @@ -304,11 +312,11 @@ module MRuby end def commit_hash(dir) - `#{@command} --git-dir '#{dir}/.git' --work-tree '#{dir}' rev-parse --verify HEAD`.strip + `#{@command} --git-dir #{shellquote(dir +'/.git')} --work-tree #{shellquote(dir)} rev-parse --verify HEAD`.strip end def current_branch(dir) - `#{@command} --git-dir '#{dir}/.git' --work-tree '#{dir}' rev-parse --abbrev-ref HEAD`.strip + `#{@command} --git-dir #{shellquote(dir + '/.git')} --work-tree #{shellquote(dir)} rev-parse --abbrev-ref HEAD`.strip end end diff --git a/lib/mruby/lockfile.rb b/lib/mruby/lockfile.rb index ce1442a89..0d2455b4c 100644 --- a/lib/mruby/lockfile.rb +++ b/lib/mruby/lockfile.rb @@ -54,6 +54,14 @@ module MRuby end end + def shellquote(s) + if ENV['OS'] == 'Windows_NT' + "\"#{s}\"" + else + "'#{s}'" + end + end + def mruby mruby = { 'version' => MRuby::Source::MRUBY_VERSION, @@ -62,7 +70,7 @@ module MRuby git_dir = "#{MRUBY_ROOT}/.git" if File.directory?(git_dir) - mruby['git_commit'] = `git --git-dir '#{git_dir}' --work-tree '#{MRUBY_ROOT}' rev-parse --verify HEAD`.strip + mruby['git_commit'] = `git --git-dir #{shellquote(git_dir)} --work-tree #{shellquote(MRUBY_ROOT)} rev-parse --verify HEAD`.strip end mruby |
