Class: Rubbr::Scm::Git
Instance Attribute Summary
Attributes inherited from Base
#date, #executable, #name, #revision
Instance Method Summary collapse
-
#initialize {|_self| ... } ⇒ Git
constructor
A new instance of Git.
- #parse_scm_stats ⇒ Object
Methods inherited from Base
Methods included from Cli
#color?, #disable_stderr, #disable_stdinn, #disable_stdout, #error, #executable?, #notice, #valid_executable, #warning
Constructor Details
#initialize {|_self| ... } ⇒ Git
Returns a new instance of Git.
9 10 11 12 13 14 15 16 17 18 |
# File 'lib/rubbr/scm/git.rb', line 9 def initialize super @name = 'Git' @executable = valid_executable :git @revision, @date = parse_scm_stats yield self if block_given? end |
Instance Method Details
#parse_scm_stats ⇒ Object
20 21 22 23 24 25 26 27 28 |
# File 'lib/rubbr/scm/git.rb', line 20 def parse_scm_stats return [nil, nil] unless @executable raw_stats = `#@executable show --abbrev-commit --pretty=medium HEAD` revision = raw_stats.scan(/^commit ([0-9a-f]+)/).first.first date = raw_stats.scan(/^Date: +(.+)/).first.first [revision, date] end |