Commit b4868a897284940a3e5e8e6ebcc246f21fb17fbe

Authored by Dmitriy Zaporozhets
1 parent f87f0201

Improved commit author detection

app/models/project.rb
... ... @@ -50,6 +50,11 @@ class Project < ActiveRecord::Base
50 50 code
51 51 end
52 52  
  53 + def team_member_by_name_or_email(email = nil, name = nil)
  54 + user = users.where("email like ? or name like ?", email, name).first
  55 + users_projects.find_by_user_id(user.id) if user
  56 + end
  57 +
53 58 def common_notes
54 59 notes.where(:noteable_type => ["", nil])
55 60 end
... ...
app/views/projects/_tree_item.html.haml
... ... @@ -13,6 +13,6 @@
13 13 ago
14 14 %td.commit
15 15 = link_to truncate(content_commit.safe_message, :length => fixed_mode? ? 40 : 80), project_commit_path(@project, content_commit), :class => "tree-commit-link"
16   - - user = @project.users.find_by_email(content_commit.author_email)
17   - - if user
18   - = link_to "[#{user.name}]", project_team_member_path(@project, @project.users_projects.find_by_user_id(user.id))
  16 + - tm = @project.team_member_by_name_or_email(content_commit.author_email, content_commit.author_name)
  17 + - if tm
  18 + = link_to "[#{tm.user_name}]", project_team_member_path(@project, tm)
... ...