Sha256: e8a86cbb929c7e2ee405af1e881e9f2c6266d9405399619a118644ee37cee723

Contents?: true

Size: 1.8 KB

Versions: 84

Compression:

Stored size: 1.8 KB

Contents

# frozen_string_literal: true

require 'avm/git/launcher/mirror_update'
require 'avm/launcher/instances/error'
require 'avm/git/vendor/github'
require 'avm/git/launcher_stereotypes/git/publish'

module Avm
  module Git
    module Launcher
      # Métodos abstratos:
      #  * source_instance
      #  * source_remote_name
      #  * current_ref
      class WarpBase < ::Avm::Launcher::Paths::Real
        include ::EacRubyUtils::SimpleCache

        TARGET_REMOTE = ::Avm::Git::LauncherStereotypes::Git::Publish::PUBLISH_GIT_REMOTE_NAME

        def initialize(instance)
          @instance = instance
          cache_git.git.reset_hard(current_ref)
          cache_git.remote(TARGET_REMOTE).url = target_remote_url
          super(path)
        end

        protected

        attr_reader :instance

        def validate_source_current_revision
          if source_git.rev_parse(source_instance.options.git_current_revision, false).present?
            return
          end

          raise ::Avm::Launcher::Instances::Error, 'Refspec ' \
            "\"#{source_instance.options.git_current_revision}\" not found in \"#{source_git}\""
        end

        def update
          validate_source_current_revision
          ::Avm::Git::Launcher::MirrorUpdate.new(
            path,
            source_instance.real,
            source_instance.options.git_current_revision
          )
        end

        def path
          instance.cache_path('git_repository')
        end

        def source_git_uncached
          ::Avm::Git::Launcher::Base.new(source_instance.real)
        end

        def cache_git_uncached
          ::Avm::Git::Launcher::Base.new(update)
        end

        def target_remote_url
          ::Avm::Git::Vendor::Github.to_ssh_url(source_git.git.remote(source_remote_name).url)
        end
      end
    end
  end
end

Version data entries

84 entries across 84 versions & 2 rubygems

Version Path
eac_tools-0.80.0 sub/avm-git/lib/avm/git/launcher/warp_base.rb
eac_tools-0.79.0 sub/avm-git/lib/avm/git/launcher/warp_base.rb
eac_tools-0.78.0 sub/avm-git/lib/avm/git/launcher/warp_base.rb
eac_tools-0.77.1 sub/avm-git/lib/avm/git/launcher/warp_base.rb
eac_tools-0.77.0 sub/avm-git/lib/avm/git/launcher/warp_base.rb
eac_tools-0.76.1 sub/avm-git/lib/avm/git/launcher/warp_base.rb
eac_tools-0.76.0 sub/avm-git/lib/avm/git/launcher/warp_base.rb
eac_tools-0.75.2 sub/avm-git/lib/avm/git/launcher/warp_base.rb
avm-git-0.13.4 lib/avm/git/launcher/warp_base.rb
eac_tools-0.75.1 sub/avm-git/lib/avm/git/launcher/warp_base.rb
eac_tools-0.75.0 sub/avm-git/lib/avm/git/launcher/warp_base.rb
eac_tools-0.74.1 sub/avm-git/lib/avm/git/launcher/warp_base.rb
eac_tools-0.74.0 sub/avm-git/lib/avm/git/launcher/warp_base.rb
eac_tools-0.73.0 sub/avm-git/lib/avm/git/launcher/warp_base.rb
eac_tools-0.72.0 sub/avm-git/lib/avm/git/launcher/warp_base.rb
eac_tools-0.70.1 sub/avm-git/lib/avm/git/launcher/warp_base.rb
eac_tools-0.70.0 sub/avm-git/lib/avm/git/launcher/warp_base.rb
eac_tools-0.69.1 sub/avm-git/lib/avm/git/launcher/warp_base.rb
eac_tools-0.69.0 sub/avm-git/lib/avm/git/launcher/warp_base.rb
eac_tools-0.68.0 sub/avm-git/lib/avm/git/launcher/warp_base.rb