mirror of
https://github.com/hoxu/gitstats.git
synced 2026-03-01 18:23:26 +01:00
Catch ZeroDivisionError in file extension stats.
Otherwise it would not be possible to generate stats for binary-only repositories.
This commit is contained in:
6
gitstats
6
gitstats
@@ -1050,7 +1050,11 @@ class HTMLReportCreator(ReportCreator):
|
||||
for ext in sorted(data.extensions.keys()):
|
||||
files = data.extensions[ext]['files']
|
||||
lines = data.extensions[ext]['lines']
|
||||
f.write('<tr><td>%s</td><td>%d (%.2f%%)</td><td>%d (%.2f%%)</td><td>%d</td></tr>' % (ext, files, (100.0 * files) / data.getTotalFiles(), lines, (100.0 * lines) / data.getTotalLOC(), lines / files))
|
||||
try:
|
||||
loc_percentage = (100.0 * lines) / data.getTotalLOC()
|
||||
except ZeroDivisionError:
|
||||
loc_percentage = 0
|
||||
f.write('<tr><td>%s</td><td>%d (%.2f%%)</td><td>%d (%.2f%%)</td><td>%d</td></tr>' % (ext, files, (100.0 * files) / data.getTotalFiles(), lines, loc_percentage, lines / files))
|
||||
f.write('</table>')
|
||||
|
||||
f.write('</body></html>')
|
||||
|
||||
Reference in New Issue
Block a user