Sha256: a1d2477fa1df0e2d8bb8d306d21822cdde8e8ac61fc30b203233e53232e8bbbd

Contents?: true

Size: 1.7 KB

Versions: 9

Compression:

Stored size: 1.7 KB

Contents

# frozen_string_literal: true

require 'avm/core_ext'
require 'eac_git/local'

module Avm
  module Tools
    class Runner
      class Git
        class Subrepo
          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,
                                              [::Avm::Git::AutoCommit::Rules::Unique.new]).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.103.0 lib/avm/tools/runner/git/subrepo/fix.rb
avm-tools-0.102.2 lib/avm/tools/runner/git/subrepo/fix.rb
avm-tools-0.102.1 lib/avm/tools/runner/git/subrepo/fix.rb
avm-tools-0.102.0 lib/avm/tools/runner/git/subrepo/fix.rb
avm-tools-0.101.0 lib/avm/tools/runner/git/subrepo/fix.rb
avm-tools-0.100.0 lib/avm/tools/runner/git/subrepo/fix.rb
avm-tools-0.99.1 lib/avm/tools/runner/git/subrepo/fix.rb
avm-tools-0.99.0 lib/avm/tools/runner/git/subrepo/fix.rb
avm-tools-0.98.0 lib/avm/tools/runner/git/subrepo/fix.rb