Browse Source

Authors: show lines added/removed.

Heikki Hokkanen 16 years ago
parent
commit
0f2064ca2a
1 changed files with 8 additions and 3 deletions
  1. 8
    3
      gitstats

+ 8
- 3
gitstats View File

162
 		self.activity_by_year_week = {} # yy_wNN -> commits
162
 		self.activity_by_year_week = {} # yy_wNN -> commits
163
 		self.activity_by_year_week_peak = 0
163
 		self.activity_by_year_week_peak = 0
164
 
164
 
165
-		self.authors = {} # name -> {commits, first_commit_stamp, last_commit_stamp, last_active_day, active_days}
165
+		self.authors = {} # name -> {commits, first_commit_stamp, last_commit_stamp, last_active_day, active_days, lines_added, lines_removed}
166
 
166
 
167
 		# author of the month
167
 		# author of the month
168
 		self.author_of_month = {} # month -> author -> commits
168
 		self.author_of_month = {} # month -> author -> commits
364
 		lines = getpipeoutput(['git log --shortstat --pretty=format:"%at %an"']).split('\n')
364
 		lines = getpipeoutput(['git log --shortstat --pretty=format:"%at %an"']).split('\n')
365
 		lines.reverse()
365
 		lines.reverse()
366
 		files = 0; inserted = 0; deleted = 0; total_lines = 0
366
 		files = 0; inserted = 0; deleted = 0; total_lines = 0
367
+		author = None
367
 		for line in lines:
368
 		for line in lines:
368
 			if len(line) == 0:
369
 			if len(line) == 0:
369
 				continue
370
 				continue
375
 					try:
376
 					try:
376
 						(stamp, author) = (int(line[:pos]), line[pos+1:])
377
 						(stamp, author) = (int(line[:pos]), line[pos+1:])
377
 						self.changes_by_date[stamp] = { 'files': files, 'ins': inserted, 'del': deleted, 'lines': total_lines }
378
 						self.changes_by_date[stamp] = { 'files': files, 'ins': inserted, 'del': deleted, 'lines': total_lines }
379
+						if author not in self.authors:
380
+							self.authors[author] = { 'lines_added' : 0, 'lines_removed' : 0 }
381
+						self.authors[author]['lines_added'] = self.authors[author].get('lines_added', 0) + inserted
382
+						self.authors[author]['lines_removed'] = self.authors[author].get('lines_removed', 0) + deleted
378
 					except ValueError:
383
 					except ValueError:
379
 						print 'Warning: unexpected line "%s"' % line
384
 						print 'Warning: unexpected line "%s"' % line
380
 				else:
385
 				else:
716
 		f.write(html_header(2, 'List of Authors'))
721
 		f.write(html_header(2, 'List of Authors'))
717
 
722
 
718
 		f.write('<table class="authors sortable" id="authors">')
723
 		f.write('<table class="authors sortable" id="authors">')
719
-		f.write('<tr><th>Author</th><th>Commits (%)</th><th>First commit</th><th>Last commit</th><th class="unsortable">Age</th><th>Active days</th><th># by commits</th></tr>')
724
+		f.write('<tr><th>Author</th><th>Commits (%)</th><th>+ lines</th><th>- lines</th><th>First commit</th><th>Last commit</th><th class="unsortable">Age</th><th>Active days</th><th># by commits</th></tr>')
720
 		for author in sorted(data.getAuthors()):
725
 		for author in sorted(data.getAuthors()):
721
 			info = data.getAuthorInfo(author)
726
 			info = data.getAuthorInfo(author)
722
-			f.write('<tr><td>%s</td><td>%d (%.2f%%)</td><td>%s</td><td>%s</td><td>%s</td><td>%d</td><td>%d</td></tr>' % (author, info['commits'], info['commits_frac'], info['date_first'], info['date_last'], info['timedelta'], info['active_days'], info['place_by_commits']))
727
+			f.write('<tr><td>%s</td><td>%d (%.2f%%)</td><td>%d</td><td>%d</td><td>%s</td><td>%s</td><td>%s</td><td>%d</td><td>%d</td></tr>' % (author, info['commits'], info['lines_added'], info['lines_removed'], info['commits_frac'], info['date_first'], info['date_last'], info['timedelta'], info['active_days'], info['place_by_commits']))
723
 		f.write('</table>')
728
 		f.write('</table>')
724
 
729
 
725
 		# Authors :: Author of Month
730
 		# Authors :: Author of Month