Unverified Commit fdc0219d authored by Yukihiro "Matz" Matsumoto's avatar Yukihiro "Matz" Matsumoto Committed by GitHub

Merge pull request #4798 from mimaki/fix-git-params-for-windows

Fix `git` command parameter for Windows.
parents ecdc6c65 f68212cc
...@@ -24,6 +24,14 @@ module MRuby ...@@ -24,6 +24,14 @@ module MRuby
target target
end end
def shellquote(s)
if ENV['OS'] == 'Windows_NT'
"\"#{s}\""
else
"#{s}"
end
end
NotFoundCommands = {} NotFoundCommands = {}
private private
...@@ -278,9 +286,9 @@ module MRuby ...@@ -278,9 +286,9 @@ module MRuby
@command = 'git' @command = 'git'
@flags = %w[] @flags = %w[]
@clone_options = "clone %{flags} %{url} %{dir}" @clone_options = "clone %{flags} %{url} %{dir}"
@pull_options = "--git-dir '%{repo_dir}/.git' --work-tree '%{repo_dir}' pull" @pull_options = "--git-dir #{shellquote("%{repo_dir}/.git")} --work-tree #{shellquote("%{repo_dir}")} pull"
@checkout_options = "--git-dir '%{repo_dir}/.git' --work-tree '%{repo_dir}' checkout %{checksum_hash}" @checkout_options = "--git-dir #{shellquote("%{repo_dir}/.git")} --work-tree #{shellquote("%{repo_dir}")} checkout %{checksum_hash}"
@reset_options = "--git-dir '%{repo_dir}/.git' --work-tree '%{repo_dir}' reset %{checksum_hash}" @reset_options = "--git-dir #{shellquote("%{repo_dir}/.git")} --work-tree #{shellquote("%{repo_dir}")} reset %{checksum_hash}"
end end
def run_clone(dir, url, _flags = []) def run_clone(dir, url, _flags = [])
...@@ -304,11 +312,11 @@ module MRuby ...@@ -304,11 +312,11 @@ module MRuby
end end
def commit_hash(dir) 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 end
def current_branch(dir) 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
end end
......
...@@ -54,6 +54,14 @@ module MRuby ...@@ -54,6 +54,14 @@ module MRuby
end end
end end
def shellquote(s)
if ENV['OS'] == 'Windows_NT'
"\"#{s}\""
else
"'#{s}'"
end
end
def mruby def mruby
mruby = { mruby = {
'version' => MRuby::Source::MRUBY_VERSION, 'version' => MRuby::Source::MRUBY_VERSION,
...@@ -62,7 +70,7 @@ module MRuby ...@@ -62,7 +70,7 @@ module MRuby
git_dir = "#{MRUBY_ROOT}/.git" git_dir = "#{MRUBY_ROOT}/.git"
if File.directory?(git_dir) 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 end
mruby mruby
......
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