Sha256: 4f0d402a66c1b4efa6a11aed6077e753e555d08274e74c97f4818c2a5822717f

Contents?: true

Size: 1.71 KB

Versions: 6

Compression:

Stored size: 1.71 KB

Contents

# frozen_string_literal: true

module Avm
  module EacWebappBase0
    module Instances
      class Deploy
        module GitInfo
          def commit_sha1_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.fetch(git_remote_name)
          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_hashs(git_remote_name)
          end

          def git_remote_name
            ::Avm::Git::DEFAULT_REMOTE_NAME
          end

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

          def git_uncached
            ::Avm::Launcher::Git::Base.new(git_repository_path)
          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
        end
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 2 rubygems

Version Path
avm-eac_webapp_base0-0.9.1 lib/avm/eac_webapp_base0/instances/deploy/git_info.rb
eac_tools-0.35.0 sub/avm-eac_webapp_base0/lib/avm/eac_webapp_base0/instances/deploy/git_info.rb
eac_tools-0.34.0 sub/avm-eac_webapp_base0/lib/avm/eac_webapp_base0/instances/deploy/git_info.rb
eac_tools-0.33.0 sub/avm-eac_webapp_base0/lib/avm/eac_webapp_base0/instances/deploy/git_info.rb
avm-eac_webapp_base0-0.9.0 lib/avm/eac_webapp_base0/instances/deploy/git_info.rb
eac_tools-0.32.0 sub/avm-eac_webapp_base0/lib/avm/eac_webapp_base0/instances/deploy/git_info.rb