Module: Teapot::Git::Commands

Defined in:
lib/teapot/repository.rb

Overview

This module needs to be refactored. Perhaps use Process::Group.

Defined Under Namespace

Classes: CommandError

Class Method Summary collapse

Class Method Details

.run(*args, &block) ⇒ Object



28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# File 'lib/teapot/repository.rb', line 28

def self.run(*args, &block)
  options = Hash === args.last ? args.pop : {}
  
  args = args.flatten.collect &:to_s
  
  puts args.join(' ').color(:blue) + " in #{options[:chdir] || Dir.getwd}"
  
  pid = Process.spawn(*args, options, &block)
  _, result = Process.wait2(pid)
  
  if result.exitstatus == 0
    true
  else
    raise CommandError.new("Non-zero exit status: #{result} while running #{args.join(' ')}!")
  end
end

.run!(*args, &block) ⇒ Object



45
46
47
48
49
# File 'lib/teapot/repository.rb', line 45

def self.run!(*args, &block)
  run(*args, &block)
rescue CommandError
  false
end