| |   |
| 215 | 215 | |
| 216 | 216 | # Returns a Hash {email => user}, where email is selected from the +commits+ |
| 217 | 217 | def users_by_commits(commits) |
| 218 | | emails = commits.map { |commit| commit.committer.email }.uniq |
| 218 | emails = commits.map { |commit| commit.author.email }.uniq |
| 219 | 219 | users = User.find(:all, :conditions => ["email in (?)", emails]) |
| 220 | 220 | |
| 221 | 221 | users_by_email = users.inject({}){|hash, user| hash[user.email] = user; hash } |
| toggle raw diff |
--- a/app/models/repository.rb
+++ b/app/models/repository.rb
@@ -215,7 +215,7 @@ class Repository < ActiveRecord::Base
# Returns a Hash {email => user}, where email is selected from the +commits+
def users_by_commits(commits)
- emails = commits.map { |commit| commit.committer.email }.uniq
+ emails = commits.map { |commit| commit.author.email }.uniq
users = User.find(:all, :conditions => ["email in (?)", emails])
users_by_email = users.inject({}){|hash, user| hash[user.email] = user; hash } |
| |   |
| 1 | 1 | <% users_by_email = @repository.users_by_commits(@commits) %> |
| 2 | 2 | <ul class="commit_list"> |
| 3 | 3 | <% @commits.each do |commit| -%> |
| 4 | | <% user = users_by_email[commit.committer.email] %> |
| 4 | <% user = users_by_email[commit.author.email] %> |
| 5 | 5 | <li class="commit_item"> |
| 6 | 6 | <div> |
| 7 | 7 | <a href=""><%= link_to h(commit.id_abbrev), |
| 8 | 8 | 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 |
| 10 | 10 | </div> |
| 11 | | <%= gravatar_frame(commit.committer.email, :size => 32) %> |
| 11 | <%= gravatar_frame(commit.author.email, :size => 32) %> |
| 12 | 12 | <div class="commit_message"> <%= link_to simple_format(h(commit.short_message)), project_repository_commit_path(@project, @repository, commit.id) -%></div> |
| 13 | 13 | <div class="clear_left"></div> |
| 14 | 14 | </li> |
| toggle raw diff |
--- a/app/views/logs/_log.html.erb
+++ b/app/views/logs/_log.html.erb
@@ -1,14 +1,14 @@
<% users_by_email = @repository.users_by_commits(@commits) %>
<ul class="commit_list">
<% @commits.each do |commit| -%>
-<% user = users_by_email[commit.committer.email] %>
+<% user = users_by_email[commit.author.email] %>
<li class="commit_item">
<div>
<a href=""><%= link_to h(commit.id_abbrev),
project_repository_commit_path(@project, @repository, commit.id) -%></a>
- by <strong><%= user ? link_to(user.login, user_path(user)) : h(commit.committer.name) -%></strong> <%=h time_ago_in_words(commit.committed_date) -%> ago
+ by <strong><%= user ? link_to(user.login, user_path(user)) : h(commit.author.name) -%></strong> <%=h time_ago_in_words(commit.authored_date) -%> ago
</div>
- <%= gravatar_frame(commit.committer.email, :size => 32) %>
+ <%= gravatar_frame(commit.author.email, :size => 32) %>
<div class="commit_message"> <%= link_to simple_format(h(commit.short_message)), project_repository_commit_path(@project, @repository, commit.id) -%></div>
<div class="clear_left"></div>
</li> |
| |   |
| 261 | 261 | commits = [] |
| 262 | 262 | users(:johan, :moe).map(&:email).each do |email| |
| 263 | 263 | committer = OpenStruct.new(:email => email) |
| 264 | | commits << OpenStruct.new(:committer => committer) |
| 264 | commits << OpenStruct.new(:committer => committer, :author => committer) |
| 265 | 265 | end |
| 266 | 266 | users = @repository.users_by_commits(commits) |
| 267 | 267 | users.keys.sort.should == users(:johan, :moe).map(&:email).sort |
| toggle raw diff |
--- a/spec/models/repository_spec.rb
+++ b/spec/models/repository_spec.rb
@@ -261,7 +261,7 @@ describe Repository do
commits = []
users(:johan, :moe).map(&:email).each do |email|
committer = OpenStruct.new(:email => email)
- commits << OpenStruct.new(:committer => committer)
+ commits << OpenStruct.new(:committer => committer, :author => committer)
end
users = @repository.users_by_commits(commits)
users.keys.sort.should == users(:johan, :moe).map(&:email).sort |