Commit d9698628 authored by Douwe Maan's avatar Douwe Maan

Add Commit#author and #committer.

parent 403b7271
...@@ -134,12 +134,13 @@ module CommitsHelper ...@@ -134,12 +134,13 @@ module CommitsHelper
# avatar: true will prepend the avatar image # avatar: true will prepend the avatar image
# size: size of the avatar image in px # size: size of the avatar image in px
def commit_person_link(commit, options = {}) def commit_person_link(commit, options = {})
user = commit.send(options[:source])
source_name = clean(commit.send "#{options[:source]}_name".to_sym) source_name = clean(commit.send "#{options[:source]}_name".to_sym)
source_email = clean(commit.send "#{options[:source]}_email".to_sym) source_email = clean(commit.send "#{options[:source]}_email".to_sym)
user = User.find_for_commit(source_email, source_name) person_name = user.try(:name) || source_name
person_name = user.nil? ? source_name : user.name person_email = user.try(:email) || source_email
person_email = user.nil? ? source_email : user.email
text = text =
if options[:avatar] if options[:avatar]
......
...@@ -126,6 +126,14 @@ class Commit ...@@ -126,6 +126,14 @@ class Commit
"commit #{id}" "commit #{id}"
end end
def author
User.find_for_commit(author_email, author_name)
end
def committer
User.find_for_commit(committer_email, committer_name)
end
def method_missing(m, *args, &block) def method_missing(m, *args, &block)
@raw.send(m, *args, &block) @raw.send(m, *args, &block)
end end
......
...@@ -127,6 +127,6 @@ class GitPushService ...@@ -127,6 +127,6 @@ class GitPushService
end end
def commit_user(commit) def commit_user(commit)
User.find_for_commit(commit.author_email, commit.author_name) || user commit.author || user
end end
end end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment