Method: Git::Lib#commit

Defined in:
lib/git/lib.rb

#commit(message, opts = {})

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Takes the commit message with the options and executes the commit command

accepts options: :amend :all :allow_empty :author :date :no_verify :allow_empty_message :gpg_sign (accepts true or a gpg key ID as a String) :no_gpg_sign (conflicts with :gpg_sign)

Parameters:

  • message (String)

    the commit message to be used

  • opts (Hash) (defaults to: {})

    the commit options to be used

Raises:

  • (ArgumentError)


1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
# File 'lib/git/lib.rb', line 1193

def commit(message, opts = {})
  opts[:message] = message if message # Handle message arg for backward compatibility

  # Perform cross-option validation before building args
  raise ArgumentError, 'cannot specify :gpg_sign and :no_gpg_sign' if opts[:gpg_sign] && opts[:no_gpg_sign]

  ArgsBuilder.validate!(opts, COMMIT_OPTION_MAP)

  args = build_args(opts, COMMIT_OPTION_MAP)
  command('commit', *args)
end