Class: Gitlab::Git::Tag
- Inherits:
-
Ref
- Object
- Ref
- Gitlab::Git::Tag
show all
- Extended by:
- EncodingHelper
- Includes:
- Utils::StrongMemoize
- Defined in:
- lib/gitlab/git/tag.rb
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, force_encode_utf8, strip_bom, unquote_path
Methods inherited from Ref
extract_branch_name
Constructor Details
#initialize(repository, raw_tag) ⇒ Tag
Returns a new instance of Tag.
47
48
49
50
51
52
53
54
55
56
57
58
59
|
# File 'lib/gitlab/git/tag.rb', line 47
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.
11
12
13
|
# File 'lib/gitlab/git/tag.rb', line 11
def object_sha
@object_sha
end
|
#repository ⇒ Object
Returns the value of attribute repository.
11
12
13
|
# File 'lib/gitlab/git/tag.rb', line 11
def repository
@repository
end
|
Class Method Details
42
43
44
|
# File 'lib/gitlab/git/tag.rb', line 42
def (repository, tag_ids, timeout: nil)
repository.gitaly_ref_client.get_tag_signatures(tag_ids, timeout: timeout)
end
|
31
32
33
34
35
36
37
38
39
40
|
# File 'lib/gitlab/git/tag.rb', line 31
def (repository, tag_id, timeout: GitalyClient.fast_timeout)
BatchLoader.for(tag_id).batch(key: repository, default_value: [+''.b, +''.b]) do |tag_ids, loader, args|
(args[:key], tag_ids, timeout: timeout).each do |tag_id, signature_data|
loader.call(tag_id, signature_data)
end
rescue GRPC::DeadlineExceeded => e
Gitlab::ErrorTracking.log_exception(e)
end
end
|
.get_message(repository, tag_id) ⇒ Object
19
20
21
22
23
24
25
|
# File 'lib/gitlab/git/tag.rb', line 19
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
27
28
29
|
# File 'lib/gitlab/git/tag.rb', line 27
def get_messages(repository, tag_ids)
repository.gitaly_ref_client.get_tag_messages(tag_ids)
end
|
Instance Method Details
#cache_key ⇒ Object
124
125
126
|
# File 'lib/gitlab/git/tag.rb', line 124
def cache_key
"tag:" + Digest::SHA1.hexdigest([name, message, target, target_commit&.sha].join)
end
|
#can_use_lazy_cached_signature? ⇒ Boolean
119
120
121
122
|
# File 'lib/gitlab/git/tag.rb', line 119
def can_use_lazy_cached_signature?
(signature_type == :SSH && render_ssh?) ||
(signature_type == :PGP && render_gpg?)
end
|
#date ⇒ Object
91
92
93
|
# File 'lib/gitlab/git/tag.rb', line 91
def date
Time.at(tagger.date.seconds).utc if tagger&.date&.seconds
end
|
#has_signature? ⇒ Boolean
95
96
97
|
# File 'lib/gitlab/git/tag.rb', line 95
def has_signature?
signature_type != :NONE
end
|
#init_from_gitaly ⇒ Object
69
70
71
72
73
74
75
76
77
|
# File 'lib/gitlab/git/tag.rb', line 69
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
61
62
63
64
65
66
67
|
# File 'lib/gitlab/git/tag.rb', line 61
def init_from_hash
raw_tag = @raw_tag.symbolize_keys
SERIALIZE_KEYS.each do |key|
send("#{key}=", raw_tag[key]) end
end
|
#lazy_cached_signature ⇒ Object
107
108
109
|
# File 'lib/gitlab/git/tag.rb', line 107
def lazy_cached_signature
signed_tag&.lazy_cached_signature
end
|
#message ⇒ Object
79
80
81
|
# File 'lib/gitlab/git/tag.rb', line 79
def message
encode! @message
end
|
#signature ⇒ Object
103
104
105
|
# File 'lib/gitlab/git/tag.rb', line 103
def signature
signed_tag&.signature
end
|
#signature_type ⇒ Object
99
100
101
|
# File 'lib/gitlab/git/tag.rb', line 99
def signature_type
@raw_tag.signature_type || :NONE
end
|
#signed_tag ⇒ Object
111
112
113
114
115
116
|
# File 'lib/gitlab/git/tag.rb', line 111
def signed_tag
return unless has_signature?
return unless signature_type == :X509 || can_use_lazy_cached_signature?
SignedTag.from_repository_tag(repository, self)
end
|
#user_email ⇒ Object
87
88
89
|
# File 'lib/gitlab/git/tag.rb', line 87
def user_email
encode! tagger.email if tagger
end
|
#user_name ⇒ Object
83
84
85
|
# File 'lib/gitlab/git/tag.rb', line 83
def user_name
encode! tagger.name if tagger
end
|