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

#dimg, #name

Instance Method Summary collapse

Methods inherited from Base

#branch, #commit_at, #container_path, #git_bare, #latest_commit, #old_git_bare, #path

Constructor Details

#initialize(dimg, name, url:) ⇒ 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(dimg, name, url:)
  super(dimg, name)

  @url = url

  dimg.project.log_secondary_process(dimg.project.t(code: 'process.git_artifact_clone', data: { name: name }), short: true) do
    begin
      Rugged::Repository.clone_at(url, path, bare: true)
    rescue Rugged::NetworkError => e
      raise Error::Rugged, code: :rugged_network_error, data: { message: e.message, url: url }
    end
  end unless File.directory?(path)
end

Instance Method Details

#cleanup!Object



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

def cleanup!
  super
  FileUtils.rm_rf path
end

#fetch!(branch = nil) ⇒ Object



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

def fetch!(branch = nil)
  branch ||= self.branch
  dimg.project.log_secondary_process(dimg.project.t(code: 'process.git_artifact_fetch', data: { name: name }), short: true) do
    git_bare.fetch('origin', [branch])
  end unless dimg.ignore_git_fetch || dimg.project.dry_run?
end