Class: LetItCrash::Matchers::Git

Inherits:
Base
  • Object
show all
Defined in:
lib/letitcrash/matchers/git.rb

Constant Summary collapse

STATUS_CMD =
'git status'
BRANCH_CMD =
'git rev-parse --abbrev-ref HEAD'
SHA_CMD =
'git rev-parse HEAD'

Instance Method Summary collapse

Methods inherited from Base

#initialize

Constructor Details

This class inherits a constructor from LetItCrash::Matchers::Base

Instance Method Details

#branchObject

This method reeks of :reek:UtilityFunction.



16
17
18
19
# File 'lib/letitcrash/matchers/git.rb', line 16

def branch
  ret = IO.popen(BRANCH_CMD).read.strip
  ret == 'HEAD' ? 'master' : ret
end

#matches?Boolean

This method reeks of :reek:UtilityFunction.

Returns:

  • (Boolean)


11
12
13
# File 'lib/letitcrash/matchers/git.rb', line 11

def matches?
  IO.popen(STATUS_CMD).read.start_with?('On branch')
end

#shaObject

This method reeks of :reek:UtilityFunction.



22
23
24
# File 'lib/letitcrash/matchers/git.rb', line 22

def sha
  IO.popen(SHA_CMD).read.strip
end