lib/avm/tools/runner/app_src/ruby/bundler/gemfile_lock.rb in avm-tools-0.105.0 vs lib/avm/tools/runner/app_src/ruby/bundler/gemfile_lock.rb in avm-tools-0.106.0

- old
+ new

@@ -7,22 +7,25 @@ class Runner class AppSrc class Ruby class Bundler class GemfileLock + require_sub __FILE__, include_modules: true runner_with :help do desc 'Manipulage a "Gemfile.lock" file.' bool_opt '-c', '--continue', 'Continue Git rebase/cherry-pick.' bool_opt '-i', '--install', 'Run "bundle install".' bool_opt '-u', '--update', 'Run "bundle update".' bool_opt '-r', '--recursive', 'Run until Git rebase/cherry-pick is finished.' - bool_opt '-a', '--all', 'Same as "-ciru".' + bool_opt '-a', '--all', 'Same as "-cirud".' + bool_opt '-d', '--delete', 'Delete Gemfile.lock' end def run loop do git_reset_checkout + delete_gemfile_lock bundle_update bundle_install git_continue break if complete? end @@ -32,23 +35,20 @@ def complete? !option_or_all?(:recursive) || !conflict? end + def delete_gemfile_lock + return unless check_capability(__method__, nil, :delete) + + ::FileUtils.rm_f(gemfile_lock) + end + def rebasing? instance.git_repo.root_path.join('.git', 'rebase-merge').exist? end - def git_reset_checkout - return unless check_capability(__method__, :git_repo, nil) - - infom 'Reseting...' - instance.git_repo.command('reset', gemfile_lock).system! - infom 'Checkouting...' - instance.git_repo.command('checkout', '--', gemfile_lock).system! - end - def bundle_install return unless check_capability(__method__, :ruby_gem, :install) infom '"bundle install"...' bundle_run('install') @@ -59,48 +59,18 @@ infom '"bundle update"...' bundle_run('update') end - def git_continue - return unless check_capability(__method__, :git_repo, :continue) - - infom "Adding \"#{gemfile_lock}\"..." - instance.git_repo.command('add', gemfile_lock).execute! - if rebase_conflict? - git_continue_run('rebase') - elsif cherry_conflict? - git_continue_run('cherry-pick') - else - raise 'Unknown how to continue' - end - end - - def git_continue_run(command) - infom "\"#{command}\" --continue..." - cmd = instance.git_repo.command(command, '--continue').envvar('GIT_EDITOR', 'true') - return unless !cmd.system && !conflict? - - fatal_error "\"#{cmd}\" failed and there is no conflict" - end - def gemfile_lock 'Gemfile.lock' end - def git_uncached - ::EacGit::Local.new(git_path) - end - def bundle_run(*args) instance.ruby_gem.bundle(*args).system! end - def git_path - '.' - end - def conflict? rebase_conflict? || cherry_conflict? end def rebase_conflict? @@ -119,10 +89,10 @@ runner_context.call(:instance) end def check_capability(caller, capability, option) return false unless option.blank? || option_or_all?(option) - return true if instance.respond_to?(capability) + return true if capability.if_present(true) { |v| instance.respond_to?(v) } warn "Cannot run #{caller}: instance has no capability \"#{capability}\"" false end end