|
|
@@ -2,6 +2,7 @@
|
|
2
|
2
|
# Copyright (c) 2007-2010 Heikki Hokkanen <hoxu@users.sf.net> & others (see doc/author.txt)
|
|
3
|
3
|
# GPLv2 / GPLv3
|
|
4
|
4
|
import datetime
|
|
|
5
|
+import getopt
|
|
5
|
6
|
import glob
|
|
6
|
7
|
import os
|
|
7
|
8
|
import pickle
|
|
|
@@ -14,7 +15,6 @@ import time
|
|
14
|
15
|
import zlib
|
|
15
|
16
|
|
|
16
|
17
|
GNUPLOT_COMMON = 'set terminal png transparent\nset size 1.0,0.5\n'
|
|
17
|
|
-MAX_EXT_LENGTH = 10 # maximum file extension length
|
|
18
|
18
|
ON_LINUX = (platform.system() == 'Linux')
|
|
19
|
19
|
|
|
20
|
20
|
exectime_internal = 0.0
|
|
|
@@ -27,6 +27,12 @@ gnuplot_cmd = 'gnuplot'
|
|
27
|
27
|
if 'GNUPLOT' in os.environ:
|
|
28
|
28
|
gnuplot_cmd = os.environ['GNUPLOT']
|
|
29
|
29
|
|
|
|
30
|
+conf = {
|
|
|
31
|
+ 'max_domains': 10,
|
|
|
32
|
+ 'max_ext_length': 10,
|
|
|
33
|
+ 'style': 'gitstats.css'
|
|
|
34
|
+}
|
|
|
35
|
+
|
|
30
|
36
|
def getpipeoutput(cmds, quiet = False):
|
|
31
|
37
|
global exectime_external
|
|
32
|
38
|
start = time.time()
|
|
|
@@ -365,7 +371,7 @@ class GitDataCollector(DataCollector):
|
|
365
|
371
|
ext = ''
|
|
366
|
372
|
else:
|
|
367
|
373
|
ext = filename[(filename.rfind('.') + 1):]
|
|
368
|
|
- if len(ext) > MAX_EXT_LENGTH:
|
|
|
374
|
+ if len(ext) > conf['max_ext_length']:
|
|
369
|
375
|
ext = ''
|
|
370
|
376
|
|
|
371
|
377
|
if ext not in self.extensions:
|
|
|
@@ -800,9 +806,8 @@ class HTMLReportCreator(ReportCreator):
|
|
800
|
806
|
f.write('<tr><th>Domains</th><th>Total (%)</th></tr>')
|
|
801
|
807
|
fp = open(path + '/domains.dat', 'w')
|
|
802
|
808
|
n = 0
|
|
803
|
|
- max_domains = 10
|
|
804
|
809
|
for domain in domains_by_commits:
|
|
805
|
|
- if n == max_domains:
|
|
|
810
|
+ if n == conf['max_domains']:
|
|
806
|
811
|
break
|
|
807
|
812
|
commits = 0
|
|
808
|
813
|
n += 1
|
|
|
@@ -1051,12 +1056,12 @@ plot 'lines_of_code.dat' using 1:2 w lines
|
|
1051
|
1056
|
<html xmlns="http://www.w3.org/1999/xhtml">
|
|
1052
|
1057
|
<head>
|
|
1053
|
1058
|
<title>GitStats - %s</title>
|
|
1054
|
|
- <link rel="stylesheet" href="gitstats.css" type="text/css" />
|
|
|
1059
|
+ <link rel="stylesheet" href="%s" type="text/css" />
|
|
1055
|
1060
|
<meta name="generator" content="GitStats %s" />
|
|
1056
|
1061
|
<script type="text/javascript" src="sortable.js"></script>
|
|
1057
|
1062
|
</head>
|
|
1058
|
1063
|
<body>
|
|
1059
|
|
-""" % (self.title, getversion()))
|
|
|
1064
|
+""" % (self.title, conf['style'], getversion()))
|
|
1060
|
1065
|
|
|
1061
|
1066
|
def printNav(self, f):
|
|
1062
|
1067
|
f.write("""
|
|
|
@@ -1074,13 +1079,25 @@ plot 'lines_of_code.dat' using 1:2 w lines
|
|
1074
|
1079
|
|
|
1075
|
1080
|
|
|
1076
|
1081
|
class GitStats:
|
|
1077
|
|
- def run(self, args):
|
|
1078
|
|
- if len(args) < 2:
|
|
|
1082
|
+ def run(self, args_orig):
|
|
|
1083
|
+ optlist, args = getopt.getopt(args_orig, 'c:')
|
|
|
1084
|
+ for o,v in optlist:
|
|
|
1085
|
+ if o == '-c':
|
|
|
1086
|
+ key, value = v.split('=', 1)
|
|
|
1087
|
+ if key not in conf:
|
|
|
1088
|
+ raise 'Error: no such key "%s" in config' % key
|
|
|
1089
|
+ conf[key] = value
|
|
|
1090
|
+
|
|
|
1091
|
+ if len(args) < 2:
|
|
1079
|
1092
|
print """
|
|
1080
|
1093
|
Usage: gitstats [options] <gitpath> <outputpath>
|
|
1081
|
1094
|
|
|
1082
|
1095
|
Options:
|
|
1083
|
|
-"""
|
|
|
1096
|
+-c key=value Override configuration value
|
|
|
1097
|
+
|
|
|
1098
|
+Default config values:
|
|
|
1099
|
+%s
|
|
|
1100
|
+""" % conf
|
|
1084
|
1101
|
sys.exit(0)
|
|
1085
|
1102
|
|
|
1086
|
1103
|
gitpath = args[0]
|