Module: Avm::EacWebappBase0::Deploy::GitInfo

Defined in:
lib/avm/eac_webapp_base0/deploy/git_info.rb

Instance Method Summary collapse

Instance Method Details

#commit_sha1_uncachedObject



7
8
9
10
11
12
13
# File 'lib/avm/eac_webapp_base0/deploy/git_info.rb', line 7

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

#git_fetch_uncachedObject



15
16
17
18
# File 'lib/avm/eac_webapp_base0/deploy/git_info.rb', line 15

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

#git_referenceObject



20
21
22
# File 'lib/avm/eac_webapp_base0/deploy/git_info.rb', line 20

def git_reference
  options[OPTION_REFERENCE] || DEFAULT_REFERENCE
end

#git_reference_found_uncachedObject



24
25
26
27
28
29
30
# File 'lib/avm/eac_webapp_base0/deploy/git_info.rb', line 24

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

#git_remote_hashs_uncachedObject



32
33
34
# File 'lib/avm/eac_webapp_base0/deploy/git_info.rb', line 32

def git_remote_hashs_uncached
  git.remote_hashs(git_remote_name)
end

#git_remote_nameObject



36
37
38
# File 'lib/avm/eac_webapp_base0/deploy/git_info.rb', line 36

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

#git_repository_pathObject



40
41
42
# File 'lib/avm/eac_webapp_base0/deploy/git_info.rb', line 40

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

#git_uncachedObject



44
45
46
# File 'lib/avm/eac_webapp_base0/deploy/git_info.rb', line 44

def git_uncached
  ::EacLauncher::Git::Base.new(git_repository_path)
end

#instance_branchObject



48
49
50
# File 'lib/avm/eac_webapp_base0/deploy/git_info.rb', line 48

def instance_branch
  remote_branch(instance.id)
end

#master_branchObject



56
57
58
# File 'lib/avm/eac_webapp_base0/deploy/git_info.rb', line 56

def master_branch
  remote_branch('master')
end

#remote_branch(name) ⇒ Object



52
53
54
# File 'lib/avm/eac_webapp_base0/deploy/git_info.rb', line 52

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