lib/braid/operations.rb in evilchelu-braid-0.4.13 vs lib/braid/operations.rb in evilchelu-braid-0.5

- old
+ new

@@ -1,8 +1,9 @@ require 'singleton' require 'rubygems' require 'open4' +require 'tempfile' module Braid module Operations class ShellExecutionError < BraidError def initialize(err = nil) @@ -116,17 +117,17 @@ end def sh(cmd, message = nil) message ||= "could not fetch" if cmd =~ /fetch/ log(cmd) - system(cmd) - raise ShellExecutionError, message unless $? == 0 + `#{cmd}` + raise ShellExecutionError, message unless $?.exitstatus == 0 true end def msg(str) - puts str + puts "Braid: #{str}" end def log(cmd) msg "Executing `#{cmd}`" if verbose? end @@ -136,10 +137,15 @@ end end class Git < Proxy def commit(message, *args) - status, out, err = exec("git commit -m #{message.inspect} --no-verify #{args.join(' ')}") + + commit_message_file = Tempfile.new("braid_commit", ".") + commit_message_file.print("Braid: " + message) + commit_message_file.flush + status, out, err = exec("git commit -F #{commit_message_file.path} --no-verify #{args.join(' ')}") + commit_message_file.unlink if status == 0 true elsif out.match(/nothing.* to commit/) false