Module: Avm::EacWebappBase0::Instances::Deploy::Scm

Defined in:
lib/avm/eac_webapp_base0/instances/deploy/scm.rb

Constant Summary collapse

DEFAULT_REMOTE_NAME =
'origin'

Instance Method Summary collapse

Instance Method Details

#commit_reference_uncachedObject

Raises:

  • (::Avm::Result::Error)


10
11
12
13
14
15
16
# File 'lib/avm/eac_webapp_base0/instances/deploy/scm.rb', line 10

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

#git_fetch_uncachedObject



18
19
20
21
# File 'lib/avm/eac_webapp_base0/instances/deploy/scm.rb', line 18

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

#git_referenceObject



23
24
25
# File 'lib/avm/eac_webapp_base0/instances/deploy/scm.rb', line 23

def git_reference
  options[OPTION_REFERENCE] || DEFAULT_REFERENCE
end

#git_reference_found_uncachedObject



27
28
29
30
31
32
33
# File 'lib/avm/eac_webapp_base0/instances/deploy/scm.rb', line 27

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



35
36
37
# File 'lib/avm/eac_webapp_base0/instances/deploy/scm.rb', line 35

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

#git_remote_nameObject



39
40
41
# File 'lib/avm/eac_webapp_base0/instances/deploy/scm.rb', line 39

def git_remote_name
  DEFAULT_REMOTE_NAME
end

#git_repository_pathObject



43
44
45
# File 'lib/avm/eac_webapp_base0/instances/deploy/scm.rb', line 43

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

#git_uncachedEacGit::Local

Returns:

  • (EacGit::Local)


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

def git_uncached
  scm.git_repo
end

#instance_branchObject



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

def instance_branch
  remote_branch(instance.id)
end

#master_branchObject



60
61
62
# File 'lib/avm/eac_webapp_base0/instances/deploy/scm.rb', line 60

def master_branch
  remote_branch('master')
end

#remote_branch(name) ⇒ Object



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

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

#scmAvm::Scms::Base

Returns:

  • (Avm::Scms::Base)


65
66
67
# File 'lib/avm/eac_webapp_base0/instances/deploy/scm.rb', line 65

def scm
  instance.application.local_source.scm
end