Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2021-08-10 12:10:08 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2021-08-10 12:10:08 +0300
commit5adf6557e251c047ed68bac28cfecf9491ee6b41 (patch)
treea7ea2924ef96ccf36a915ddaf686f5f6e1e75b00 /lib/gitlab/signed_tag.rb
parent0adc81d8e0c7b291fd7fdef33a4ea9c01b4852ce (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'lib/gitlab/signed_tag.rb')
-rw-r--r--lib/gitlab/signed_tag.rb47
1 files changed, 47 insertions, 0 deletions
diff --git a/lib/gitlab/signed_tag.rb b/lib/gitlab/signed_tag.rb
new file mode 100644
index 00000000000..3b22cb7622d
--- /dev/null
+++ b/lib/gitlab/signed_tag.rb
@@ -0,0 +1,47 @@
+# frozen_string_literal: true
+
+module Gitlab
+ class SignedTag
+ include Gitlab::Utils::StrongMemoize
+
+ def initialize(repository, tag)
+ @repository = repository
+ @tag = tag
+
+ if Feature.enabled?(:get_tag_signatures)
+ @signature_data = Gitlab::Git::Tag.extract_signature_lazily(repository, tag.id) if repository
+ else
+ @signature_data = [signature_text_of_message.b, signed_text_of_message.b]
+ end
+ end
+
+ def signature
+ return unless @tag.has_signature?
+ end
+
+ def signature_text
+ @signature_data&.fetch(0)
+ end
+
+ def signed_text
+ @signature_data&.fetch(1)
+ end
+
+ private
+
+ def signature_text_of_message
+ @tag.message.slice(@tag.message.index("-----BEGIN SIGNED MESSAGE-----")..-1)
+ rescue StandardError
+ nil
+ end
+
+ def signed_text_of_message
+ %{object #{@tag.target_commit.id}
+type commit
+tag #{@tag.name}
+tagger #{@tag.tagger.name} <#{@tag.tagger.email}> #{@tag.tagger.date.seconds} #{@tag.tagger.timezone}
+
+#{@tag.message.gsub(/-----BEGIN SIGNED MESSAGE-----(.*)-----END SIGNED MESSAGE-----/m, "")}}
+ end
+ end
+end