Class: Rugged::Tag
- Inherits:
-
RuggedObject
- Object
- RuggedObject
- Rugged::Tag
- Defined in:
- lib/rugged/objects.rb,
ext/rugged/rugged_tag.c
Class Method Summary collapse
Instance Method Summary collapse
- #message ⇒ Object
- #modify(new_args, force = True) ⇒ Object
- #name ⇒ Object
- #tagger ⇒ Object
- #target ⇒ Object
- #target_type ⇒ Object
- #to_hash ⇒ Object
Class Method Details
.create(rb_repo, rb_data) ⇒ Object
80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 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 |
# File 'ext/rugged/rugged_tag.c', line 80
static VALUE rb_git_tag_create(VALUE self, VALUE rb_repo, VALUE rb_data)
{
git_oid tag_oid;
git_repository *repo = NULL;
int error, force = 0;
VALUE rb_name, rb_target, rb_tagger, rb_message, rb_force;
if (!rb_obj_is_kind_of(rb_repo, rb_cRuggedRepo))
rb_raise(rb_eTypeError, "Expeting a Rugged::Repository instance");
Data_Get_Struct(rb_repo, git_repository, repo);
if (TYPE(rb_data) == T_STRING) {
error = git_tag_create_frombuffer(
&tag_oid,
repo,
StringValueCStr(rb_data),
force
);
} else if (TYPE(rb_data) == T_HASH) {
git_object *target = NULL;
rb_name = rb_hash_aref(rb_data, CSTR2SYM("name"));
Check_Type(rb_name, T_STRING);
rb_target = rb_hash_aref(rb_data, CSTR2SYM("target"));
target = rugged_object_load(repo, rb_target, GIT_OBJ_ANY);
rb_force = rb_hash_aref(rb_data, CSTR2SYM("force"));
if (!NIL_P(rb_force))
force = rugged_parse_bool(rb_force);
/* only for heavy tags */
rb_message = rb_hash_aref(rb_data, CSTR2SYM("message"));
rb_tagger = rb_hash_aref(rb_data, CSTR2SYM("tagger"));
if (!NIL_P(rb_tagger) && !NIL_P(rb_message)) {
git_signature *tagger = NULL;
tagger = rugged_signature_get(rb_tagger);
Check_Type(rb_message, T_STRING);
error = git_tag_create(
&tag_oid,
repo,
StringValueCStr(rb_name),
target,
tagger,
StringValueCStr(rb_message),
force
);
git_signature_free(tagger);
} else {
error = git_tag_create_lightweight(
&tag_oid,
repo,
StringValueCStr(rb_name),
target,
force
);
}
git_object_free(target);
} else {
rb_raise(rb_eTypeError, "Invalid tag data: expected a String or a Hash");
}
rugged_exception_check(error);
return rugged_create_oid(&tag_oid);
}
|
.delete(rb_repo, rb_name) ⇒ Object
187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 |
# File 'ext/rugged/rugged_tag.c', line 187
static VALUE rb_git_tag_delete(VALUE self, VALUE rb_repo, VALUE rb_name)
{
git_repository *repo;
int error;
if (!rb_obj_is_kind_of(rb_repo, rb_cRuggedRepo))
rb_raise(rb_eTypeError, "Expeting a Rugged::Repository instance");
Data_Get_Struct(rb_repo, git_repository, repo);
Check_Type(rb_name, T_STRING);
error = git_tag_delete(repo, StringValueCStr(rb_name));
rugged_exception_check(error);
return Qnil;
}
|
.each(*args) ⇒ Object
153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 |
# File 'ext/rugged/rugged_tag.c', line 153
static VALUE rb_git_tag_each(int argc, VALUE *argv, VALUE self)
{
git_repository *repo;
git_strarray tags;
size_t i;
int error;
VALUE rb_repo, rb_pattern;
const char *pattern = NULL;
rb_scan_args(argc, argv, "11", &rb_repo, &rb_pattern);
if (!rb_block_given_p())
return rb_funcall(self, rb_intern("to_enum"), 3, CSTR2SYM("each"), rb_repo, rb_pattern);
if (!NIL_P(rb_pattern)) {
Check_Type(rb_pattern, T_STRING);
pattern = StringValueCStr(rb_pattern);
}
if (!rb_obj_is_kind_of(rb_repo, rb_cRuggedRepo))
rb_raise(rb_eTypeError, "Expeting a Rugged::Repository instance");
Data_Get_Struct(rb_repo, git_repository, repo);
error = git_tag_list_match(&tags, pattern ? pattern : "", repo);
rugged_exception_check(error);
for (i = 0; i < tags.count; ++i)
rb_yield(rugged_str_new2(tags.strings[i], NULL));
git_strarray_free(&tags);
return Qnil;
}
|
Instance Method Details
#message ⇒ Object
72 73 74 75 76 77 78 |
# File 'ext/rugged/rugged_tag.c', line 72
static VALUE rb_git_tag_message_GET(VALUE self)
{
git_tag *tag;
Data_Get_Struct(self, git_tag, tag);
return rugged_str_new2(git_tag_message(tag), NULL);
}
|
#modify(new_args, force = True) ⇒ Object
40 41 42 43 |
# File 'lib/rugged/objects.rb', line 40 def modify(new_args, force=True) args = self.to_hash.merge(new_args) Tag.create(args, force) end |
#name ⇒ Object
56 57 58 59 60 61 62 |
# File 'ext/rugged/rugged_tag.c', line 56
static VALUE rb_git_tag_name_GET(VALUE self)
{
git_tag *tag;
Data_Get_Struct(self, git_tag, tag);
return rugged_str_new2(git_tag_name(tag), NULL);
}
|
#tagger ⇒ Object
64 65 66 67 68 69 70 |
# File 'ext/rugged/rugged_tag.c', line 64
static VALUE rb_git_tag_tagger_GET(VALUE self)
{
git_tag *tag;
Data_Get_Struct(self, git_tag, tag);
return rugged_signature_new(git_tag_tagger(tag), NULL);
}
|
#target ⇒ Object
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'ext/rugged/rugged_tag.c', line 32
static VALUE rb_git_tag_target_GET(VALUE self)
{
git_tag *tag;
git_object *target;
int error;
VALUE owner;
Data_Get_Struct(self, git_tag, tag);
owner = rugged_owner(self);
error = git_tag_target(&target, tag);
rugged_exception_check(error);
return rugged_object_new(owner, target);
}
|
#target_type ⇒ Object
48 49 50 51 52 53 54 |
# File 'ext/rugged/rugged_tag.c', line 48
static VALUE rb_git_tag_target_type_GET(VALUE self)
{
git_tag *tag;
Data_Get_Struct(self, git_tag, tag);
return rugged_str_new2(git_object_type2string(git_tag_type(tag)), NULL);
}
|
#to_hash ⇒ Object
31 32 33 34 35 36 37 38 |
# File 'lib/rugged/objects.rb', line 31 def to_hash { :message => , :name => name, :target => target, :tagger => tagger, } end |