|
|
@@ -1073,49 +1073,53 @@ plot 'lines_of_code.dat' using 1:2 w lines
|
|
1073
|
1073
|
""")
|
|
1074
|
1074
|
|
|
1075
|
1075
|
|
|
1076
|
|
-usage = """
|
|
|
1076
|
+class GitStats:
|
|
|
1077
|
+ def run(self, args):
|
|
|
1078
|
+ if len(args) < 2:
|
|
|
1079
|
+ print """
|
|
1077
|
1080
|
Usage: gitstats [options] <gitpath> <outputpath>
|
|
1078
|
1081
|
|
|
1079
|
1082
|
Options:
|
|
1080
|
1083
|
"""
|
|
|
1084
|
+ sys.exit(0)
|
|
1081
|
1085
|
|
|
1082
|
|
-if len(sys.argv) < 3:
|
|
1083
|
|
- print usage
|
|
1084
|
|
- sys.exit(0)
|
|
|
1086
|
+ gitpath = args[0]
|
|
|
1087
|
+ outputpath = os.path.abspath(args[1])
|
|
|
1088
|
+ rundir = os.getcwd()
|
|
1085
|
1089
|
|
|
1086
|
|
-gitpath = sys.argv[1]
|
|
1087
|
|
-outputpath = os.path.abspath(sys.argv[2])
|
|
1088
|
|
-rundir = os.getcwd()
|
|
|
1090
|
+ try:
|
|
|
1091
|
+ os.makedirs(outputpath)
|
|
|
1092
|
+ except OSError:
|
|
|
1093
|
+ pass
|
|
|
1094
|
+ if not os.path.isdir(outputpath):
|
|
|
1095
|
+ print 'FATAL: Output path is not a directory or does not exist'
|
|
|
1096
|
+ sys.exit(1)
|
|
|
1097
|
+
|
|
|
1098
|
+ print 'Git path: %s' % gitpath
|
|
|
1099
|
+ print 'Output path: %s' % outputpath
|
|
1089
|
1100
|
|
|
1090
|
|
-try:
|
|
1091
|
|
- os.makedirs(outputpath)
|
|
1092
|
|
-except OSError:
|
|
1093
|
|
- pass
|
|
1094
|
|
-if not os.path.isdir(outputpath):
|
|
1095
|
|
- print 'FATAL: Output path is not a directory or does not exist'
|
|
1096
|
|
- sys.exit(1)
|
|
|
1101
|
+ os.chdir(gitpath)
|
|
1097
|
1102
|
|
|
1098
|
|
-print 'Git path: %s' % gitpath
|
|
1099
|
|
-print 'Output path: %s' % outputpath
|
|
|
1103
|
+ cachefile = os.path.join(outputpath, 'gitstats.cache')
|
|
1100
|
1104
|
|
|
1101
|
|
-os.chdir(gitpath)
|
|
|
1105
|
+ print 'Collecting data...'
|
|
|
1106
|
+ data = GitDataCollector()
|
|
|
1107
|
+ data.loadCache(cachefile)
|
|
|
1108
|
+ data.collect(gitpath)
|
|
|
1109
|
+ print 'Refining data...'
|
|
|
1110
|
+ data.saveCache(cachefile)
|
|
|
1111
|
+ data.refine()
|
|
1102
|
1112
|
|
|
1103
|
|
-cachefile = os.path.join(outputpath, 'gitstats.cache')
|
|
|
1113
|
+ os.chdir(rundir)
|
|
1104
|
1114
|
|
|
1105
|
|
-print 'Collecting data...'
|
|
1106
|
|
-data = GitDataCollector()
|
|
1107
|
|
-data.loadCache(cachefile)
|
|
1108
|
|
-data.collect(gitpath)
|
|
1109
|
|
-print 'Refining data...'
|
|
1110
|
|
-data.saveCache(cachefile)
|
|
1111
|
|
-data.refine()
|
|
|
1115
|
+ print 'Generating report...'
|
|
|
1116
|
+ report = HTMLReportCreator()
|
|
|
1117
|
+ report.create(data, outputpath)
|
|
1112
|
1118
|
|
|
1113
|
|
-os.chdir(rundir)
|
|
|
1119
|
+ time_end = time.time()
|
|
|
1120
|
+ exectime_internal = time_end - time_start
|
|
|
1121
|
+ print 'Execution time %.5f secs, %.5f secs (%.2f %%) in external commands)' % (exectime_internal, exectime_external, (100.0 * exectime_external) / exectime_internal)
|
|
1114
|
1122
|
|
|
1115
|
|
-print 'Generating report...'
|
|
1116
|
|
-report = HTMLReportCreator()
|
|
1117
|
|
-report.create(data, outputpath)
|
|
|
1123
|
+g = GitStats()
|
|
|
1124
|
+g.run(sys.argv[1:])
|
|
1118
|
1125
|
|
|
1119
|
|
-time_end = time.time()
|
|
1120
|
|
-exectime_internal = time_end - time_start
|
|
1121
|
|
-print 'Execution time %.5f secs, %.5f secs (%.2f %%) in external commands)' % (exectime_internal, exectime_external, (100.0 * exectime_external) / exectime_internal)
|