static VALUE rb_git_tree_entry_name_GET(VALUE self) { rugged_tree_entry *tree_entry; Data_Get_Struct(self, rugged_tree_entry, tree_entry); return rugged_str_new2(git_tree_entry_name(tree_entry->entry), NULL); }
static VALUE rb_git_treeentry_fromC(const git_tree_entry *entry) { VALUE rb_entry; VALUE type; if (!entry) return Qnil; rb_entry = rb_hash_new(); rb_hash_aset(rb_entry, CSTR2SYM("name"), rugged_str_new2(git_tree_entry_name(entry), NULL)); rb_hash_aset(rb_entry, CSTR2SYM("oid"), rugged_create_oid(git_tree_entry_id(entry))); rb_hash_aset(rb_entry, CSTR2SYM("filemode"), INT2FIX(git_tree_entry_filemode(entry))); switch(git_tree_entry_type(entry)) { case GIT_OBJ_TREE: type = CSTR2SYM("tree"); break; case GIT_OBJ_BLOB: type = CSTR2SYM("blob"); break; default: type = Qnil; break; } rb_hash_aset(rb_entry, CSTR2SYM("type"), type); return rb_entry; }
static VALUE rb_git_commit_message_short_GET(VALUE self) { git_commit *commit; RUGGED_OBJ_UNWRAP(self, git_commit, commit); return rugged_str_new2(git_commit_message_short(commit), NULL); }
static VALUE rb_git_tag_name_GET(VALUE self) { git_tag *tag; RUGGED_OBJ_UNWRAP(self, git_tag, tag); return rugged_str_new2(git_tag_name(tag), NULL); }
static VALUE rb_git_tag_target_type_GET(VALUE self) { git_tag *tag; RUGGED_OBJ_UNWRAP(self, git_tag, tag); return rugged_str_new2(git_object_type2string(git_tag_type(tag)), NULL); }
static int rugged__treewalk_cb(const char *root, const git_tree_entry *entry, void *proc) { rb_funcall((VALUE)proc, rb_intern("call"), 2, rugged_str_new2(root, NULL), rb_git_treeentry_fromC(entry)); return GIT_OK; }
static VALUE rb_git_type_to_string(VALUE self, VALUE type) { const char *str; Check_Type(type, T_FIXNUM); git_otype t = (git_otype)FIX2INT(type); str = git_object_type2string(t); return str ? rugged_str_new2(str, NULL) : Qfalse; }
VALUE rugged_signature_new(const git_signature *sig, const char *encoding_name) { VALUE rb_sig, rb_time; #ifdef HAVE_RUBY_ENCODING_H rb_encoding *encoding = NULL; if (encoding_name != NULL) encoding = rb_enc_find(encoding_name); #endif rb_sig = rb_hash_new(); rb_time = rb_time_new(sig->when.time, 0); rb_funcall(rb_time, rb_intern("utc"), 0); rb_hash_aset(rb_sig, CSTR2SYM("name"), rugged_str_new2(sig->name, encoding)); rb_hash_aset(rb_sig, CSTR2SYM("email"), rugged_str_new2(sig->email, encoding)); rb_hash_aset(rb_sig, CSTR2SYM("time"), rb_time); return rb_sig; }