Sha256: 64d150b8e7999a3c982e8c574587d2bd85c2ff10d94034619c2412be7028ad07

Contents?: true

Size: 1.23 KB

Versions: 248

Compression:

Stored size: 1.23 KB

Contents

# frozen_string_literal: true

require 'avm/result'
require 'eac_ruby_utils/core_ext'

module Avm
  module Git
    class SubrepoCheck
      module Parent
        def fix_parent
          return if parent_result.success?

          info('  Fixing...')
          self.parent_hash = expected_parent_hash
          info_banner
        end

        private

        def expected_parent_hash_uncached
          subrepo.local.rev_parse("#{last_file_change_rev}^")
        end

        def last_file_change_rev
          subrepo.local.command('log', '-n', '1', '--pretty=format:%H', '--',
                                subrepo.config_relative_path.to_path).execute!.strip
        end

        def parent_hash
          subrepo.parent_commit_id
        end

        def parent_hash=(new_hash)
          subrepo.config.parent_commit_id = new_hash
          subrepo.write_config
        end

        def parent_hash_ok?
          return false if expected_parent_hash.blank? || parent_hash.blank?

          expected_parent_hash == parent_hash
        end

        def parent_result_uncached
          ::Avm::Result.success_or_error(parent_hash_ok?,
                                         parent_hash.presence || blank_text)
        end
      end
    end
  end
end

Version data entries

248 entries across 248 versions & 4 rubygems

Version Path
avm-git-0.18.0 lib/avm/git/subrepo_check/parent.rb
eac_tools-0.94.0 sub/avm-git/lib/avm/git/subrepo_check/parent.rb
avm-git-0.17.0 lib/avm/git/subrepo_check/parent.rb
eac_tools-0.86.5 sub/avm-git/lib/avm/git/subrepo_check/parent.rb
avm-git-0.16.0 lib/avm/git/subrepo_check/parent.rb
eac_tools-0.86.4 sub/avm-git/lib/avm/git/subrepo_check/parent.rb
eac_tools-0.86.3 sub/avm-git/lib/avm/git/subrepo_check/parent.rb
avm-git-0.15.0 lib/avm/git/subrepo_check/parent.rb
eac_tools-0.86.2 sub/avm-git/lib/avm/git/subrepo_check/parent.rb
eac_tools-0.84.0 sub/avm-git/lib/avm/git/subrepo_check/parent.rb
eac_tools-0.83.0 sub/avm-git/lib/avm/git/subrepo_check/parent.rb
eac_tools-0.82.0 sub/avm-git/lib/avm/git/subrepo_check/parent.rb
avm-git-0.14.0 lib/avm/git/subrepo_check/parent.rb
eac_tools-0.81.0 sub/avm-git/lib/avm/git/subrepo_check/parent.rb
eac_tools-0.80.0 sub/avm-git/lib/avm/git/subrepo_check/parent.rb
eac_tools-0.79.0 sub/avm-git/lib/avm/git/subrepo_check/parent.rb
eac_tools-0.78.0 sub/avm-git/lib/avm/git/subrepo_check/parent.rb
eac_tools-0.77.1 sub/avm-git/lib/avm/git/subrepo_check/parent.rb
eac_tools-0.77.0 sub/avm-git/lib/avm/git/subrepo_check/parent.rb
eac_tools-0.76.1 sub/avm-git/lib/avm/git/subrepo_check/parent.rb