Skip to content
This repository has been archived by the owner on Jan 6, 2022. It is now read-only.

Commit

Permalink
Added reports by file types
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
gpoo committed Jun 24, 2011
1 parent 19b718e commit b2770f2
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 2 deletions.
9 changes: 8 additions & 1 deletion gitdm
Expand Up @@ -41,6 +41,7 @@ CFName = 'gitdm.config'
DirName = ''
Aggregate = 'month'
Numstat = 0
ReportByFileType = 0

#
# Options:
Expand All @@ -66,8 +67,9 @@ def ParseOpts ():
global MapUnknown, DevReports
global DateStats, AuthorSOBs, FileFilter, AkpmOverLt, DumpDB
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:
if opt[0] == '-a':
AkpmOverLt = 1
Expand All @@ -94,6 +96,8 @@ def ParseOpts ():
FileFilter = re.compile (opt[1])
elif opt[0] == '-s':
AuthorSOBs = 0
elif opt[0] == '-t':
ReportByFileType = 1
elif opt[0] == '-u':
MapUnknown = 1
elif opt[0] == '-x':
Expand Down Expand Up @@ -485,3 +489,6 @@ if CSVFile:
if DevReports:
reports.DevReports (hlist, TotalChanged, CSCount, TotalRemoved)
reports.EmplReports (elist, TotalChanged, CSCount)

if ReportByFileType and Numstat:
reports.ReportByFileType (hlist)
44 changes: 43 additions & 1 deletion reports.py
Expand Up @@ -340,4 +340,46 @@ def EmplReports (elist, totalchanged, cscount):
ReportByELChanged (elist, totalchanged)
ReportByESOBs (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

0 comments on commit b2770f2

Please sign in to comment.