Module: Avm::EacWebappBase0::Instances::Deploy::Scm
- Defined in:
- lib/avm/eac_webapp_base0/instances/deploy/scm.rb
Constant Summary collapse
- DEFAULT_REMOTE_NAME =
'origin'
- DEFAULT_REMOTE_READ =
true
- DEFAULT_REMOTE_WRITE =
true
Instance Method Summary collapse
- #commit_reference_uncached ⇒ Object
- #git_fetch_uncached ⇒ Object
- #git_reference ⇒ Object
- #git_reference_found_uncached ⇒ Object
- #git_remote_hashs_uncached ⇒ Object
- #git_remote_name ⇒ Object
- #git_repository_path ⇒ Object
- #git_uncached ⇒ EacGit::Local
- #instance_branch ⇒ Object
- #master_branch ⇒ Object
- #remote_branch(name) ⇒ Object
- #remote_read? ⇒ Boolean
- #remote_write? ⇒ Boolean
- #scm ⇒ Avm::Scms::Base
Instance Method Details
#commit_reference_uncached ⇒ Object
12 13 14 15 16 17 18 |
# File 'lib/avm/eac_webapp_base0/instances/deploy/scm.rb', line 12 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_uncached ⇒ Object
20 21 22 23 24 25 |
# File 'lib/avm/eac_webapp_base0/instances/deploy/scm.rb', line 20 def git_fetch_uncached return unless remote_read? infom "Fetching remote \"#{git_remote_name}\" from \"#{git_repository_path}\"..." git.remote(git_remote_name).fetch end |
#git_reference ⇒ Object
27 28 29 |
# File 'lib/avm/eac_webapp_base0/instances/deploy/scm.rb', line 27 def git_reference [OPTION_REFERENCE] || DEFAULT_REFERENCE end |
#git_reference_found_uncached ⇒ Object
31 32 33 34 35 36 37 |
# File 'lib/avm/eac_webapp_base0/instances/deploy/scm.rb', line 31 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_uncached ⇒ Object
39 40 41 42 43 |
# File 'lib/avm/eac_webapp_base0/instances/deploy/scm.rb', line 39 def git_remote_hashs_uncached return {} unless remote_read? git.remote(git_remote_name).ls.hashes end |
#git_remote_name ⇒ Object
45 46 47 |
# File 'lib/avm/eac_webapp_base0/instances/deploy/scm.rb', line 45 def git_remote_name DEFAULT_REMOTE_NAME end |
#git_repository_path ⇒ Object
49 50 51 |
# File 'lib/avm/eac_webapp_base0/instances/deploy/scm.rb', line 49 def git_repository_path instance.source_instance.read_entry(::Avm::Instances::EntryKeys::INSTALL_PATH) end |
#git_uncached ⇒ EacGit::Local
54 55 56 |
# File 'lib/avm/eac_webapp_base0/instances/deploy/scm.rb', line 54 def git_uncached scm.git_repo end |
#instance_branch ⇒ Object
58 59 60 |
# File 'lib/avm/eac_webapp_base0/instances/deploy/scm.rb', line 58 def instance_branch remote_branch(instance.id) end |
#master_branch ⇒ Object
66 67 68 |
# File 'lib/avm/eac_webapp_base0/instances/deploy/scm.rb', line 66 def master_branch remote_branch('master') end |
#remote_branch(name) ⇒ Object
62 63 64 |
# File 'lib/avm/eac_webapp_base0/instances/deploy/scm.rb', line 62 def remote_branch(name) git_remote_hashs.key?("refs/heads/#{name}") ? "#{git_remote_name}/#{name}" : nil end |
#remote_read? ⇒ Boolean
71 72 73 |
# File 'lib/avm/eac_webapp_base0/instances/deploy/scm.rb', line 71 def remote_read? .if_key(OPTION_REMOTE_READ, DEFAULT_REMOTE_READ).to_bool end |
#remote_write? ⇒ Boolean
76 77 78 |
# File 'lib/avm/eac_webapp_base0/instances/deploy/scm.rb', line 76 def remote_write? .if_key(OPTION_REMOTE_WRITE, DEFAULT_REMOTE_WRITE).to_bool end |
#scm ⇒ Avm::Scms::Base
81 82 83 |
# File 'lib/avm/eac_webapp_base0/instances/deploy/scm.rb', line 81 def scm instance.application.local_source.scm end |