Added reports by file types

Added first attempt for reporting by file type:
- A general report
- A report aggregated by file type and contributor
- A report aggregated by contributor and file type

Signed-off-by: Germán Póo-Caamaño <gpoo@gnome.org>
This commit is contained in:
Germán Póo-Caamaño
2011-06-24 00:17:30 -07:00
parent 19b718ef41
commit b2770f20b9
2 changed files with 51 additions and 2 deletions

9
gitdm
View File

@@ -41,6 +41,7 @@ CFName = 'gitdm.config'
DirName = '' DirName = ''
Aggregate = 'month' Aggregate = 'month'
Numstat = 0 Numstat = 0
ReportByFileType = 0
# #
# Options: # Options:
@@ -66,8 +67,9 @@ def ParseOpts ():
global MapUnknown, DevReports global MapUnknown, DevReports
global DateStats, AuthorSOBs, FileFilter, AkpmOverLt, DumpDB global DateStats, AuthorSOBs, FileFilter, AkpmOverLt, DumpDB
global CFName, CSVFile, CSVPrefix,DirName, Aggregate, Numstat global CFName, CSVFile, CSVPrefix,DirName, Aggregate, Numstat
global ReportByFileType
opts, rest = getopt.getopt (sys.argv[1:], 'ab:dc:Dh:l:no:p:r:suwx:z') opts, rest = getopt.getopt (sys.argv[1:], 'ab:dc:Dh:l:no:p:r:stuwx:z')
for opt in opts: for opt in opts:
if opt[0] == '-a': if opt[0] == '-a':
AkpmOverLt = 1 AkpmOverLt = 1
@@ -94,6 +96,8 @@ def ParseOpts ():
FileFilter = re.compile (opt[1]) FileFilter = re.compile (opt[1])
elif opt[0] == '-s': elif opt[0] == '-s':
AuthorSOBs = 0 AuthorSOBs = 0
elif opt[0] == '-t':
ReportByFileType = 1
elif opt[0] == '-u': elif opt[0] == '-u':
MapUnknown = 1 MapUnknown = 1
elif opt[0] == '-x': elif opt[0] == '-x':
@@ -485,3 +489,6 @@ if CSVFile:
if DevReports: if DevReports:
reports.DevReports (hlist, TotalChanged, CSCount, TotalRemoved) reports.DevReports (hlist, TotalChanged, CSCount, TotalRemoved)
reports.EmplReports (elist, TotalChanged, CSCount) reports.EmplReports (elist, TotalChanged, CSCount)
if ReportByFileType and Numstat:
reports.ReportByFileType (hlist)

View File

@@ -340,4 +340,46 @@ def EmplReports (elist, totalchanged, cscount):
ReportByELChanged (elist, totalchanged) ReportByELChanged (elist, totalchanged)
ReportByESOBs (elist) ReportByESOBs (elist)
ReportByEHackers (elist) ReportByEHackers (elist)
def ReportByFileType (hacker_list):
total = {}
total_by_hacker = {}
BeginReport ('Developer contributions by type')
for h in hacker_list:
by_hacker = {}
for patch in h.patches:
# Get a summary by hacker
for (filetype, (added, removed)) in patch.filetypes.iteritems():
if by_hacker.has_key(filetype):
by_hacker[filetype][patch.ADDED] += added
by_hacker[filetype][patch.REMOVED] += removed
else:
by_hacker[filetype] = [added, removed]
# Update the totals
if total.has_key(filetype):
total[filetype][patch.ADDED] += added
total[filetype][patch.REMOVED] += removed
else:
total[filetype] = [added, removed, []]
# Print a summary by hacker
print h.name
for filetype, counters in by_hacker.iteritems():
print '\t', filetype, counters
h_added = by_hacker[filetype][patch.ADDED]
h_removed = by_hacker[filetype][patch.REMOVED]
total[filetype][2].append ([h.name, h_added, h_removed])
# Print the global summary
BeginReport ('Contributions by type and developers')
for filetype, (added, removed, hackers) in total.iteritems():
print filetype, added, removed
for h, h_added, h_removed in hackers:
print '\t%s: [%d, %d]' % (h, h_added, h_removed)
# Print the very global summary
BeginReport ('General contributions by type')
for filetype, (added, removed, hackers) in total.iteritems():
print filetype, added, removed