]> xenbits.xensource.com Git - people/larsk/xenproject-org-gitdm.git/commitdiff
Add -y option to aggregate changes by year, not month
authorAidan Skinner <aidan@skinner.me.uk>
Fri, 30 Sep 2011 12:14:26 +0000 (13:14 +0100)
committerJonathan Corbet <corbet@lwn.net>
Sun, 12 Feb 2012 18:46:30 +0000 (11:46 -0700)
csvdump.py
gitdm

index 6353a2bc476d69b780b4d55c2f5bcd22218b8c8d..c3f6b5ae2e7526c063e5388d48fc225bcd9753b9 100644 (file)
@@ -19,9 +19,12 @@ class CSVStat:
 PeriodCommitHash = { }
 
 def AccumulatePatch (p, Aggregate):
-    date = "%.2d-%.2d-01"%(p.date.year, p.date.month)
     if (Aggregate == 'week'):
         date = "%.2d-%.2d"%(p.date.isocalendar()[0], p.date.isocalendar()[1])
+    elif (Aggregate == 'year'):
+        date = "%.2d"%(p.date.year)
+    else:
+        date = "%.2d-%.2d-01"%(p.date.year, p.date.month)
     authdatekey = "%s-%s"%(p.author.name, date)
     if authdatekey not in PeriodCommitHash:
         empl = p.author.emailemployer (p.email, p.date)
diff --git a/gitdm b/gitdm
index 41634e6b1431788f1b7d4f15310ad7a974187a9d..1367ebd6a2b46eba18c0e46d14086f595f05b703 100755 (executable)
--- a/gitdm
+++ b/gitdm
@@ -62,6 +62,7 @@ ReportByFileType = 0
 # -u           Map unknown employers to '(Unknown)'
 # -x file.csv   Export raw statistics as CSV
 # -w        Aggregrate the raw statistics by weeks instead of months
+# -y            Aggregrate the raw statistics by years instead of months
 # -z           Dump out the hacker database at completion
 
 def ParseOpts ():
@@ -70,7 +71,7 @@ def ParseOpts ():
     global CFName, CSVFile, CSVPrefix,DirName, Aggregate, Numstat
     global ReportByFileType
 
-    opts, rest = getopt.getopt (sys.argv[1:], 'ab:dc:Dh:l:no:p:r:stuwx:z')
+    opts, rest = getopt.getopt (sys.argv[1:], 'ab:dc:Dh:l:no:p:r:stuwx:yz')
     for opt in opts:
         if opt[0] == '-a':
             AkpmOverLt = 1
@@ -106,6 +107,8 @@ def ParseOpts ():
             print "open output file " + opt[1] + "\n"
         elif opt [0] == '-w':
             Aggregate = 'week'
+        elif opt [0] == '-y':
+            Aggregate = 'year'
         elif opt[0] == '-z':
             DumpDB = 1