Browse Source

Graph: Lines of Code.

Line statistics are gathered correctly (again).
Heikki Hokkanen 18 years ago
parent
commit
c9964f028c
1 changed files with 28 additions and 1 deletions
  1. 28
    1
      gitstats

+ 28
- 1
gitstats View File

246
 		lines = getoutput('git-log --shortstat --pretty=format:"%at %an" |tac').split('\n')
246
 		lines = getoutput('git-log --shortstat --pretty=format:"%at %an" |tac').split('\n')
247
 		files = 0; inserted = 0; deleted = 0; total_lines = 0
247
 		files = 0; inserted = 0; deleted = 0; total_lines = 0
248
 		for line in lines:
248
 		for line in lines:
249
+			if len(line) == 0:
250
+				continue
251
+
249
 			# <stamp> <author>
252
 			# <stamp> <author>
250
 			if line.find(',') == -1:
253
 			if line.find(',') == -1:
251
 				pos = line.find(' ')
254
 				pos = line.find(' ')
252
-				(stamp, author) = (line[:pos], line[pos+1:])
255
+				(stamp, author) = (int(line[:pos]), line[pos+1:])
253
 				self.changes_by_date[stamp] = { 'files': files, 'ins': inserted, 'del': deleted, 'lines': total_lines }
256
 				self.changes_by_date[stamp] = { 'files': files, 'ins': inserted, 'del': deleted, 'lines': total_lines }
254
 			else:
257
 			else:
255
 				numbers = re.findall('\d+', line)
258
 				numbers = re.findall('\d+', line)
581
 		f.write('<dt>Total lines</dt><dd>%d</dd>' % data.getTotalLOC())
584
 		f.write('<dt>Total lines</dt><dd>%d</dd>' % data.getTotalLOC())
582
 		f.write('</dl>\n')
585
 		f.write('</dl>\n')
583
 
586
 
587
+		f.write(html_header(2, 'Lines of Code'))
588
+		f.write('<img src="lines_of_code.png" />')
589
+
590
+		fg = open(path + '/lines_of_code.dat', 'w')
591
+		for stamp in sorted(data.changes_by_date.keys()):
592
+			fg.write('%d %d\n' % (stamp, data.changes_by_date[stamp]['lines']))
593
+		fg.close()
594
+
584
 		f.write('</body></html>')
595
 		f.write('</body></html>')
585
 		f.close()
596
 		f.close()
586
 
597
 
701
 """)
712
 """)
702
 		f.close()
713
 		f.close()
703
 
714
 
715
+		# Lines of Code
716
+		f = open(path + '/lines_of_code.plot', 'w')
717
+		f.write(GNUPLOT_COMMON)
718
+		f.write(
719
+"""
720
+set output 'lines_of_code.png'
721
+unset key
722
+set xdata time
723
+set timefmt "%s"
724
+set format x "%Y-%m-%d"
725
+set ylabel "Lines"
726
+set xtics rotate by 90
727
+plot 'lines_of_code.dat' using 1:2 w lines
728
+""")
729
+		f.close()
730
+
704
 		os.chdir(path)
731
 		os.chdir(path)
705
 		files = glob.glob(path + '/*.plot')
732
 		files = glob.glob(path + '/*.plot')
706
 		for f in files:
733
 		for f in files: