summaryrefslogtreecommitdiff
path: root/app/models/commit.rb
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2020-02-07 00:09:12 +0000
committerGitLab Bot <gitlab-bot@gitlab.com>2020-02-07 00:09:12 +0000
commit6168721025dd8e98caeb2bf6844273e6690eaf69 (patch)
tree8c4fb20d793669e488a739bc9951dab8b363eed4 /app/models/commit.rb
parenta89cb5cbdd832d4d9e80517973aceda6bc0a3856 (diff)
downloadgitlab-ce-6168721025dd8e98caeb2bf6844273e6690eaf69.tar.gz
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'app/models/commit.rb')
-rw-r--r--app/models/commit.rb32
1 files changed, 26 insertions, 6 deletions
diff --git a/app/models/commit.rb b/app/models/commit.rb
index f2a6a8b6cbb..46222bbc4cd 100644
--- a/app/models/commit.rb
+++ b/app/models/commit.rb
@@ -25,7 +25,7 @@ class Commit
attr_accessor :redacted_description_html
attr_accessor :redacted_title_html
attr_accessor :redacted_full_title_html
- attr_reader :gpg_commit, :container
+ attr_reader :container
delegate :repository, to: :container
delegate :project, to: :repository, allow_nil: true
@@ -123,7 +123,6 @@ class Commit
@raw = raw_commit
@container = container
- @gpg_commit = Gitlab::Gpg::Commit.new(self) if container
end
delegate \
@@ -320,13 +319,34 @@ class Commit
)
end
- def signature
- return @signature if defined?(@signature)
+ def has_signature?
+ signature_type && signature_type != :NONE
+ end
+
+ def raw_signature_type
+ strong_memoize(:raw_signature_type) do
+ next unless @raw.instance_of?(Gitlab::Git::Commit)
+
+ @raw.raw_commit.signature_type if defined? @raw.raw_commit.signature_type
+ end
+ end
- @signature = gpg_commit.signature
+ def signature_type
+ @signature_type ||= raw_signature_type || :NONE
end
- delegate :has_signature?, to: :gpg_commit
+ def signature
+ strong_memoize(:signature) do
+ case signature_type
+ when :PGP
+ Gitlab::Gpg::Commit.new(self).signature
+ when :X509
+ Gitlab::X509::Commit.new(self).signature
+ else
+ nil
+ end
+ end
+ end
def revert_branch_name
"revert-#{short_id}"