Sha256: 9b3be8fe3fc29ad8f8d9d8333d1221b7990d3523b0775933cf4cf99eec604c9f

Contents?: true

Size: 1.87 KB

Versions: 91

Compression:

Stored size: 1.87 KB

Contents

# frozen_string_literal: true

module Avm
  module EacWebappBase0
    module Instances
      class Deploy
        module Scm
          DEFAULT_REMOTE_NAME = 'origin'

          def commit_reference_uncached
            git_fetch
            r = git.rev_parse(git_reference_found)
            return r if r

            raise ::Avm::Result::Error, "No commit SHA1 found for \"#{git_reference_found}\""
          end

          def git_fetch_uncached
            infom "Fetching remote \"#{git_remote_name}\" from \"#{git_repository_path}\"..."
            git.remote(git_remote_name).fetch
          end

          def git_reference
            options[OPTION_REFERENCE] || DEFAULT_REFERENCE
          end

          def git_reference_found_uncached
            %w[git_reference instance_branch master_branch].map { |b| send(b) }.find(&:present?) ||
              raise(
                ::Avm::Result::Error,
                'No git reference found (Searched for option, instance and master)'
              )
          end

          def git_remote_hashs_uncached
            git.remote(git_remote_name).ls.hashes
          end

          def git_remote_name
            DEFAULT_REMOTE_NAME
          end

          def git_repository_path
            instance.source_instance.read_entry(::Avm::Instances::EntryKeys::INSTALL_PATH)
          end

          # @return [EacGit::Local]
          def git_uncached
            scm.git_repo
          end

          def instance_branch
            remote_branch(instance.id)
          end

          def remote_branch(name)
            git_remote_hashs.key?("refs/heads/#{name}") ? "#{git_remote_name}/#{name}" : nil
          end

          def master_branch
            remote_branch('master')
          end

          # @return [Avm::Scms::Base]
          def scm
            instance.application.local_source.scm
          end
        end
      end
    end
  end
end

Version data entries

91 entries across 91 versions & 2 rubygems

Version Path
avm-eac_webapp_base0-0.19.0 lib/avm/eac_webapp_base0/instances/deploy/scm.rb
eac_tools-0.87.0 sub/avm-eac_webapp_base0/lib/avm/eac_webapp_base0/instances/deploy/scm.rb
avm-eac_webapp_base0-0.18.4 lib/avm/eac_webapp_base0/instances/deploy/scm.rb
eac_tools-0.86.8 sub/avm-eac_webapp_base0/lib/avm/eac_webapp_base0/instances/deploy/scm.rb
eac_tools-0.84.2 sub/avm-eac_webapp_base0/lib/avm/eac_webapp_base0/instances/deploy/scm.rb
avm-eac_webapp_base0-0.18.3 lib/avm/eac_webapp_base0/instances/deploy/scm.rb
eac_tools-0.84.1 sub/avm-eac_webapp_base0/lib/avm/eac_webapp_base0/instances/deploy/scm.rb
eac_tools-0.84.0 sub/avm-eac_webapp_base0/lib/avm/eac_webapp_base0/instances/deploy/scm.rb
eac_tools-0.83.0 sub/avm-eac_webapp_base0/lib/avm/eac_webapp_base0/instances/deploy/scm.rb
eac_tools-0.82.0 sub/avm-eac_webapp_base0/lib/avm/eac_webapp_base0/instances/deploy/scm.rb
eac_tools-0.81.0 sub/avm-eac_webapp_base0/lib/avm/eac_webapp_base0/instances/deploy/scm.rb
eac_tools-0.80.0 sub/avm-eac_webapp_base0/lib/avm/eac_webapp_base0/instances/deploy/scm.rb
eac_tools-0.79.0 sub/avm-eac_webapp_base0/lib/avm/eac_webapp_base0/instances/deploy/scm.rb
eac_tools-0.78.0 sub/avm-eac_webapp_base0/lib/avm/eac_webapp_base0/instances/deploy/scm.rb
eac_tools-0.77.1 sub/avm-eac_webapp_base0/lib/avm/eac_webapp_base0/instances/deploy/scm.rb
eac_tools-0.77.0 sub/avm-eac_webapp_base0/lib/avm/eac_webapp_base0/instances/deploy/scm.rb
eac_tools-0.76.1 sub/avm-eac_webapp_base0/lib/avm/eac_webapp_base0/instances/deploy/scm.rb
eac_tools-0.76.0 sub/avm-eac_webapp_base0/lib/avm/eac_webapp_base0/instances/deploy/scm.rb
eac_tools-0.75.2 sub/avm-eac_webapp_base0/lib/avm/eac_webapp_base0/instances/deploy/scm.rb
eac_tools-0.75.1 sub/avm-eac_webapp_base0/lib/avm/eac_webapp_base0/instances/deploy/scm.rb