Class: XCCache::Git
- Inherits:
-
Object
- Object
- XCCache::Git
- Defined in:
- lib/xccache/core/git.rb
Instance Attribute Summary collapse
-
#root ⇒ Object
readonly
Returns the value of attribute root.
Instance Method Summary collapse
- #clean? ⇒ Boolean
- #init? ⇒ Boolean
-
#initialize(root) ⇒ Git
constructor
A new instance of Git.
- #run(*args, **kwargs) ⇒ Object
- #sha ⇒ Object
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). end |
Instance Attribute Details
#root ⇒ Object (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
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
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 |
#sha ⇒ Object
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 |