Class: Stove::Plugin::Git

Inherits:
Base
  • Object
show all
Defined in:
lib/stove/plugins/git.rb

Instance Attribute Summary

Attributes inherited from Base

#cookbook, #options

Instance Method Summary collapse

Methods inherited from Base

#initialize, onload

Methods included from Mixin::Filterable

#after, #before

Methods included from Mixin::Optionable

extended, included

Methods included from Mixin::Validatable

#validate

Constructor Details

This class inherits a constructor from Stove::Plugin::Base

Instance Method Details

#git(command, errors = true) ⇒ Object



49
50
51
52
53
54
55
56
57
58
# File 'lib/stove/plugins/git.rb', line 49

def git(command, errors = true)
  log.debug("Running `git #{command}', errors: #{errors}")
  response = %x|cd "#{cookbook.path}" && git #{command}|

  if errors && !$?.success?
    raise Error::GitFailed.new(command: command)
  end

  response
end

#git_null(command) ⇒ Object



60
61
62
63
64
65
66
67
68
69
# File 'lib/stove/plugins/git.rb', line 60

def git_null(command)
  null = case RbConfig::CONFIG['host_os']
         when /mswin|mingw|cygwin/
           'NUL'
         else
           '/dev/null'
         end

  git("#{command} 2>#{null}", false)
end