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?, #entries, #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

NOTICE: Параметры nil, to: nil можно указать только для Own repo. NOTICE: Для Remote repo такой вызов не имеет смысла и это ошибка пользователя класса Remote.



26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/dapp/dimg/git_repo/own.rb', line 26

def diff(from, to, **kwargs)
  if from.nil? and to.nil?
    mid_commit = latest_commit
    diff_obj = super(nil, mid_commit, **kwargs)
    diff_obj.merge! git.lookup(mid_commit).diff_workdir(**kwargs)
    diff_obj
  elsif to.nil?
    git.lookup(from).diff_workdir(**kwargs)
  else
    super
  end
end

#exclude_pathsObject



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



39
40
41
# File 'lib/dapp/dimg/git_repo/own.rb', line 39

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

#lookup_commit(commit) ⇒ Object



43
44
45
46
47
# File 'lib/dapp/dimg/git_repo/own.rb', line 43

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

#pathObject



17
18
19
20
21
# File 'lib/dapp/dimg/git_repo/own.rb', line 17

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

#workdir_pathObject



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

def workdir_path
  Pathname(git.workdir)
end