Use the same way to find the author for a particular commit
This was discovered in https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/7225#note_17974391
We have two ways to find a user for a particular commit, namely:
module Gitlab
module Identifier
# Tries to identify a user based on a commit SHA.
def identify_using_commit(project, ref)
commit = project.commit(ref)
return if !commit || !commit.author_email
email = commit.author_email
identify_with_cache(:email, email) do
User.find_by_any_email(email)
end
end
end
end
And this:
class Commit
def author
if RequestStore.active?
key = "commit_author:#{author_email.downcase}"
# nil is a valid value since no author may exist in the system
if RequestStore.store.has_key?(key)
@author = RequestStore.store[key]
else
@author = find_author_by_any_email
RequestStore.store[key] = @author
end
else
@author ||= find_author_by_any_email
end
end
end
We should merge the two, by changing the first one to something like:
module Gitlab
module Identifier
# Tries to identify a user based on a commit SHA.
def identify_using_commit(project, ref)
commit = project.commit(ref)
return if !commit || !commit.author_email
identify_with_cache(:email, commit.author_email) do
commit.author
end
end
end
end