Commit 205f5f1283c5ed1ed2471a616b449dae08ab616b
- Diff rendering mode:
- inline
- side by side
app/models/repository.rb
(9 / 12)
|   | |||
| 181 | 181 | def commit_graph_data_by_author(head = "master") | |
| 182 | 182 | h = {} | |
| 183 | 183 | emails = {} | |
| 184 | count_author_regexp = /^\s+(\d+)\s(.+)\s\<(\S+)\>$/.freeze | ||
| 185 | 184 | data = self.git.git.shortlog({:e => true, :s => true }, head) | |
| 186 | 185 | 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 | ||
| 197 | 192 | end | |
| 198 | 193 | ||
| 199 | 194 | users = User.find(:all, :conditions => ["email in (?)", emails.keys]) | |
| 200 | 195 | users.each do |user| | |
| 201 | 196 | 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 | ||
| 203 | 200 | end | |
| 204 | 201 | ||
| 205 | 202 | h |

