stat = PeriodCommitHash[authdatekey]
stat.accumulate (p)
+ChangeSets = []
+FileTypes = []
+
+def store_patch(patch):
+ if not patch.merge:
+ employer = patch.author.emailemployer(patch.email, patch.date)
+ employer = employer.name.replace('"', '.').replace ('\\', '.')
+ author = patch.author.name.replace ('"', '.').replace ('\\', '.')
+ author = patch.author.name.replace ("'", '.')
+ try:
+ domain = patch.email.split('@')[1]
+ except:
+ domain = patch.email
+ ChangeSets.append([patch.commit, str(patch.date),
+ patch.email, domain, author, employer,
+ patch.added, patch.removed])
+ for (filetype, (added, removed)) in patch.filetypes.iteritems():
+ FileTypes.append([patch.commit, filetype, added, removed])
+
+
+def save_csv (prefix='data'):
+ # Dump the ChangeSets
+ if len(ChangeSets) > 0:
+ fd = open('%s-changesets.csv' % prefix, 'w')
+ writer = csv.writer (fd, quoting=csv.QUOTE_NONNUMERIC)
+ writer.writerow (['Commit', 'Date', 'Domain',
+ 'Email', 'Name', 'Affliation',
+ 'Added', 'Removed'])
+ for commit in ChangeSets:
+ writer.writerow(commit)
+
+ # Dump the file types
+ if len(FileTypes) > 0:
+ fd = open('%s-filetypes.csv' % prefix, 'w')
+ writer = csv.writer (fd, quoting=csv.QUOTE_NONNUMERIC)
+
+ writer.writerow (['Commit', 'Type', 'Added', 'Removed'])
+ for commit in FileTypes:
+ writer.writerow(commit)
+
+
+
def OutputCSV (file):
if file is None:
return
writer.writerow ([author_name, stat.email, empl_name, stat.date,
stat.added, stat.removed])
-__all__ = [ 'OutputCSV' ]
+__all__ = [ 'AccumulatePatch', 'OutputCSV', 'store_patch' ]
AuthorSOBs = 1
FileFilter = None
CSVFile = None
+CSVPrefix = None
AkpmOverLt = 0
DumpDB = 0
CFName = 'gitdm.config'
# -l count Maximum length for output lists
# -n Use numstats instead of generated patch from git log
# -o file File for text output
+# -p prefix Prefix for CSV output
# -r pattern Restrict to files matching pattern
# -s Ignore author SOB lines
# -u Map unknown employers to '(Unknown)'
def ParseOpts ():
global MapUnknown, DevReports
global DateStats, AuthorSOBs, FileFilter, AkpmOverLt, DumpDB
- global CFName, CSVFile, DirName, Aggregate, Numstat
+ global CFName, CSVFile, CSVPrefix,DirName, Aggregate, Numstat
- opts, rest = getopt.getopt (sys.argv[1:], 'ab:dc:Dh:l:no:r:suwx:z')
+ opts, rest = getopt.getopt (sys.argv[1:], 'ab:dc:Dh:l:no:p:r:suwx:z')
for opt in opts:
if opt[0] == '-a':
AkpmOverLt = 1
Numstat = 1
elif opt[0] == '-o':
reports.SetOutput (open (opt[1], 'w'))
+ elif opt[0] == '-p':
+ CSVPrefix = opt[1]
elif opt[0] == '-r':
print 'Filter on "%s"' % (opt[1])
FileFilter = re.compile (opt[1])
hacker.addreport (p)
CSCount += 1
csvdump.AccumulatePatch (p, Aggregate)
+ csvdump.store_patch (p)
print >> sys.stderr, 'Grabbing changesets...done '
if DumpDB:
if DateStats:
PrintDateStats ()
-csvdump.OutputCSV (CSVFile)
-if CSVFile is not None:
+if CSVPrefix:
+ csvdump.save_csv (CSVPrefix)
+
+if CSVFile:
+ csvdump.OutputCSV (CSVFile)
CSVFile.close ()
if DevReports: