Class: EacGit::Local
- Inherits:
-
Object
show all
- Defined in:
- lib/eac_git/local.rb,
lib/eac_git/local/commit.rb,
lib/eac_git/local/subrepo.rb,
lib/eac_git/local/dirty_files.rb,
lib/eac_git/local/subrepo/config.rb,
lib/eac_git/local/commit/changed_file.rb,
lib/eac_git/local/commit/diff_tree_line.rb
Overview
A Git repository in local filesystem.
Defined Under Namespace
Modules: DirtyFiles
Classes: Commit, Subrepo
Instance Method Summary
collapse
Instance Method Details
#command(*args) ⇒ Object
38
39
40
|
# File 'lib/eac_git/local.rb', line 38
def command(*args)
::EacGit::Executables.git.command('-C', root_path.to_path, *args)
end
|
#commit(ref, required = false) ⇒ Object
15
16
17
|
# File 'lib/eac_git/local.rb', line 15
def commit(ref, required = false)
rev_parse(ref, required).if_present { |v| ::EacGit::Local::Commit.new(self, v) }
end
|
#descendant?(descendant, ancestor) ⇒ Boolean
19
20
21
22
23
24
25
|
# File 'lib/eac_git/local.rb', line 19
def descendant?(descendant, ancestor)
base = merge_base(descendant, ancestor)
return false if base.blank?
revparse = command('rev-parse', '--verify', ancestor).execute!.strip
base == revparse
end
|
#merge_base(*commits) ⇒ Object
27
28
29
30
31
32
33
34
35
36
|
# File 'lib/eac_git/local.rb', line 27
def merge_base(*commits)
refs = commits.dup
while refs.count > 1
refs[1] = merge_base_pair(refs[0], refs[1])
return nil if refs[1].blank?
refs.shift
end
refs.first
end
|
#rev_parse(ref, required = false) ⇒ Object
42
43
44
45
46
47
48
49
|
# File 'lib/eac_git/local.rb', line 42
def rev_parse(ref, required = false)
r = command('rev-parse', ref).execute!(exit_outputs: { 128 => nil, 32_768 => nil })
r.strip! if r.is_a?(String)
return r if r.present?
return nil unless required
raise "Reference \"#{ref}\" not found"
end
|
#subrepo(subpath) ⇒ Object
51
52
53
|
# File 'lib/eac_git/local.rb', line 51
def subrepo(subpath)
::EacGit::Local::Subrepo.new(self, subpath)
end
|
#to_s ⇒ Object
55
56
57
|
# File 'lib/eac_git/local.rb', line 55
def to_s
"#{self.class}[#{root_path}]"
end
|