blob: 19cb5c38a53bcc5329e1de2b4e19a7418e36ea41 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
|
# Detect user based on identifier like
# key-13 or user-36 or last commit
module Gitlab
module Indentifier
def identify(identifier, project, newrev)
if identifier.blank?
# Local push from gitlab
email = project.repository.commit(newrev).author_email rescue nil
User.find_by_email(email) if email
elsif identifier =~ /\Auser-\d+\Z/
# git push over http
user_id = identifier.gsub("user-", "")
User.find_by_id(user_id)
elsif identifier =~ /\Akey-\d+\Z/
# git push over ssh
key_id = identifier.gsub("key-", "")
Key.find_by_id(key_id).try(:user)
end
end
end
end
|