Sha256: 1bd38271b29766de11ec1e9545f012dc76ad35b36a8492620230fd4344ded5f5

Contents?: true

Size: 1.71 KB

Versions: 13

Compression:

Stored size: 1.71 KB

Contents

# frozen_string_literal: true

require 'avm/tools/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

13 entries across 13 versions & 1 rubygems

Version Path
avm-tools-0.113.1 lib/avm/tools/runner/git/subrepo/fix.rb
avm-tools-0.113.0 lib/avm/tools/runner/git/subrepo/fix.rb
avm-tools-0.112.0 lib/avm/tools/runner/git/subrepo/fix.rb
avm-tools-0.111.0 lib/avm/tools/runner/git/subrepo/fix.rb
avm-tools-0.110.0 lib/avm/tools/runner/git/subrepo/fix.rb
avm-tools-0.109.1 lib/avm/tools/runner/git/subrepo/fix.rb
avm-tools-0.109.0 lib/avm/tools/runner/git/subrepo/fix.rb
avm-tools-0.108.0 lib/avm/tools/runner/git/subrepo/fix.rb
avm-tools-0.107.0 lib/avm/tools/runner/git/subrepo/fix.rb
avm-tools-0.106.0 lib/avm/tools/runner/git/subrepo/fix.rb
avm-tools-0.105.0 lib/avm/tools/runner/git/subrepo/fix.rb
avm-tools-0.104.0 lib/avm/tools/runner/git/subrepo/fix.rb
avm-tools-0.103.1 lib/avm/tools/runner/git/subrepo/fix.rb