Mercurial > hg > soundsoftware-site
comparison app/models/repository.rb @ 1533:59e13100ea95 cannam
Fix to user lookup
author | Chris Cannam |
---|---|
date | Wed, 11 Feb 2015 14:17:38 +0000 |
parents | a0460a3d154f |
children | 2696466256ff |
comparison
equal
deleted
inserted
replaced
1532:a0460a3d154f | 1533:59e13100ea95 |
---|---|
314 @found_committer_users ||= {} | 314 @found_committer_users ||= {} |
315 return @found_committer_users[committer] if @found_committer_users.has_key?(committer) | 315 return @found_committer_users[committer] if @found_committer_users.has_key?(committer) |
316 | 316 |
317 user = nil | 317 user = nil |
318 c = changesets.where(:committer => committer).includes(:user).first | 318 c = changesets.where(:committer => committer).includes(:user).first |
319 logger.info "seeking user for committer #{committer}" | |
320 if c && c.user | 319 if c && c.user |
321 user = c.user | 320 user = c.user |
322 elsif committer.strip =~ /^([^<]+)(<(.*)>)?$/ | 321 elsif committer.strip =~ /^([^<]+)(<(.*)>)?$/ |
323 username, email = $1.strip, $3 | 322 username, email = $1.strip, $3 |
324 logger.info "username = #{username}, email = #{email}" | |
325 u = User.find_by_login(username) | 323 u = User.find_by_login(username) |
326 if u.nil? | 324 if u.nil? |
327 if email.blank? | 325 if email.blank? |
328 if username.strip =~ /^([^ ]+) ([^ ]+)$/ | 326 if username.strip =~ /^([^ ]+) ([^ ]+)$/ |
329 first, last = $1, $2 | 327 first, last = $1, $2 |
330 logger.info "first = #{username}, last = #{email}" | 328 uu = User.where(:firstname => first, :lastname => last) |
331 u = User.where(:firstname => first, :lastname => last) | 329 if uu.length == 1 |
330 u = uu.first | |
331 else | |
332 logger.warn "find_committer_user: found more than one (#{uu.length}) results for user named #{username}, ignoring" | |
333 end | |
332 end | 334 end |
333 else | 335 else |
334 u = User.find_by_mail(email) | 336 u = User.find_by_mail(email) |
335 end | 337 end |
336 end | 338 end |