Method: Rugged::Rebase#commit
- Defined in:
- ext/rugged/rugged_rebase.c
permalink #commit(author: nil, committer: committer, message: nil) ⇒ nil
Commit the current patch. Any conflicts must have been resolved.
If author
is nil
, the existing author for the commit will be used. If message
is nil
, the existing message will be used.
Returns a string containing the oid of the newly created commit, or nil
if there are no changes to be committed.
273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 |
# File 'ext/rugged/rugged_rebase.c', line 273
static VALUE rb_git_rebase_commit(int argc, VALUE *argv, VALUE self)
{
int error;
git_oid id;
git_rebase *rebase;
git_signature *author = NULL, *committer;
const char *message = NULL;
VALUE rb_options, rb_author, rb_committer, rb_message;
Data_Get_Struct(self, git_rebase, rebase);
rb_scan_args(argc, argv, ":", &rb_options);
Check_Type(rb_options, T_HASH);
rb_author = rb_hash_aref(rb_options, CSTR2SYM("author"));
rb_committer = rb_hash_aref(rb_options, CSTR2SYM("committer"));
rb_message = rb_hash_aref(rb_options, CSTR2SYM("message"));
if (!NIL_P(rb_message)) {
Check_Type(rb_message, T_STRING);
message = StringValueCStr(rb_message);
}
if (NIL_P(rb_committer))
rb_raise(rb_eArgError, "Expected non-nil committer");
else
committer = rugged_signature_get(rb_committer, NULL);
if (!NIL_P(rb_author))
author = rugged_signature_get(rb_author, NULL);
error = git_rebase_commit(&id, rebase, author, committer, NULL, message);
git_signature_free(author);
git_signature_free(committer);
if (error == GIT_EAPPLIED) {
giterr_clear();
return Qnil;
}
rugged_exception_check(error);
return rugged_create_oid(&id);
}
|