Class: Dapp::GitRepo::Remote

Inherits:
Base
  • Object
show all
Defined in:
lib/dapp/git_repo/remote.rb

Overview

Normal Git repo

Instance Attribute Summary

Attributes inherited from Base

#application, #name

Instance Method Summary collapse

Methods inherited from Base

#branch, #commit_at, #container_build_dir_path, #dir_path, #exist_in_commit?, #git_bare, #latest_commit

Constructor Details

#initialize(application, name, url:, ssh_key_path: nil) ⇒ Remote

Returns a new instance of Remote.



5
6
7
8
9
10
11
12
13
14
15
16
17
# File 'lib/dapp/git_repo/remote.rb', line 5

def initialize(application, name, url:, ssh_key_path: nil)
  super(application, name)

  @url = url
  @ssh_key_path = File.expand_path(ssh_key_path, application.home_path) if ssh_key_path

  @use_ssh_key = false
  File.chmod(0o600, @ssh_key_path) if @ssh_key_path

  with_ssh_key do
    git "clone --bare --depth 1 #{url} #{dir_path}"
  end unless File.directory? dir_path
end

Instance Method Details

#cleanup!Object



27
28
29
30
# File 'lib/dapp/git_repo/remote.rb', line 27

def cleanup!
  super
  FileUtils.rm_rf dir_path
end

#fetch!(branch = 'master') ⇒ Object



19
20
21
22
23
24
25
# File 'lib/dapp/git_repo/remote.rb', line 19

def fetch!(branch = 'master')
  with_ssh_key do
    application.log_secondary_process(application.t(code: 'process.git_artifact_fetch', data: { name: name }), short: true) do
      git_bare "fetch origin #{branch}:#{branch}"
    end
  end unless application.ignore_git_fetch || application.dry_run?
end