Class: Rugged::Tag::Annotation

Inherits:
Object
  • Object
show all
Defined in:
lib/rugged/tag.rb,
ext/rugged/rugged_tag.c

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Object

#<=>, #==, #create_note, lookup, new, #notes, #oid, #read_raw, #remove_note, rev_parse, rev_parse_oid, #type

Class Method Details

.prettify_message(msg, strip_comments = true) ⇒ Object



32
33
34
# File 'lib/rugged/tag.rb', line 32

def self.prettify_message(msg, strip_comments = true)
  Rugged::prettify_message(msg, strip_comments)
end

Instance Method Details

#inspectObject



36
37
38
# File 'lib/rugged/tag.rb', line 36

def inspect
  "#<Rugged::Tag::Annotation:#{object_id} {name: #{name.inspect}, message: #{message.inspect}, target: #{target.inspect}>"
end

#messageObject

Return the message of this tag annotation. This includes the full body of the message and any optional footers or signatures after it.

annotation.message #=> "Release v0.16.0, codename 'broken stuff'"


136
137
138
139
140
141
142
143
144
145
146
147
148
# File 'ext/rugged/rugged_tag.c', line 136

static VALUE rb_git_tag_annotation_message(VALUE self)
{
	git_tag *tag;
	const char *message;

	TypedData_Get_Struct(self, git_tag, &rugged_object_type, tag);
	message = git_tag_message(tag);

	if (!message)
		return Qnil;

	return rb_str_new_utf8(message);
}

#modify(new_args, force = True) ⇒ Object



49
50
51
52
# File 'lib/rugged/tag.rb', line 49

def modify(new_args, force=True)
  args = self.to_hash.merge(new_args)
  Tag.create(args, force)
end

#nameObject

Return a string with the name of this tag annotation.

annotation.name #=> "v0.16.0"


95
96
97
98
99
100
101
# File 'ext/rugged/rugged_tag.c', line 95

static VALUE rb_git_tag_annotation_name(VALUE self)
{
	git_tag *tag;
	TypedData_Get_Struct(self, git_tag, &rugged_object_type, tag);

	return rb_str_new_utf8(git_tag_name(tag));
}

#taggerObject

Return the signature for the author of this tag annotation. The signature is returned as a Hash containing :name, :email of the author and :time of the tagging.

annotation.tagger #=> {:email=>"[email protected]", :time=>Tue Jan 24 05:42:45 UTC 2012, :name=>"Vicent Mart\303\255"}


113
114
115
116
117
118
119
120
121
122
123
124
125
# File 'ext/rugged/rugged_tag.c', line 113

static VALUE rb_git_tag_annotation_tagger(VALUE self)
{
	git_tag *tag;
	const git_signature *tagger;

	TypedData_Get_Struct(self, git_tag, &rugged_object_type, tag);
	tagger = git_tag_tagger(tag);

	if (!tagger)
		return Qnil;

	return rugged_signature_new(tagger, NULL);
}

#targetObject

Return the object pointed at by this tag annotation, as a Rugged::Object instance.

annotation.target #=> #<Rugged::Commit:0x108828918>

Returns:



29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# File 'ext/rugged/rugged_tag.c', line 29

static VALUE rb_git_tag_annotation_target(VALUE self)
{
	git_tag *tag;
	git_object *target;
	int error;
	VALUE owner;

	TypedData_Get_Struct(self, git_tag, &rugged_object_type, tag);
	owner = rugged_owner(self);

	error = git_tag_target(&target, tag);
	rugged_exception_check(error);

	return rugged_object_new(owner, target);
}

#target_oidObject #target_idObject

Return the oid pointed at by this tag annotation, as a String instance.

annotation.target_id #=> "2cb831a8aea28b2c1b9c63385585b864e4d3bad1"


55
56
57
58
59
60
61
62
63
64
65
# File 'ext/rugged/rugged_tag.c', line 55

static VALUE rb_git_tag_annotation_target_id(VALUE self)
{
	git_tag *tag;
	const git_oid *target_oid;

	TypedData_Get_Struct(self, git_tag, &rugged_object_type, tag);

	target_oid = git_tag_target_id(tag);

	return rugged_create_oid(target_oid);
}

#target_oidObject #target_idObject

Return the oid pointed at by this tag annotation, as a String instance.

annotation.target_id #=> "2cb831a8aea28b2c1b9c63385585b864e4d3bad1"


55
56
57
58
59
60
61
62
63
64
65
# File 'ext/rugged/rugged_tag.c', line 55

static VALUE rb_git_tag_annotation_target_id(VALUE self)
{
	git_tag *tag;
	const git_oid *target_oid;

	TypedData_Get_Struct(self, git_tag, &rugged_object_type, tag);

	target_oid = git_tag_target_id(tag);

	return rugged_create_oid(target_oid);
}

#typeObject

Return a symbol representing the type of the objeced pointed at by this annotation. Possible values are :blob, :commit, :tree and :tag.

This is always the same as the type of the returned annotation.target

annotation.type #=> :commit
annotation.target.type == annotation.type #=> true


79
80
81
82
83
84
85
# File 'ext/rugged/rugged_tag.c', line 79

static VALUE rb_git_tag_annotation_target_type(VALUE self)
{
	git_tag *tag;
	TypedData_Get_Struct(self, git_tag, &rugged_object_type, tag);

	return rugged_otype_new(git_tag_target_type(tag));
}

#to_hashObject



40
41
42
43
44
45
46
47
# File 'lib/rugged/tag.rb', line 40

def to_hash
  {
    :message => message,
    :name => name,
    :target => target,
    :tagger => tagger,
  }
end