Class: Dapp::Dimg::GitRepo::Own

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

Instance Attribute Summary

Attributes inherited from Base

#dimg, #name

Instance Method Summary collapse

Methods inherited from Base

#branch, #commit_at, #commit_exists?, #find_commit_id_by_message, #lookup_object, #patches, #walker

Constructor Details

#initialize(dimg) ⇒ Own

Returns a new instance of Own.



5
6
7
# File 'lib/dapp/dimg/git_repo/own.rb', line 5

def initialize(dimg)
  super(dimg, 'own')
end

Instance Method Details

#diff(from, to, **kwargs) ⇒ Object



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

def diff(from, to, **kwargs)
  if to.nil?
    git.lookup(from).diff_workdir
  else
    super
  end
end

#exclude_paths ⇒ Object



9
10
11
# File 'lib/dapp/dimg/git_repo/own.rb', line 9

def exclude_paths
  dimg.dapp.local_git_artifact_exclude_paths
end

#latest_commit(_branch = nil) ⇒ Object



27
28
29
# File 'lib/dapp/dimg/git_repo/own.rb', line 27

def latest_commit(_branch = nil)
  git.head.target_id
end

#lookup_commit(commit) ⇒ Object



31
32
33
34
35
# File 'lib/dapp/dimg/git_repo/own.rb', line 31

def lookup_commit(commit)
  super
rescue Rugged::OdbError => _e
  raise Error::Rugged, code: :commit_not_found_in_local_git_repository, data: { commit: commit }
end

#path ⇒ Object



13
14
15
16
17
# File 'lib/dapp/dimg/git_repo/own.rb', line 13

def path
  @path ||= Rugged::Repository.discover(dimg.home_path.to_s).path
rescue Rugged::RepositoryError => _e
  raise Error::Rugged, code: :local_git_repository_does_not_exist
end