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
eac_tools-0.75.0 sub/avm-eac_webapp_base0/lib/avm/eac_webapp_base0/instances/deploy/scm.rb
avm-eac_webapp_base0-0.18.2 lib/avm/eac_webapp_base0/instances/deploy/scm.rb
eac_tools-0.74.1 sub/avm-eac_webapp_base0/lib/avm/eac_webapp_base0/instances/deploy/scm.rb
eac_tools-0.74.0 sub/avm-eac_webapp_base0/lib/avm/eac_webapp_base0/instances/deploy/scm.rb
eac_tools-0.73.0 sub/avm-eac_webapp_base0/lib/avm/eac_webapp_base0/instances/deploy/scm.rb
eac_tools-0.72.0 sub/avm-eac_webapp_base0/lib/avm/eac_webapp_base0/instances/deploy/scm.rb
avm-eac_webapp_base0-0.18.1 lib/avm/eac_webapp_base0/instances/deploy/scm.rb
eac_tools-0.70.1 sub/avm-eac_webapp_base0/lib/avm/eac_webapp_base0/instances/deploy/scm.rb
avm-eac_webapp_base0-0.18.0 lib/avm/eac_webapp_base0/instances/deploy/scm.rb
eac_tools-0.70.0 sub/avm-eac_webapp_base0/lib/avm/eac_webapp_base0/instances/deploy/scm.rb
eac_tools-0.69.1 sub/avm-eac_webapp_base0/lib/avm/eac_webapp_base0/instances/deploy/scm.rb
eac_tools-0.69.0 sub/avm-eac_webapp_base0/lib/avm/eac_webapp_base0/instances/deploy/scm.rb
eac_tools-0.68.0 sub/avm-eac_webapp_base0/lib/avm/eac_webapp_base0/instances/deploy/scm.rb
eac_tools-0.67.1 sub/avm-eac_webapp_base0/lib/avm/eac_webapp_base0/instances/deploy/scm.rb
avm-eac_webapp_base0-0.17.2 lib/avm/eac_webapp_base0/instances/deploy/scm.rb
eac_tools-0.67.0 sub/avm-eac_webapp_base0/lib/avm/eac_webapp_base0/instances/deploy/scm.rb
avm-eac_webapp_base0-0.17.1 lib/avm/eac_webapp_base0/instances/deploy/scm.rb
eac_tools-0.66.0 sub/avm-eac_webapp_base0/lib/avm/eac_webapp_base0/instances/deploy/scm.rb
eac_tools-0.65.1 sub/avm-eac_webapp_base0/lib/avm/eac_webapp_base0/instances/deploy/scm.rb
eac_tools-0.65.0 sub/avm-eac_webapp_base0/lib/avm/eac_webapp_base0/instances/deploy/scm.rb