Commit b4868a897284940a3e5e8e6ebcc246f21fb17fbe
1 parent
f87f0201
Exists in
master
and in
4 other branches
Improved commit author detection
Showing
2 changed files
with
8 additions
and
3 deletions
Show diff stats
app/models/project.rb
| @@ -50,6 +50,11 @@ class Project < ActiveRecord::Base | @@ -50,6 +50,11 @@ class Project < ActiveRecord::Base | ||
| 50 | code | 50 | code |
| 51 | end | 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 | def common_notes | 58 | def common_notes |
| 54 | notes.where(:noteable_type => ["", nil]) | 59 | notes.where(:noteable_type => ["", nil]) |
| 55 | end | 60 | end |
app/views/projects/_tree_item.html.haml
| @@ -13,6 +13,6 @@ | @@ -13,6 +13,6 @@ | ||
| 13 | ago | 13 | ago |
| 14 | %td.commit | 14 | %td.commit |
| 15 | = link_to truncate(content_commit.safe_message, :length => fixed_mode? ? 40 : 80), project_commit_path(@project, content_commit), :class => "tree-commit-link" | 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) |