Class: Rugged::Tag

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

Defined Under Namespace

Classes: Annotation

Constant Summary collapse

GPG_SIGNATURE_PREFIX =
"-----BEGIN PGP SIGNATURE-----".freeze

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Reference

#branch?, #canonical_name, #inspect, #log, #log?, #peel, #remote?, #resolve, #tag?, #target_id, #type, valid_name?

Class Method Details

.extract_signature(repo, oid, prefix = GPG_SIGNATURE_PREFIX) ⇒ Object



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/rugged/tag.rb', line 10

def self.extract_signature(repo, oid, prefix=GPG_SIGNATURE_PREFIX)
  object = repo.read(oid)

  unless object.type == :tag
    raise GitRPC::InvalidObject, "Invalid object type #{object.type}, expected tag"
  end

  if index = object.data.index(prefix)
    [
      object.data.byteslice(index..-1),
      object.data.byteslice(0...index)
    ]
  else
    nil
  end
end

Instance Method Details

#annotated?Boolean

Returns:

  • (Boolean)


214
215
216
217
# File 'ext/rugged/rugged_tag.c', line 214

static VALUE rb_git_tag_annotated_p(VALUE self)
{
	return RTEST(rb_git_tag_annotation(self)) ? Qtrue : Qfalse;
}

#annotationnil

Returns:

  • (nil)


154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
# File 'ext/rugged/rugged_tag.c', line 154

static VALUE rb_git_tag_annotation(VALUE self)
{
	git_reference *ref, *resolved_ref;
	git_repository *repo;
	git_object *target;
	int error;
	VALUE rb_repo = rugged_owner(self);

	rugged_check_repo(rb_repo);
	Data_Get_Struct(self, git_reference, ref);
	Data_Get_Struct(rb_repo, git_repository, repo);

	error = git_reference_resolve(&resolved_ref, ref);
	rugged_exception_check(error);

	error = git_object_lookup(&target, repo, git_reference_target(resolved_ref), GIT_OBJ_TAG);
	git_reference_free(resolved_ref);

	if (error == GIT_ENOTFOUND)
		return Qnil;

	return rugged_object_new(rb_repo, target);
}

#nameObject



27
28
29
# File 'lib/rugged/tag.rb', line 27

def name
  canonical_name.sub(%r{^refs/tags/}, "")
end

#targetObject



182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
# File 'ext/rugged/rugged_tag.c', line 182

static VALUE rb_git_tag_target(VALUE self)
{
	git_reference *ref, *resolved_ref;
	git_repository *repo;
	git_object *target;
	int error;
	VALUE rb_repo = rugged_owner(self);

	rugged_check_repo(rb_repo);
	Data_Get_Struct(self, git_reference, ref);
	Data_Get_Struct(rb_repo, git_repository, repo);

	error = git_reference_resolve(&resolved_ref, ref);
	rugged_exception_check(error);

	error = git_object_lookup(&target, repo, git_reference_target(resolved_ref), GIT_OBJ_ANY);
	git_reference_free(resolved_ref);
	rugged_exception_check(error);

	if (git_object_type(target) == GIT_OBJ_TAG) {
		git_object *annotation_target;

		error = git_tag_target(&annotation_target, (git_tag *)target);
		git_object_free(target);
		rugged_exception_check(error);

		return rugged_object_new(rb_repo, annotation_target);
	} else {
		return rugged_object_new(rb_repo, target);
	}
}