2017-06-14 03:17:34 -04:00
|
|
|
class GpgSignature < ActiveRecord::Base
|
2017-07-20 09:44:15 -04:00
|
|
|
include ShaAttribute
|
2017-08-31 14:45:29 -04:00
|
|
|
include IgnorableColumn
|
|
|
|
|
|
|
|
ignore_column :valid_signature
|
2017-07-20 09:44:15 -04:00
|
|
|
|
|
|
|
sha_attribute :commit_sha
|
|
|
|
sha_attribute :gpg_key_primary_keyid
|
|
|
|
|
2017-08-24 08:21:30 -04:00
|
|
|
enum verification_status: {
|
|
|
|
unverified: 0,
|
|
|
|
verified: 1,
|
2017-08-24 08:21:42 -04:00
|
|
|
same_user_different_email: 2,
|
|
|
|
other_user: 3,
|
|
|
|
unverified_key: 4,
|
|
|
|
unknown_key: 5
|
2017-08-24 08:21:30 -04:00
|
|
|
}
|
|
|
|
|
2017-06-14 03:17:34 -04:00
|
|
|
belongs_to :project
|
|
|
|
belongs_to :gpg_key
|
|
|
|
|
|
|
|
validates :commit_sha, presence: true
|
2017-07-25 15:20:48 -04:00
|
|
|
validates :project_id, presence: true
|
2017-06-15 06:43:04 -04:00
|
|
|
validates :gpg_key_primary_keyid, presence: true
|
2017-07-06 04:17:09 -04:00
|
|
|
|
2017-07-25 10:23:52 -04:00
|
|
|
def gpg_key_primary_keyid
|
|
|
|
super&.upcase
|
|
|
|
end
|
|
|
|
|
2017-07-06 04:17:09 -04:00
|
|
|
def commit
|
|
|
|
project.commit(commit_sha)
|
|
|
|
end
|
2017-08-15 07:22:55 -04:00
|
|
|
|
|
|
|
def gpg_commit
|
2017-08-24 08:21:26 -04:00
|
|
|
Gitlab::Gpg::Commit.new(commit)
|
2017-08-15 07:22:55 -04:00
|
|
|
end
|
2017-06-14 03:17:34 -04:00
|
|
|
end
|