Commit 205f5f1283c5ed1ed2471a616b449dae08ab616b

Fixed Repository#commit_graph_data_by_author edge case of the commit count being nil when multiple "authors" with the same name have different emails

Commit diff

app/models/repository.rb

 
181181 def commit_graph_data_by_author(head = "master")
182182 h = {}
183183 emails = {}
184 count_author_regexp = /^\s+(\d+)\s(.+)\s\<(\S+)\>$/.freeze
185184 data = self.git.git.shortlog({:e => true, :s => true }, head)
186185 data.each_line do |line|
187 if line =~ count_author_regexp
188 count = $1.to_i
189 author = $2
190 email = $3
191
192 h[author] ||= 0
193 h[author] += count
194
195 emails[email] = author
196 end
186 count, actor = line.split("\t")
187 actor = Grit::Actor.from_string(actor)
188
189 h[actor.name] ||= 0
190 h[actor.name] += count.to_i
191 emails[actor.email] = actor.name
197192 end
198193
199194 users = User.find(:all, :conditions => ["email in (?)", emails.keys])
200195 users.each do |user|
201196 author_name = emails[user.email]
202 h[user.login] = h.delete(author_name)
197 if h[author_name] # in the event that a user with the same name has used two different emails, he'd be gone by now
198 h[user.login] = h.delete(author_name)
199 end
203200 end
204201
205202 h
toggle raw diff