changeset 1534:b31caaed9d4d live

Look up users by name as well as email/login: for use with #1136
author Chris Cannam
date Wed, 11 Feb 2015 14:19:20 +0000
parents 83a2227efc71 (current diff) 59e13100ea95 (diff)
children e2c122809c5c
files
diffstat 1 files changed, 15 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/app/models/repository.rb	Wed Oct 08 14:04:32 2014 +0100
+++ b/app/models/repository.rb	Wed Feb 11 14:19:20 2015 +0000
@@ -321,7 +321,21 @@
       elsif committer.strip =~ /^([^<]+)(<(.*)>)?$/
         username, email = $1.strip, $3
         u = User.find_by_login(username)
-        u ||= User.find_by_mail(email) unless email.blank?
+        if u.nil?
+          if email.blank?
+            if username.strip =~ /^([^ ]+) ([^ ]+)$/
+              first, last = $1, $2
+              uu = User.where(:firstname => first, :lastname => last)
+              if uu.length == 1
+                u = uu.first
+              else
+                logger.warn "find_committer_user: found more than one (#{uu.length}) results for user named #{username}, ignoring"
+              end
+            end
+          else
+            u = User.find_by_mail(email)
+          end
+        end
         user = u
       end
       @found_committer_users[committer] = user