Class: Giblish::GitItf

Inherits:
Object
  • Object
show all
Defined in:
lib/giblish/gititf.rb

Overview

A home-grown interface class to git. Used for situations when the ‘official’ ruby git gem does not support an operation that is needed.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(path) ⇒ GitItf

Returns a new instance of GitItf.



10
11
12
13
14
15
# File 'lib/giblish/gititf.rb', line 10

def initialize(path)
  @repo_root = Giblish::PathManager.find_gitrepo_root(path)
  raise ArgumentError("The path: @{path} is not within a git repo!") if @repo_root.nil?

  @git_dir = @repo_root / ".git"
end

Instance Attribute Details

#git_dirObject (readonly)

Returns the value of attribute git_dir.



8
9
10
# File 'lib/giblish/gititf.rb', line 8

def git_dir
  @git_dir
end

#repo_rootObject (readonly)

Returns the value of attribute repo_root.



8
9
10
# File 'lib/giblish/gititf.rb', line 8

def repo_root
  @repo_root
end

Instance Method Details

#file_log(filename) ⇒ Object

Get the log history of the supplied file as an array of hashes, each entry has keys: sha date author email parent message



25
26
27
28
29
30
# File 'lib/giblish/gititf.rb', line 25

def file_log(filename)
  o, e, s = exec_cmd("log", %w[--follow --date=iso --], "'#{filename}'")
  raise "Failed to get git log for #{filename}!!\n#{e}" if s.exitstatus != 0

  process_log_output(o)
end