Sha256: a5ec6ea005d02d0c377042a50540d1c66b18c67a507248faba62fddc0b810ad7

Contents?: true

Size: 1.58 KB

Versions: 19

Compression:

Stored size: 1.58 KB

Contents

# frozen_string_literal: true

module Avm
  module EacWebappBase0
    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[: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::FS_PATH)
        end

        def git_uncached
          ::EacLauncher::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

Version data entries

19 entries across 19 versions & 1 rubygems

Version Path
avm-tools-0.88.0 lib/avm/eac_webapp_base0/deploy/git_info.rb
avm-tools-0.87.1 lib/avm/eac_webapp_base0/deploy/git_info.rb
avm-tools-0.87.0 lib/avm/eac_webapp_base0/deploy/git_info.rb
avm-tools-0.86.0 lib/avm/eac_webapp_base0/deploy/git_info.rb
avm-tools-0.85.1 lib/avm/eac_webapp_base0/deploy/git_info.rb
avm-tools-0.85.0 lib/avm/eac_webapp_base0/deploy/git_info.rb
avm-tools-0.84.0 lib/avm/eac_webapp_base0/deploy/git_info.rb
avm-tools-0.83.0 lib/avm/eac_webapp_base0/deploy/git_info.rb
avm-tools-0.82.1 lib/avm/eac_webapp_base0/deploy/git_info.rb
avm-tools-0.82.0 lib/avm/eac_webapp_base0/deploy/git_info.rb
avm-tools-0.81.0 lib/avm/eac_webapp_base0/deploy/git_info.rb
avm-tools-0.80.0 lib/avm/eac_webapp_base0/deploy/git_info.rb
avm-tools-0.79.0 lib/avm/eac_webapp_base0/deploy/git_info.rb
avm-tools-0.78.0 lib/avm/eac_webapp_base0/deploy/git_info.rb
avm-tools-0.77.0 lib/avm/eac_webapp_base0/deploy/git_info.rb
avm-tools-0.76.1 lib/avm/eac_webapp_base0/deploy/git_info.rb
avm-tools-0.76.0 lib/avm/eac_webapp_base0/deploy/git_info.rb
avm-tools-0.75.1 lib/avm/eac_webapp_base0/deploy/git_info.rb
avm-tools-0.75.0 lib/avm/eac_webapp_base0/deploy/git_info.rb