Class: XCCache::Git

Inherits:
Object
  • Object
show all
Defined in:
lib/xccache/core/git.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(root) ⇒ Git

Returns a new instance of Git.



5
6
7
# File 'lib/xccache/core/git.rb', line 5

def initialize(root)
  @root = Pathname(root).expand_path
end

Instance Attribute Details

#rootObject (readonly)

Returns the value of attribute root.



3
4
5
# File 'lib/xccache/core/git.rb', line 3

def root
  @root
end

Instance Method Details

#clean?Boolean

Returns:

  • (Boolean)


17
18
19
# File 'lib/xccache/core/git.rb', line 17

def clean?
  status("--porcelain", capture: true, log_cmd: false)[0].empty?
end

#init?Boolean

Returns:

  • (Boolean)


21
22
23
# File 'lib/xccache/core/git.rb', line 21

def init?
  !root.glob(".git").empty?
end

#run(*args, **kwargs) ⇒ Object



9
10
11
# File 'lib/xccache/core/git.rb', line 9

def run(*args, **kwargs)
  Sh.run("git -C #{root}", *args, **kwargs)
end

#shaObject



13
14
15
# File 'lib/xccache/core/git.rb', line 13

def sha
  run("rev-parse --short HEAD", capture: true, log_cmd: false)[0].strip
end