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.
-
#get_ruby2go_state_hash ⇒ Object
-
#ignore_patch?(patch, paths: [], exclude_paths: []) ⇒ Boolean
-
#initialize(dapp, name, path) ⇒ Local
constructor
-
#lookup_commit(commit) ⇒ Object
-
#nested_git_directories_patches(paths: [], exclude_paths: [], **kwargs) ⇒ Object
-
#nested_git_repository_mode?(mode) ⇒ Boolean
-
#raise_submodule_commit_not_found!(commit) ⇒ Object
-
#submodules_git(commit) ⇒ Object
-
#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, #head_commit, #latest_branch_commit, #latest_tag_commit, #lookup_object, #patches, #remote_branches, #remote_origin_url, #remote_origin_url_protocol, #set_ruby2go_state_hash, #submodule_params, #submodule_url, #submodules, #submodules_git_path, #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.
79
80
81
82
83
84
85
86
87
88
89
90
|
# File 'lib/dapp/dimg/git_repo/local.rb', line 79
def diff(from, to, **kwargs)
if from.nil? and to.nil?
mid_commit = head_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
|
#get_ruby2go_state_hash ⇒ Object
12
13
14
15
16
17
18
19
|
# File 'lib/dapp/dimg/git_repo/local.rb', line 12
def get_ruby2go_state_hash
super.tap {|res|
p = @path.to_s
p = File.dirname(@path) if File.basename(@path) == ".git"
res["Path"] = p
res["GitDir"] = @path.to_s
}
end
|
#ignore_patch?(patch, paths: [], exclude_paths: []) ⇒ Boolean
62
63
64
65
66
67
68
69
70
|
# File 'lib/dapp/dimg/git_repo/local.rb', line 62
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
|
#lookup_commit(commit) ⇒ Object
92
93
94
95
96
|
# File 'lib/dapp/dimg/git_repo/local.rb', line 92
def lookup_commit(commit)
super
rescue Rugged::OdbError, TypeError => _e
raise Error::Rugged, code: :commit_not_found_in_local_git_repository, data: { commit: commit, path: path }
end
|
#nested_git_directories_patches(paths: [], exclude_paths: [], **kwargs) ⇒ Object
31
32
33
34
35
36
|
# File 'lib/dapp/dimg/git_repo/local.rb', line 31
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
72
73
74
|
# File 'lib/dapp/dimg/git_repo/local.rb', line 72
def nested_git_repository_mode?(mode)
mode == 0o040000
end
|
#raise_submodule_commit_not_found!(commit) ⇒ Object
58
59
60
|
# File 'lib/dapp/dimg/git_repo/local.rb', line 58
def raise_submodule_commit_not_found!(commit)
raise Error::Rugged, code: :git_local_submodule_commit_not_found, data: { commit: commit, path: path }
end
|
#submodules_git(commit) ⇒ Object
50
51
52
53
54
55
56
|
# File 'lib/dapp/dimg/git_repo/local.rb', line 50
def submodules_git(commit)
if commit.nil?
git
else
super
end
end
|
#submodules_params(commit, paths: [], exclude_paths: []) ⇒ Object
38
39
40
41
42
43
44
45
46
47
48
|
# File 'lib/dapp/dimg/git_repo/local.rb', line 38
def submodules_params(commit, paths: [], exclude_paths: [])
submodules(commit, paths: paths, exclude_paths: exclude_paths).map do |submodule|
submodule_params(submodule).tap do |params|
params[:commit] = submodule.workdir_oid || params[:commit] if commit.nil?
if submodule.in_workdir? && !submodule.uninitialized?
dapp.log_info("Using local submodule repository `#{params[:path]}`!")
params[:type] = :local
end
end
end.compact
end
|
#workdir_path ⇒ Object
27
28
29
|
# File 'lib/dapp/dimg/git_repo/local.rb', line 27
def workdir_path
Pathname(git.workdir)
end
|