From c9964f028c83bc5106d539be707b23e3fa946372 Mon Sep 17 00:00:00 2001 From: Heikki Hokkanen Date: Tue, 21 Aug 2007 15:50:26 +0300 Subject: [PATCH] Graph: Lines of Code. Line statistics are gathered correctly (again). --- gitstats | 29 ++++++++++++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) diff --git a/gitstats b/gitstats index b9adc01..7749e94 100755 --- a/gitstats +++ b/gitstats @@ -246,10 +246,13 @@ class GitDataCollector(DataCollector): lines = getoutput('git-log --shortstat --pretty=format:"%at %an" |tac').split('\n') files = 0; inserted = 0; deleted = 0; total_lines = 0 for line in lines: + if len(line) == 0: + continue + # if line.find(',') == -1: pos = line.find(' ') - (stamp, author) = (line[:pos], line[pos+1:]) + (stamp, author) = (int(line[:pos]), line[pos+1:]) self.changes_by_date[stamp] = { 'files': files, 'ins': inserted, 'del': deleted, 'lines': total_lines } else: numbers = re.findall('\d+', line) @@ -581,6 +584,14 @@ class HTMLReportCreator(ReportCreator): f.write('
Total lines
%d
' % data.getTotalLOC()) f.write('\n') + f.write(html_header(2, 'Lines of Code')) + f.write('') + + fg = open(path + '/lines_of_code.dat', 'w') + for stamp in sorted(data.changes_by_date.keys()): + fg.write('%d %d\n' % (stamp, data.changes_by_date[stamp]['lines'])) + fg.close() + f.write('') f.close() @@ -701,6 +712,22 @@ plot 'files_by_date.dat' using 1:2 smooth csplines """) f.close() + # Lines of Code + f = open(path + '/lines_of_code.plot', 'w') + f.write(GNUPLOT_COMMON) + f.write( +""" +set output 'lines_of_code.png' +unset key +set xdata time +set timefmt "%s" +set format x "%Y-%m-%d" +set ylabel "Lines" +set xtics rotate by 90 +plot 'lines_of_code.dat' using 1:2 w lines +""") + f.close() + os.chdir(path) files = glob.glob(path + '/*.plot') for f in files: -- 2.11.4.GIT