Class: Dapp::Dimg::GitRepo::Local
- Inherits:
-
Base
- Object
- Base
- Dapp::Dimg::GitRepo::Local
show all
- Defined in:
- lib/dapp/dimg/git_repo/local.rb
Direct Known Subclasses
Own
Instance Attribute Summary collapse
Attributes inherited from Base
#dapp, #name
Instance Method Summary
collapse
-
#diff(from, to, **kwargs) ⇒ Object
NOTICE: Параметры nil, to: nil можно указать только для Own repo.
-
#ignore_patch?(patch, paths: [], exclude_paths: []) ⇒ Boolean
-
#initialize(dapp, name, path) ⇒ Local
constructor
-
#latest_commit(_branch = nil) ⇒ Object
-
#lookup_commit(commit) ⇒ Object
-
#nested_git_directories_patches(paths: [], exclude_paths: [], **kwargs) ⇒ Object
-
#nested_git_repository_mode?(mode) ⇒ Boolean
-
#submodules_params(commit, paths: [], exclude_paths: []) ⇒ Object
-
#workdir_path ⇒ Object
Methods inherited from Base
#blobs_entries, #branch, #commit_exists?, #empty?, #exclude_paths, #find_commit_id_by_message, #lookup_object, #patches, #remote_branches, #remote_origin_url, #remote_origin_url_protocol, #submodule_params, #submodule_url, #submodules, #submodules_git, #tags, #tracked_remote_repository?, #walker
#check_path?, #check_subpath?, #class_to_lowercase, class_to_lowercase, #delete_file, #ignore_path?, #ignore_path_base, #kwargs, #make_path, #path_checker, #search_file_upward
Constructor Details
#initialize(dapp, name, path) ⇒ Local
Returns a new instance of Local.
7
8
9
10
|
# File 'lib/dapp/dimg/git_repo/local.rb', line 7
def initialize(dapp, name, path)
super(dapp, name)
self.path = path
end
|
Instance Attribute Details
#path ⇒ Object
Returns the value of attribute path.
5
6
7
|
# File 'lib/dapp/dimg/git_repo/local.rb', line 5
def path
@path
end
|
Instance Method Details
#diff(from, to, **kwargs) ⇒ Object
NOTICE: Параметры nil, to: nil можно указать только для Own repo. NOTICE: Для Remote repo такой вызов не имеет смысла и это ошибка пользователя класса Remote.
62
63
64
65
66
67
68
69
70
71
72
73
|
# File 'lib/dapp/dimg/git_repo/local.rb', line 62
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
|
#ignore_patch?(patch, paths: [], exclude_paths: []) ⇒ Boolean
45
46
47
48
49
50
51
52
53
|
# File 'lib/dapp/dimg/git_repo/local.rb', line 45
def ignore_patch?(patch, paths: [], exclude_paths: [])
delta_new_file = patch.delta.new_file
args = [delta_new_file[:path], paths: paths, exclude_paths: exclude_paths]
if nested_git_repository_mode?(delta_new_file[:mode])
ignore_directory?(*args)
else
ignore_path?(*args)
end
end
|
#latest_commit(_branch = nil) ⇒ Object
75
76
77
|
# File 'lib/dapp/dimg/git_repo/local.rb', line 75
def latest_commit(_branch = nil)
git.head.target_id
end
|
#lookup_commit(commit) ⇒ Object
79
80
81
82
83
|
# File 'lib/dapp/dimg/git_repo/local.rb', line 79
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
|
#nested_git_directories_patches(paths: [], exclude_paths: [], **kwargs) ⇒ Object
22
23
24
25
26
27
|
# File 'lib/dapp/dimg/git_repo/local.rb', line 22
def nested_git_directories_patches(paths: [], exclude_paths: [], **kwargs)
patches(nil, nil, paths: paths, exclude_paths: exclude_paths, **kwargs).select do |patch|
delta_new_file = patch.delta.new_file
nested_git_repository_mode?(delta_new_file[:mode])
end
end
|
#nested_git_repository_mode?(mode) ⇒ Boolean
55
56
57
|
# File 'lib/dapp/dimg/git_repo/local.rb', line 55
def nested_git_repository_mode?(mode)
mode == 0o040000
end
|
#submodules_params(commit, paths: [], exclude_paths: []) ⇒ Object
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
|
# File 'lib/dapp/dimg/git_repo/local.rb', line 29
def submodules_params(commit, paths: [], exclude_paths: [])
submodules(commit, paths: paths, exclude_paths: exclude_paths).map do |submodule|
next if commit.nil? && !submodule.in_config?
submodule_params(submodule).tap do |params|
if commit.nil?
submodule_path = File.join(workdir_path, params[:path])
params[:commit] = submodule.workdir_oid || submodule.head_oid
if git_repo_exist?(submodule_path)
dapp.log_info("Using local submodule `#{params[:path]}`!")
params[:type] = :local
end
end
end
end.compact
end
|
#workdir_path ⇒ Object
18
19
20
|
# File 'lib/dapp/dimg/git_repo/local.rb', line 18
def workdir_path
Pathname(git.workdir)
end
|