Class: Gitlab::Git::Tag
Constant Summary
collapse
- MAX_TAG_MESSAGE_DISPLAY_SIZE =
10.megabytes
- SERIALIZE_KEYS =
%i[name target target_commit message].freeze
EncodingHelper::BOM_UTF8, EncodingHelper::ENCODING_CONFIDENCE_THRESHOLD, EncodingHelper::ESCAPED_CHARS, EncodingHelper::UNICODE_REPLACEMENT_CHARACTER
Instance Attribute Summary collapse
Attributes inherited from Ref
#dereferenced_target, #name, #target
Class Method Summary
collapse
Instance Method Summary
collapse
binary_io, detect_binary?, detect_encoding, detect_libgit2_binary?, encode!, encode_binary, encode_utf8, encode_utf8_no_detect, encode_utf8_with_escaping!, encode_utf8_with_replacement_character, strip_bom, unquote_path
Methods inherited from Ref
extract_branch_name
dereference_object
Constructor Details
#initialize(repository, raw_tag) ⇒ Tag
Returns a new instance of Tag.
43
44
45
46
47
48
49
50
51
52
53
54
55
|
# File 'lib/gitlab/git/tag.rb', line 43
def initialize(repository, raw_tag)
@repository = repository
@raw_tag = raw_tag
case raw_tag
when Hash
init_from_hash
when Gitaly::Tag
init_from_gitaly
end
super(repository, name, target, target_commit)
end
|
Instance Attribute Details
#object_sha ⇒ Object
Returns the value of attribute object_sha.
10
11
12
|
# File 'lib/gitlab/git/tag.rb', line 10
def object_sha
@object_sha
end
|
#repository ⇒ Object
Returns the value of attribute repository.
10
11
12
|
# File 'lib/gitlab/git/tag.rb', line 10
def repository
@repository
end
|
Class Method Details
38
39
40
|
# File 'lib/gitlab/git/tag.rb', line 38
def (repository, tag_ids)
repository.gitaly_ref_client.get_tag_signatures(tag_ids)
end
|
30
31
32
33
34
35
36
|
# File 'lib/gitlab/git/tag.rb', line 30
def (repository, tag_id)
BatchLoader.for(tag_id).batch(key: repository) do |tag_ids, loader, args|
(args[:key], tag_ids).each do |tag_id, signature_data|
loader.call(tag_id, signature_data)
end
end
end
|
.get_message(repository, tag_id) ⇒ Object
18
19
20
21
22
23
24
|
# File 'lib/gitlab/git/tag.rb', line 18
def get_message(repository, tag_id)
BatchLoader.for(tag_id).batch(key: repository) do |tag_ids, loader, args|
get_messages(args[:key], tag_ids).each do |tag_id, message|
loader.call(tag_id, message)
end
end
end
|
.get_messages(repository, tag_ids) ⇒ Object
26
27
28
|
# File 'lib/gitlab/git/tag.rb', line 26
def get_messages(repository, tag_ids)
repository.gitaly_ref_client.get_tag_messages(tag_ids)
end
|
Instance Method Details
#cache_key ⇒ Object
110
111
112
|
# File 'lib/gitlab/git/tag.rb', line 110
def cache_key
"tag:" + Digest::SHA1.hexdigest([name, message, target, target_commit&.sha].join)
end
|
#date ⇒ Object
87
88
89
|
# File 'lib/gitlab/git/tag.rb', line 87
def date
Time.at(tagger.date.seconds).utc if tagger
end
|
#has_signature? ⇒ Boolean
91
92
93
|
# File 'lib/gitlab/git/tag.rb', line 91
def has_signature?
signature_type != :NONE
end
|
#init_from_gitaly ⇒ Object
65
66
67
68
69
70
71
72
73
|
# File 'lib/gitlab/git/tag.rb', line 65
def init_from_gitaly
@name = encode_utf8_with_escaping!(@raw_tag.name.dup)
@target = @raw_tag.id
@message = message_from_gitaly_tag
if @raw_tag.target_commit.present?
@target_commit = Gitlab::Git::Commit.decorate(repository, @raw_tag.target_commit)
end
end
|
#init_from_hash ⇒ Object
57
58
59
60
61
62
63
|
# File 'lib/gitlab/git/tag.rb', line 57
def init_from_hash
raw_tag = @raw_tag.symbolize_keys
SERIALIZE_KEYS.each do |key|
send("#{key}=", raw_tag[key]) end
end
|
#message ⇒ Object
75
76
77
|
# File 'lib/gitlab/git/tag.rb', line 75
def message
encode! @message
end
|
#signature ⇒ Object
99
100
101
102
103
104
105
106
107
108
|
# File 'lib/gitlab/git/tag.rb', line 99
def signature
return unless has_signature?
case signature_type
when :PGP
nil when :X509
X509::Tag.new(@repository, self).signature
end
end
|
#signature_type ⇒ Object
95
96
97
|
# File 'lib/gitlab/git/tag.rb', line 95
def signature_type
@raw_tag.signature_type || :NONE
end
|
#user_email ⇒ Object
83
84
85
|
# File 'lib/gitlab/git/tag.rb', line 83
def user_email
encode! tagger.email if tagger
end
|
#user_name ⇒ Object
79
80
81
|
# File 'lib/gitlab/git/tag.rb', line 79
def user_name
encode! tagger.name if tagger
end
|