Class: EacGit::Local

Inherits:
Object
  • Object
show all
Defined in:
lib/eac_git/local.rb,
lib/eac_git/local/subrepo.rb,
lib/eac_git/local/dirty_files.rb,
lib/eac_git/local/subrepo/config.rb

Overview

A Git repository in local filesystem.

Defined Under Namespace

Modules: DirtyFiles Classes: Subrepo

Instance Method Summary collapse

Instance Method Details

#command(*args) ⇒ Object



34
35
36
# File 'lib/eac_git/local.rb', line 34

def command(*args)
  ::EacGit::Executables.git.command('-C', root_path.to_path, *args)
end

#descendant?(descendant, ancestor) ⇒ Boolean

Returns:

  • (Boolean)


15
16
17
18
19
20
21
# File 'lib/eac_git/local.rb', line 15

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



23
24
25
26
27
28
29
30
31
32
# File 'lib/eac_git/local.rb', line 23

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



38
39
40
41
42
43
44
45
# File 'lib/eac_git/local.rb', line 38

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



47
48
49
# File 'lib/eac_git/local.rb', line 47

def subrepo(subpath)
  ::EacGit::Local::Subrepo.new(self, subpath)
end

#to_sObject



51
52
53
# File 'lib/eac_git/local.rb', line 51

def to_s
  "#{self.class}[#{root_path}]"
end