We still need the name of the person, so it might make sense to have a Person object to simplify the code. Later. Suggested-by: Duy Nguyen <pclouds@xxxxxxxxx> Signed-off-by: Felipe Contreras <felipe.contreras@xxxxxxxxx> --- contrib/related/git-related | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/contrib/related/git-related b/contrib/related/git-related index 4e9b916..f85e924 100755 --- a/contrib/related/git-related +++ b/contrib/related/git-related @@ -202,12 +202,15 @@ end # hash of hashes persons = Hash.new { |hash, key| hash[key] = {} } +names = {} commits.items.values.each do |commit| commit.roles.each do |person, roles| + name, email = person + names[email] ||= name roles.each do |role| - persons[person][role] ||= 0 - persons[person][role] += 1 + persons[email][role] ||= 0 + persons[email][role] += 1 end end end @@ -217,7 +220,7 @@ count_sort = lambda do |a, b| b[1].values.reduce(:+) <=> a[1].values.reduce(:+) end -persons.sort(&count_sort).each do |person, roles| +persons.sort(&count_sort).each do |email, roles| roles = roles.map do |role, count| percent = count.to_f * 100 / commits.size next if percent < $min_percent @@ -225,7 +228,7 @@ persons.sort(&count_sort).each do |person, roles| end.compact next if roles.empty? - name, email = person + name = names[email] # must quote chars? name = '"%s"' % name if name =~ /[^\w \-]/i person = name ? '%s <%s>' % [name, email] : email -- 1.8.2.1 -- To unsubscribe from this list: send the line "unsubscribe git" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html