Sha256: e2b591def1256d461c826503f5db5fe3a6c9a385cf02687375bbafbcebf0ba9f

Contents?: true

Size: 1.78 KB

Versions: 9

Compression:

Stored size: 1.78 KB

Contents

# frozen_string_literal: true

require 'eac_cli/core_ext'
require 'eac_git/local'
require 'eac_ruby_utils/console/docopt_runner'

module Avm
  module Tools
    class Runner < ::EacRubyUtils::Console::DocoptRunner
      class Git < ::EacRubyUtils::Console::DocoptRunner
        class Subrepo < ::EacRubyUtils::Console::DocoptRunner
          class Fix
            runner_with :help do
              desc 'Fix git-subrepos\' parent property.'
            end

            def run
              loop do
                break if fix

                amend_each
                rebase_fixup
              end
            end

            private

            def amend_each
              infov 'Dirty files', local_repos.dirty_files.count
              local_repos.dirty_files.each do |file|
                infov '  * Ammending', file.path
                ::Avm::Git::FileAutoFixup.new(runner_context.call(:git), file.path).run
              end
            end

            def fix
              infom 'Checking/fixing...'
              c = new_check(true)
              c.show_result
              !c.result.error?
            end

            def new_check(fix_parent = false)
              r = ::Avm::Git::SubrepoChecks.new(local_repos).add_all_subrepos
              r.fix_parent = fix_parent
              r
            end

            def local_repos_uncached
              ::EacGit::Local.new(runner_context.call(:git))
            end

            def rebase_fixup
              local_repos.command('rebase', '-i', 'origin/master', '--autosquash').envvar(
                'GIT_SEQUENCE_EDITOR', 'true'
              ).or(
                local_repos.command('rebase', '--continue').envvar('GIT_SEQUENCE_EDITOR', 'true')
              ).system!
            end
          end
        end
      end
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
avm-tools-0.86.0 lib/avm/tools/runner/git/subrepo/fix.rb
avm-tools-0.85.1 lib/avm/tools/runner/git/subrepo/fix.rb
avm-tools-0.85.0 lib/avm/tools/runner/git/subrepo/fix.rb
avm-tools-0.84.0 lib/avm/tools/runner/git/subrepo/fix.rb
avm-tools-0.83.0 lib/avm/tools/runner/git/subrepo/fix.rb
avm-tools-0.82.1 lib/avm/tools/runner/git/subrepo/fix.rb
avm-tools-0.82.0 lib/avm/tools/runner/git/subrepo/fix.rb
avm-tools-0.81.0 lib/avm/tools/runner/git/subrepo/fix.rb
avm-tools-0.80.0 lib/avm/tools/runner/git/subrepo/fix.rb