ソースを参照

Added first gnuplot graph for "Commits by Year".

Heikki Hokkanen 18 年 前
コミット
fb8ad3b9ee
共有3 個のファイルを変更した54 個の追加2 個の削除を含む
  1. 6
    1
      TODO.txt
  2. 8
    0
      commits_by_year_month.plot
  3. 40
    1
      statgit

+ 6
- 1
TODO.txt ファイルの表示

@@ -1,3 +1,8 @@
1
+[]
2
+- copy/link statgit.css to target dir
3
+- Activity: gnuplot graphs of tables
4
+	- Commits by year/month
5
+
1 6
 - development statistics generator for git
2 7
 	- should be as versatile as statcvs / statsvn
3 8
 
@@ -48,7 +53,7 @@
48 53
 	- Total Files
49 54
 	- Average file size
50 55
 	- Average revisions per file
51
-	- (G) File Count: x = date, y = files
56
+	- (G) File Count by Date: x = date, y = files
52 57
 	- (G) Average file size: x = date, y = lines/file
53 58
 	- (T) File Extensions (or mime types from "file"?): extension, files (%), lines (%), lines/file
54 59
 	- (T) Largest Files?

+ 8
- 0
commits_by_year_month.plot ファイルの表示

@@ -0,0 +1,8 @@
1
+set terminal png
2
+set size 0.5,0.5
3
+set output 'commits_by_year_month.png'
4
+unset key
5
+set xdata time
6
+set timefmt "%Y-%m"
7
+set format x "%Y-%m"
8
+plot 'commits_by_year_month.dat' using 1:2 w lp

+ 40
- 1
statgit ファイルの表示

@@ -7,6 +7,8 @@ import os
7 7
 import re
8 8
 import sys
9 9
 
10
+GNUPLOT_COMMON = 'set terminal png\nset size 0.5,0.5\n'
11
+
10 12
 def getoutput(cmd):
11 13
 	print '>> %s' % cmd
12 14
 	output = commands.getoutput(cmd)
@@ -89,6 +91,8 @@ class GitDataCollector(DataCollector):
89 91
 		self.tags = {}
90 92
 		lines = getoutput('git-show-ref --tags').split('\n')
91 93
 		for line in lines:
94
+			if len(line) == 0:
95
+				continue
92 96
 			(hash, tag) = line.split(' ')
93 97
 			tag = tag.replace('refs/tags/', '')
94 98
 			output = getoutput('git-log "%s" --pretty=format:"%%at %%an" -n 1' % hash)
@@ -326,6 +330,11 @@ class HTMLReportCreator(ReportCreator):
326 330
 		for yy in reversed(sorted(data.commits_by_year.keys())):
327 331
 			f.write('<tr><td>%s</td><td>%d (%.2f%%)</td></tr>' % (yy, data.commits_by_year[yy], (100.0 * data.commits_by_year[yy]) / data.getTotalCommits()))
328 332
 		f.write('</table>')
333
+		f.write('<img src="commits_by_year.png" />')
334
+		fg = open(path + '/commits_by_year.dat', 'w')
335
+		for yy in sorted(data.commits_by_year.keys()):
336
+			fg.write('%d %d\n' % (yy, data.commits_by_year[yy]))
337
+		fg.close()
329 338
 
330 339
 		f.write('</body></html>')
331 340
 		f.close()
@@ -372,6 +381,18 @@ class HTMLReportCreator(ReportCreator):
372 381
 		f.write('</body></html>')
373 382
 		f.close()
374 383
 
384
+		###
385
+		# Files
386
+		f = open(path + '/files.html', 'w')
387
+		self.printHeader(f)
388
+		f.write('<h1>Files</h1>')
389
+		self.printNav(f)
390
+
391
+		f.write('<h2>File count by date</h2>')
392
+
393
+		f.write('</body></html>')
394
+		f.close()
395
+
375 396
 		###
376 397
 		# tags.html
377 398
 		f = open(path + '/tags.html', 'w')
@@ -381,7 +402,8 @@ class HTMLReportCreator(ReportCreator):
381 402
 
382 403
 		f.write('<dl>')
383 404
 		f.write('<dt>Total tags</dt><dd>%d</dd>' % len(data.tags))
384
-		f.write('<dt>Average commits per tag</dt><dd>%.2f</dd>' % (data.getTotalCommits() / len(data.tags)))
405
+		if len(data.tags) > 0:
406
+			f.write('<dt>Average commits per tag</dt><dd>%.2f</dd>' % (data.getTotalCommits() / len(data.tags)))
385 407
 		f.write('</dl>')
386 408
 
387 409
 		f.write('<table>')
@@ -394,7 +416,24 @@ class HTMLReportCreator(ReportCreator):
394 416
 
395 417
 		f.write('</body></html>')
396 418
 		f.close()
419
+
420
+		self.createGraphs(path)
397 421
 	pass
422
+	
423
+	def createGraphs(self, path):
424
+		# commits_by_year
425
+		f = open(path + '/commits_by_year.plot', 'w')
426
+		f.write(GNUPLOT_COMMON)
427
+		f.write('set output \'commits_by_year.png\'\n')
428
+		f.write('unset key\n')
429
+		f.write('set xtics 1\n')
430
+		f.write('plot \'commits_by_year.dat\' using 1:2 w lp')
431
+		f.close()
432
+
433
+		os.chdir(path)
434
+		os.system('gnuplot commits_by_year.plot')
435
+
436
+		pass
398 437
 
399 438
 	def printHeader(self, f):
400 439
 		f.write("""<html>