Method: Braid::Operations::Git#commit

Defined in:
lib/braid/operations.rb

#commit(message, *args) ⇒ Object



141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
# File 'lib/braid/operations.rb', line 141

def commit(message, *args)
  cmd = "git commit --no-verify"
  if message # allow nil
    message_file = Tempfile.new("braid_commit")
    message_file.print(message)
    message_file.flush
    cmd << " -F #{message_file.path}"
  end
  cmd << " #{args.join(' ')}" unless args.empty?
  status, out, err = exec(cmd)
  message_file.unlink if message_file

  if status == 0
    true
  elsif out.match(/nothing.* to commit/)
    false
  else
    raise ShellExecutionError, err
  end
end