Method: Rugged::Object#create_note
- Defined in:
- ext/rugged/rugged_note.c
permalink #create_note(data = {}) ⇒ Object
Write a new note
to object
, with the given data
arguments, passed as a Hash
:
-
:message
: the content of the note to add to the object -
:committer
: (optional) a hash with the signature for the committer defaults to the signature from the configuration -
:author
: (optional) a hash with the signature for the author defaults to the signature from the configuration -
:ref
: (optional): canonical name of the reference to use, defaults to “refs/notes/commits” -
:force
: (optional): overwrite existing note (disabled by default)
When the note is successfully written to disk, its oid
will be returned as a hex String
.
= {:email=>"tanoku@gmail.com", :time=>Time.now, :name=>"Vicent Mart\303\255"}
obj.create_note(
:author => ,
:committer => ,
:message => "Hello world\n\n",
:ref => 'refs/notes/builds'
)
112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 |
# File 'ext/rugged/rugged_note.c', line 112
static VALUE rb_git_note_create(VALUE self, VALUE rb_data)
{
VALUE rb_ref, rb_message, rb_force;
git_repository *repo = NULL;
const char *notes_ref = NULL;
VALUE owner;
git_signature *author, *committer;
git_oid note_oid;
git_object *target = NULL;
int error = 0;
int force = 0;
Check_Type(rb_data, T_HASH);
TypedData_Get_Struct(self, git_object, &rugged_object_type, target);
owner = rugged_owner(self);
Data_Get_Struct(owner, git_repository, repo);
rb_ref = rb_hash_aref(rb_data, CSTR2SYM("ref"));
rb_force = rb_hash_aref(rb_data, CSTR2SYM("force"));
if (!NIL_P(rb_force))
force = rugged_parse_bool(rb_force);
if (!NIL_P(rb_ref)) {
Check_Type(rb_ref, T_STRING);
notes_ref = StringValueCStr(rb_ref);
}
rb_message = rb_hash_aref(rb_data, CSTR2SYM("message"));
Check_Type(rb_message, T_STRING);
committer = rugged_signature_get(
rb_hash_aref(rb_data, CSTR2SYM("committer")), repo
);
author = rugged_signature_get(
rb_hash_aref(rb_data, CSTR2SYM("author")), repo
);
error = git_note_create(
¬e_oid,
repo,
notes_ref,
author,
committer,
git_object_id(target),
StringValueCStr(rb_message),
force);
git_signature_free(author);
git_signature_free(committer);
rugged_exception_check(error);
return rugged_create_oid(¬e_oid);
}
|