From dc15c2838f5aff6c7daddc7993ce2bb4719d634b Mon Sep 17 00:00:00 2001 From: dearblue Date: Sun, 22 Dec 2019 14:01:53 +0900 Subject: Display directory with git command --- lib/mruby/build/command.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'lib') diff --git a/lib/mruby/build/command.rb b/lib/mruby/build/command.rb index 2b26ad20b..f2d735c34 100644 --- a/lib/mruby/build/command.rb +++ b/lib/mruby/build/command.rb @@ -302,12 +302,12 @@ module MRuby end def run_checkout(dir, checksum_hash) - _pp "GIT CHECKOUT", checksum_hash + _pp "GIT CHECKOUT", dir, checksum_hash _run checkout_options, { :checksum_hash => checksum_hash, :repo_dir => shellquote(dir) } end def run_reset_hard(dir, checksum_hash) - _pp "GIT RESET", checksum_hash + _pp "GIT RESET", dir, checksum_hash _run reset_options, { :checksum_hash => checksum_hash, :repo_dir => shellquote(dir) } end -- cgit v1.2.3 From f08d9b288db5faf92282ae3c2ac2c970e73bdc00 Mon Sep 17 00:00:00 2001 From: dearblue Date: Sun, 15 Dec 2019 13:07:31 +0900 Subject: Use `git checkout` instead of `git reset` With this change, if the checkout fails, it will stop with an error. The purpose is to avoid deleting working branch history when developing gem. --- lib/mruby/build/command.rb | 8 +++++++- lib/mruby/build/load_gems.rb | 13 ++++++------- 2 files changed, 13 insertions(+), 8 deletions(-) (limited to 'lib') diff --git a/lib/mruby/build/command.rb b/lib/mruby/build/command.rb index f2d735c34..6eb4b6628 100644 --- a/lib/mruby/build/command.rb +++ b/lib/mruby/build/command.rb @@ -279,7 +279,7 @@ 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 @@ -288,6 +288,7 @@ module MRuby @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}" + @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 @@ -306,6 +307,11 @@ module MRuby _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", dir, checksum_hash _run reset_options, { :checksum_hash => checksum_hash, :repo_dir => shellquote(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 -- cgit v1.2.3