summaryrefslogtreecommitdiffhomepage
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/mruby/build.rb2
-rw-r--r--lib/mruby/build/command.rb26
-rw-r--r--lib/mruby/build/load_gems.rb13
3 files changed, 23 insertions, 18 deletions
diff --git a/lib/mruby/build.rb b/lib/mruby/build.rb
index 55b82cd2b..c080857a0 100644
--- a/lib/mruby/build.rb
+++ b/lib/mruby/build.rb
@@ -280,7 +280,7 @@ EOS
if name.is_a?(Array)
name.flatten.map { |n| cygwin_filename(n) }
else
- `cygpath -w "#{filename(name)}"`.strip
+ '"%s"' % `cygpath -w "#{filename(name)}"`.strip
end
end
diff --git a/lib/mruby/build/command.rb b/lib/mruby/build/command.rb
index 0a6d6b818..6eb4b6628 100644
--- a/lib/mruby/build/command.rb
+++ b/lib/mruby/build/command.rb
@@ -279,36 +279,42 @@ module MRuby
class Command::Git < Command
attr_accessor :flags
- attr_accessor :clone_options, :pull_options, :checkout_options, :reset_options
+ attr_accessor :clone_options, :pull_options, :checkout_options, :checkout_detach_options, :reset_options
def initialize(build)
super
@command = 'git'
@flags = %w[]
@clone_options = "clone %{flags} %{url} %{dir}"
- @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}"
+ @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}"
+ @checkout_detach_options = "--git-dir %{repo_dir}/.git --work-tree %{repo_dir} checkout --detach %{checksum_hash}"
+ @reset_options = "--git-dir %{repo_dir}/.git --work-tree %{repo_dir} reset %{checksum_hash}"
end
def run_clone(dir, url, _flags = [])
_pp "GIT", url, dir.relative_path
- _run clone_options, { :flags => [flags, _flags].flatten.join(' '), :url => url, :dir => filename(dir) }
+ _run clone_options, { :flags => [flags, _flags].flatten.join(' '), :url => shellquote(url), :dir => shellquote(filename(dir)) }
end
def run_pull(dir, url)
_pp "GIT PULL", url, dir.relative_path
- _run pull_options, { :repo_dir => dir }
+ _run pull_options, { :repo_dir => shellquote(dir) }
end
def run_checkout(dir, checksum_hash)
- _pp "GIT CHECKOUT", checksum_hash
- _run checkout_options, { :checksum_hash => checksum_hash, :repo_dir => dir }
+ _pp "GIT CHECKOUT", dir, checksum_hash
+ _run checkout_options, { :checksum_hash => checksum_hash, :repo_dir => shellquote(dir) }
+ end
+
+ def run_checkout_detach(dir, checksum_hash)
+ _pp "GIT CHECKOUT DETACH", dir, checksum_hash
+ _run checkout_detach_options, { :checksum_hash => checksum_hash, :repo_dir => shellquote(dir) }
end
def run_reset_hard(dir, checksum_hash)
- _pp "GIT RESET", checksum_hash
- _run reset_options, { :checksum_hash => checksum_hash, :repo_dir => dir }
+ _pp "GIT RESET", dir, checksum_hash
+ _run reset_options, { :checksum_hash => checksum_hash, :repo_dir => shellquote(dir) }
end
def commit_hash(dir)
diff --git a/lib/mruby/build/load_gems.rb b/lib/mruby/build/load_gems.rb
index f6deb5168..17035c459 100644
--- a/lib/mruby/build/load_gems.rb
+++ b/lib/mruby/build/load_gems.rb
@@ -86,14 +86,13 @@ module MRuby
if File.exist?(gemdir)
if $pull_gems
- git.run_pull gemdir, url
# Jump to the top of the branch
- git.run_checkout(gemdir, branch)
- git.run_reset_hard gemdir, "origin/#{branch}"
+ git.run_checkout gemdir, branch
+ git.run_pull gemdir, url
elsif params[:checksum_hash]
- git.run_reset_hard(gemdir, params[:checksum_hash])
+ git.run_checkout_detach gemdir, params[:checksum_hash]
elsif lock
- git.run_reset_hard(gemdir, lock['commit'])
+ git.run_checkout_detach gemdir, lock['commit']
end
else
options = [params[:options]] || []
@@ -105,9 +104,9 @@ module MRuby
# Jump to the specified commit
if params[:checksum_hash]
- git.run_reset_hard gemdir, params[:checksum_hash]
+ git.run_checkout_detach gemdir, params[:checksum_hash]
elsif lock
- git.run_reset_hard gemdir, lock['commit']
+ git.run_checkout_detach gemdir, lock['commit']
end
end