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
eac_tools-0.8.0 sub/avm-tools/sub/avm-git/lib/avm/git/subrepo_check/parent.rb
eac_tools-0.7.0 sub/avm-tools/sub/avm-git/lib/avm/git/subrepo_check/parent.rb
eac_tools-0.6.0 sub/avm-tools/sub/avm-git/lib/avm/git/subrepo_check/parent.rb
avm-tools-0.121.2 sub/avm-git/lib/avm/git/subrepo_check/parent.rb
eac_tools-0.5.0 sub/avm-tools/sub/avm-git/lib/avm/git/subrepo_check/parent.rb
eac_tools-0.4.0 sub/avm-tools/sub/avm-git/lib/avm/git/subrepo_check/parent.rb
eac_tools-0.3.0 sub/avm-tools/sub/avm-git/lib/avm/git/subrepo_check/parent.rb
eac_tools-0.2.2 sub/avm-tools/sub/avm-git/lib/avm/git/subrepo_check/parent.rb
avm-tools-0.121.1 sub/avm-git/lib/avm/git/subrepo_check/parent.rb
avm-tools-0.121.0 sub/avm-git/lib/avm/git/subrepo_check/parent.rb
avm-tools-0.120.2 sub/avm-git/lib/avm/git/subrepo_check/parent.rb
avm-tools-0.120.1 sub/avm-git/lib/avm/git/subrepo_check/parent.rb
avm-tools-0.120.0 sub/avm-git/lib/avm/git/subrepo_check/parent.rb
avm-tools-0.119.0 sub/avm-git/lib/avm/git/subrepo_check/parent.rb
avm-tools-0.118.0 sub/avm-git/lib/avm/git/subrepo_check/parent.rb
avm-tools-0.117.3 sub/avm-git/lib/avm/git/subrepo_check/parent.rb
avm-tools-0.117.2 sub/avm-git/lib/avm/git/subrepo_check/parent.rb
avm-tools-0.117.1 sub/avm-git/lib/avm/git/subrepo_check/parent.rb
avm-git-0.4.0 lib/avm/git/subrepo_check/parent.rb
avm-tools-0.117.0 sub/avm-git/lib/avm/git/subrepo_check/parent.rb