Commit d2dea3016197479bf4c039126ea7dfc7304a6fb2

Merge commit 'dysinger/commit-log-shows-author'

Commit diff

app/models/repository.rb

 
215215
216216 # Returns a Hash {email => user}, where email is selected from the +commits+
217217 def users_by_commits(commits)
218 emails = commits.map { |commit| commit.committer.email }.uniq
218 emails = commits.map { |commit| commit.author.email }.uniq
219219 users = User.find(:all, :conditions => ["email in (?)", emails])
220220
221221 users_by_email = users.inject({}){|hash, user| hash[user.email] = user; hash }
toggle raw diff

app/views/logs/_log.html.erb

 
11<% users_by_email = @repository.users_by_commits(@commits) %>
22<ul class="commit_list">
33<% @commits.each do |commit| -%>
4<% user = users_by_email[commit.committer.email] %>
4<% user = users_by_email[commit.author.email] %>
55<li class="commit_item">
66 <div>
77 <a href=""><%= link_to h(commit.id_abbrev),
88 project_repository_commit_path(@project, @repository, commit.id) -%></a>
9 by <strong><%= user ? link_to(user.login, user_path(user)) : h(commit.committer.name) -%></strong> <%=h time_ago_in_words(commit.committed_date) -%> ago
9 by <strong><%= user ? link_to(user.login, user_path(user)) : h(commit.author.name) -%></strong> <%=h time_ago_in_words(commit.authored_date) -%> ago
1010 </div>
11 <%= gravatar_frame(commit.committer.email, :size => 32) %>
11 <%= gravatar_frame(commit.author.email, :size => 32) %>
1212 <div class="commit_message"> <%= link_to simple_format(h(commit.short_message)), project_repository_commit_path(@project, @repository, commit.id) -%></div>
1313 <div class="clear_left"></div>
1414</li>
toggle raw diff

spec/models/repository_spec.rb

 
261261 commits = []
262262 users(:johan, :moe).map(&:email).each do |email|
263263 committer = OpenStruct.new(:email => email)
264 commits << OpenStruct.new(:committer => committer)
264 commits << OpenStruct.new(:committer => committer, :author => committer)
265265 end
266266 users = @repository.users_by_commits(commits)
267267 users.keys.sort.should == users(:johan, :moe).map(&:email).sort
toggle raw diff