Просмотр исходного кода

Authors: show lines added/removed.

Heikki Hokkanen 16 лет назад
Родитель
Сommit
0f2064ca2a
1 измененных файлов: 8 добавлений и 3 удалений
  1. 8
    3
      gitstats

+ 8
- 3
gitstats Просмотреть файл

@@ -162,7 +162,7 @@ class GitDataCollector(DataCollector):
162 162
 		self.activity_by_year_week = {} # yy_wNN -> commits
163 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 167
 		# author of the month
168 168
 		self.author_of_month = {} # month -> author -> commits
@@ -364,6 +364,7 @@ class GitDataCollector(DataCollector):
364 364
 		lines = getpipeoutput(['git log --shortstat --pretty=format:"%at %an"']).split('\n')
365 365
 		lines.reverse()
366 366
 		files = 0; inserted = 0; deleted = 0; total_lines = 0
367
+		author = None
367 368
 		for line in lines:
368 369
 			if len(line) == 0:
369 370
 				continue
@@ -375,6 +376,10 @@ class GitDataCollector(DataCollector):
375 376
 					try:
376 377
 						(stamp, author) = (int(line[:pos]), line[pos+1:])
377 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 383
 					except ValueError:
379 384
 						print 'Warning: unexpected line "%s"' % line
380 385
 				else:
@@ -716,10 +721,10 @@ class HTMLReportCreator(ReportCreator):
716 721
 		f.write(html_header(2, 'List of Authors'))
717 722
 
718 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 725
 		for author in sorted(data.getAuthors()):
721 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 728
 		f.write('</table>')
724 729
 
725 730
 		# Authors :: Author of Month