2 # Copyright (c) 2007-2011 Heikki Hokkanen <hoxu@users.sf.net> & others (see doc/author.txt)
17 GNUPLOT_COMMON
= 'set terminal png transparent size 640,240\nset size 1.0,1.0\n'
18 ON_LINUX
= (platform
.system() == 'Linux')
19 WEEKDAYS
= ('Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun')
21 exectime_internal
= 0.0
22 exectime_external
= 0.0
23 time_start
= time
.time()
25 # By default, gnuplot is searched from path, but can be overridden with the
26 # environment variable "GNUPLOT"
27 gnuplot_cmd
= 'gnuplot'
28 if 'GNUPLOT' in os
.environ
:
29 gnuplot_cmd
= os
.environ
['GNUPLOT']
34 'style': 'gitstats.css',
39 'linear_linestats': 1,
43 def getpipeoutput(cmds
, quiet
= False):
44 global exectime_external
46 if not quiet
and ON_LINUX
and os
.isatty(1):
47 print '>> ' + ' | '.join(cmds
),
49 p0
= subprocess
.Popen(cmds
[0], stdout
= subprocess
.PIPE
, shell
= True)
52 p
= subprocess
.Popen(x
, stdin
= p0
.stdout
, stdout
= subprocess
.PIPE
, shell
= True)
54 output
= p
.communicate()[0]
57 if ON_LINUX
and os
.isatty(1):
59 print '[%.5f] >> %s' % (end
- start
, ' | '.join(cmds
))
60 exectime_external
+= (end
- start
)
61 return output
.rstrip('\n')
63 def getcommitrange(defaultrange
= 'HEAD', end_only
= False):
64 if len(conf
['commit_end']) > 0:
65 if end_only
or len(conf
['commit_begin']) == 0:
66 return conf
['commit_end']
67 return '%s..%s' % (conf
['commit_begin'], conf
['commit_end'])
70 def getkeyssortedbyvalues(dict):
71 return map(lambda el
: el
[1], sorted(map(lambda el
: (el
[1], el
[0]), dict.items())))
73 # dict['author'] = { 'commits': 512 } - ...key(dict, 'commits')
74 def getkeyssortedbyvaluekey(d
, key
):
75 return map(lambda el
: el
[1], sorted(map(lambda el
: (d
[el
][key
], el
), d
.keys())))
81 VERSION
= getpipeoutput(["git rev-parse --short %s" % getcommitrange('HEAD')]).split('\n')[0]
85 return getpipeoutput(['git --version']).split('\n')[0]
87 def getgnuplotversion():
88 return getpipeoutput(['gnuplot --version']).split('\n')[0]
91 """Manages data collection from a revision control repository."""
93 self
.stamp_created
= time
.time()
95 self
.total_authors
= 0
96 self
.activity_by_hour_of_day
= {} # hour -> commits
97 self
.activity_by_day_of_week
= {} # day -> commits
98 self
.activity_by_month_of_year
= {} # month [1-12] -> commits
99 self
.activity_by_hour_of_week
= {} # weekday -> hour -> commits
100 self
.activity_by_hour_of_day_busiest
= 0
101 self
.activity_by_hour_of_week_busiest
= 0
102 self
.activity_by_year_week
= {} # yy_wNN -> commits
103 self
.activity_by_year_week_peak
= 0
105 self
.authors
= {} # name -> {commits, first_commit_stamp, last_commit_stamp, last_active_day, active_days, lines_added, lines_removed}
107 self
.total_commits
= 0
109 self
.authors_by_commits
= 0
112 self
.domains
= {} # domain -> commits
114 # author of the month
115 self
.author_of_month
= {} # month -> author -> commits
116 self
.author_of_year
= {} # year -> author -> commits
117 self
.commits_by_month
= {} # month -> commits
118 self
.commits_by_year
= {} # year -> commits
119 self
.lines_added_by_month
= {} # month -> lines added
120 self
.lines_added_by_year
= {} # year -> lines added
121 self
.lines_removed_by_month
= {} # month -> lines removed
122 self
.lines_removed_by_year
= {} # year -> lines removed
123 self
.first_commit_stamp
= 0
124 self
.last_commit_stamp
= 0
125 self
.last_active_day
= None
126 self
.active_days
= set()
130 self
.total_lines_added
= 0
131 self
.total_lines_removed
= 0
137 self
.commits_by_timezone
= {} # timezone -> commits
142 self
.files_by_stamp
= {} # stamp -> files
145 self
.extensions
= {} # extension -> files, lines
148 self
.changes_by_date
= {} # stamp -> { files, ins, del }
151 # This should be the main function to extract data from the repository.
152 def collect(self
, dir):
154 if len(conf
['project_name']) == 0:
155 self
.projectname
= os
.path
.basename(os
.path
.abspath(dir))
157 self
.projectname
= conf
['project_name']
160 # Load cacheable data
161 def loadCache(self
, cachefile
):
162 if not os
.path
.exists(cachefile
):
164 print 'Loading cache...'
165 f
= open(cachefile
, 'rb')
167 self
.cache
= pickle
.loads(zlib
.decompress(f
.read()))
169 # temporary hack to upgrade non-compressed caches
171 self
.cache
= pickle
.load(f
)
175 # Produce any additional statistics from the extracted data.
180 # : get a dictionary of author
181 def getAuthorInfo(self
, author
):
184 def getActivityByDayOfWeek(self
):
187 def getActivityByHourOfDay(self
):
190 # : get a dictionary of domains
191 def getDomainInfo(self
, domain
):
195 # Get a list of authors
196 def getAuthors(self
):
199 def getFirstCommitDate(self
):
200 return datetime
.datetime
.now()
202 def getLastCommitDate(self
):
203 return datetime
.datetime
.now()
205 def getStampCreated(self
):
206 return self
.stamp_created
211 def getTotalAuthors(self
):
214 def getTotalCommits(self
):
217 def getTotalFiles(self
):
220 def getTotalLOC(self
):
224 # Save cacheable data
225 def saveCache(self
, cachefile
):
226 print 'Saving cache...'
227 f
= open(cachefile
, 'wb')
228 #pickle.dump(self.cache, f)
229 data
= zlib
.compress(pickle
.dumps(self
.cache
))
233 class GitDataCollector(DataCollector
):
234 def collect(self
, dir):
235 DataCollector
.collect(self
, dir)
238 self
.total_authors
+= int(getpipeoutput(['git shortlog -s %s' % getcommitrange(), 'wc -l']))
240 self
.total_authors
= 0
241 #self.total_lines = int(getoutput('git-ls-files -z |xargs -0 cat |wc -l'))
244 lines
= getpipeoutput(['git show-ref --tags']).split('\n')
248 (hash, tag
) = line
.split(' ')
250 tag
= tag
.replace('refs/tags/', '')
251 output
= getpipeoutput(['git log "%s" --pretty=format:"%%at %%aN" -n 1' % hash])
253 parts
= output
.split(' ')
256 stamp
= int(parts
[0])
259 self
.tags
[tag
] = { 'stamp': stamp
, 'hash' : hash, 'date' : datetime
.datetime
.fromtimestamp(stamp
).strftime('%Y-%m-%d'), 'commits': 0, 'authors': {} }
261 # collect info on tags, starting from latest
262 tags_sorted_by_date_desc
= map(lambda el
: el
[1], reversed(sorted(map(lambda el
: (el
[1]['date'], el
[0]), self
.tags
.items()))))
264 for tag
in reversed(tags_sorted_by_date_desc
):
265 cmd
= 'git shortlog -s "%s"' % tag
267 cmd
+= ' "^%s"' % prev
268 output
= getpipeoutput([cmd
])
272 for line
in output
.split('\n'):
273 parts
= re
.split('\s+', line
, 2)
274 commits
= int(parts
[1])
276 self
.tags
[tag
]['commits'] = commits
277 self
.tags
[tag
]['authors'][author
] = commits
279 # Collect revision statistics
280 # Outputs "<stamp> <date> <time> <timezone> <author> '<' <mail> '>'"
281 lines
= getpipeoutput(['git rev-list --pretty=format:"%%at %%ai %%aN <%%aE>" %s' % getcommitrange('HEAD'), 'grep -v ^commit']).split('\n')
283 parts
= line
.split(' ', 4)
286 stamp
= int(parts
[0])
290 author
, mail
= parts
[4].split('<', 1)
291 author
= author
.rstrip()
292 mail
= mail
.rstrip('>')
294 if mail
.find('@') != -1:
295 domain
= mail
.rsplit('@', 1)[1]
296 date
= datetime
.datetime
.fromtimestamp(float(stamp
))
298 # First and last commit stamp (may be in any order because of cherry-picking and patches)
299 if stamp
> self
.last_commit_stamp
:
300 self
.last_commit_stamp
= stamp
301 if self
.first_commit_stamp
== 0 or stamp
< self
.first_commit_stamp
:
302 self
.first_commit_stamp
= stamp
307 self
.activity_by_hour_of_day
[hour
] = self
.activity_by_hour_of_day
.get(hour
, 0) + 1
309 if self
.activity_by_hour_of_day
[hour
] > self
.activity_by_hour_of_day_busiest
:
310 self
.activity_by_hour_of_day_busiest
= self
.activity_by_hour_of_day
[hour
]
314 self
.activity_by_day_of_week
[day
] = self
.activity_by_day_of_week
.get(day
, 0) + 1
317 if domain
not in self
.domains
:
318 self
.domains
[domain
] = {}
320 self
.domains
[domain
]['commits'] = self
.domains
[domain
].get('commits', 0) + 1
323 if day
not in self
.activity_by_hour_of_week
:
324 self
.activity_by_hour_of_week
[day
] = {}
325 self
.activity_by_hour_of_week
[day
][hour
] = self
.activity_by_hour_of_week
[day
].get(hour
, 0) + 1
327 if self
.activity_by_hour_of_week
[day
][hour
] > self
.activity_by_hour_of_week_busiest
:
328 self
.activity_by_hour_of_week_busiest
= self
.activity_by_hour_of_week
[day
][hour
]
332 self
.activity_by_month_of_year
[month
] = self
.activity_by_month_of_year
.get(month
, 0) + 1
334 # yearly/weekly activity
335 yyw
= date
.strftime('%Y-%W')
336 self
.activity_by_year_week
[yyw
] = self
.activity_by_year_week
.get(yyw
, 0) + 1
337 if self
.activity_by_year_week_peak
< self
.activity_by_year_week
[yyw
]:
338 self
.activity_by_year_week_peak
= self
.activity_by_year_week
[yyw
]
341 if author
not in self
.authors
:
342 self
.authors
[author
] = {}
343 # commits, note again that commits may be in any date order because of cherry-picking and patches
344 if 'last_commit_stamp' not in self
.authors
[author
]:
345 self
.authors
[author
]['last_commit_stamp'] = stamp
346 if stamp
> self
.authors
[author
]['last_commit_stamp']:
347 self
.authors
[author
]['last_commit_stamp'] = stamp
348 if 'first_commit_stamp' not in self
.authors
[author
]:
349 self
.authors
[author
]['first_commit_stamp'] = stamp
350 if stamp
< self
.authors
[author
]['first_commit_stamp']:
351 self
.authors
[author
]['first_commit_stamp'] = stamp
353 # author of the month/year
354 yymm
= date
.strftime('%Y-%m')
355 if yymm
in self
.author_of_month
:
356 self
.author_of_month
[yymm
][author
] = self
.author_of_month
[yymm
].get(author
, 0) + 1
358 self
.author_of_month
[yymm
] = {}
359 self
.author_of_month
[yymm
][author
] = 1
360 self
.commits_by_month
[yymm
] = self
.commits_by_month
.get(yymm
, 0) + 1
363 if yy
in self
.author_of_year
:
364 self
.author_of_year
[yy
][author
] = self
.author_of_year
[yy
].get(author
, 0) + 1
366 self
.author_of_year
[yy
] = {}
367 self
.author_of_year
[yy
][author
] = 1
368 self
.commits_by_year
[yy
] = self
.commits_by_year
.get(yy
, 0) + 1
370 # authors: active days
371 yymmdd
= date
.strftime('%Y-%m-%d')
372 if 'last_active_day' not in self
.authors
[author
]:
373 self
.authors
[author
]['last_active_day'] = yymmdd
374 self
.authors
[author
]['active_days'] = set([yymmdd
])
375 elif yymmdd
!= self
.authors
[author
]['last_active_day']:
376 self
.authors
[author
]['last_active_day'] = yymmdd
377 self
.authors
[author
]['active_days'].add(yymmdd
)
379 # project: active days
380 if yymmdd
!= self
.last_active_day
:
381 self
.last_active_day
= yymmdd
382 self
.active_days
.add(yymmdd
)
385 self
.commits_by_timezone
[timezone
] = self
.commits_by_timezone
.get(timezone
, 0) + 1
387 # TODO Optimize this, it's the worst bottleneck
388 # outputs "<stamp> <files>" for each revision
389 revlines
= getpipeoutput(['git rev-list --pretty=format:"%%at %%T" %s' % getcommitrange('HEAD'), 'grep -v ^commit']).strip().split('\n')
391 for revline
in revlines
:
392 time
, rev
= revline
.split(' ')
393 linecount
= self
.getFilesInCommit(rev
)
394 lines
.append('%d %d' % (int(time
), linecount
))
396 self
.total_commits
+= len(lines
)
398 parts
= line
.split(' ')
401 (stamp
, files
) = parts
[0:2]
403 self
.files_by_stamp
[int(stamp
)] = int(files
)
405 print 'Warning: failed to parse line "%s"' % line
407 # extensions and size of files
408 lines
= getpipeoutput(['git ls-tree -r -l -z %s' % getcommitrange('HEAD', end_only
= True)]).split('\000')
410 self
.total_files
+= len(lines
)
414 parts
= re
.split('\s+', line
, 5)
419 self
.total_size
+= size
421 filename
= fullpath
.split('/')[-1] # strip directories
422 if filename
.find('.') == -1 or filename
.rfind('.') == 0:
425 ext
= filename
[(filename
.rfind('.') + 1):]
426 if len(ext
) > conf
['max_ext_length']:
429 if ext
not in self
.extensions
:
430 self
.extensions
[ext
] = {'files': 0, 'lines': 0}
432 self
.extensions
[ext
]['files'] += 1
434 self
.extensions
[ext
]['lines'] += self
.getLinesInBlob(sha1
)
436 print 'Warning: Could not count lines for file "%s"' % line
440 # N files changed, N insertions (+), N deletions(-)
442 self
.changes_by_date
= {} # stamp -> { files, ins, del }
443 # computation of lines of code by date is better done
444 # on a linear history.
446 if conf
['linear_linestats']:
447 extra
= '--first-parent -m'
448 lines
= getpipeoutput(['git log --shortstat %s --pretty=format:"%%at %%aN" %s' % (extra
, getcommitrange('HEAD'))]).split('\n')
450 files
= 0; inserted
= 0; deleted
= 0; total_lines
= 0
457 if line
.find('files changed,') == -1:
461 (stamp
, author
) = (int(line
[:pos
]), line
[pos
+1:])
462 self
.changes_by_date
[stamp
] = { 'files': files
, 'ins': inserted
, 'del': deleted
, 'lines': total_lines
}
464 date
= datetime
.datetime
.fromtimestamp(stamp
)
465 yymm
= date
.strftime('%Y-%m')
466 self
.lines_added_by_month
[yymm
] = self
.lines_added_by_month
.get(yymm
, 0) + inserted
467 self
.lines_removed_by_month
[yymm
] = self
.lines_removed_by_month
.get(yymm
, 0) + deleted
470 self
.lines_added_by_year
[yy
] = self
.lines_added_by_year
.get(yy
,0) + inserted
471 self
.lines_removed_by_year
[yy
] = self
.lines_removed_by_year
.get(yy
, 0) + deleted
473 files
, inserted
, deleted
= 0, 0, 0
475 print 'Warning: unexpected line "%s"' % line
477 print 'Warning: unexpected line "%s"' % line
479 numbers
= re
.findall('\d+', line
)
480 if len(numbers
) == 3:
481 (files
, inserted
, deleted
) = map(lambda el
: int(el
), numbers
)
482 total_lines
+= inserted
483 total_lines
-= deleted
484 self
.total_lines_added
+= inserted
485 self
.total_lines_removed
+= deleted
488 print 'Warning: failed to handle line "%s"' % line
489 (files
, inserted
, deleted
) = (0, 0, 0)
490 #self.changes_by_date[stamp] = { 'files': files, 'ins': inserted, 'del': deleted }
491 self
.total_lines
= total_lines
493 # Per-author statistics
495 # defined for stamp, author only if author commited at this timestamp.
496 self
.changes_by_date_by_author
= {} # stamp -> author -> lines_added
498 # Similar to the above, but never use --first-parent
499 # (we need to walk through every commit to know who
500 # committed what, not just through mainline)
501 lines
= getpipeoutput(['git log --shortstat --date-order --pretty=format:"%%at %%aN" %s' % (getcommitrange('HEAD'))]).split('\n')
503 files
= 0; inserted
= 0; deleted
= 0
511 if line
.find('files changed,') == -1:
516 (stamp
, author
) = (int(line
[:pos
]), line
[pos
+1:])
518 # clock skew, keep old timestamp to avoid having ugly graph
520 if author
not in self
.authors
:
521 self
.authors
[author
] = { 'lines_added' : 0, 'lines_removed' : 0, 'commits' : 0}
522 self
.authors
[author
]['commits'] = self
.authors
[author
].get('commits', 0) + 1
523 self
.authors
[author
]['lines_added'] = self
.authors
[author
].get('lines_added', 0) + inserted
524 self
.authors
[author
]['lines_removed'] = self
.authors
[author
].get('lines_removed', 0) + deleted
525 if stamp
not in self
.changes_by_date_by_author
:
526 self
.changes_by_date_by_author
[stamp
] = {}
527 if author
not in self
.changes_by_date_by_author
[stamp
]:
528 self
.changes_by_date_by_author
[stamp
][author
] = {}
529 self
.changes_by_date_by_author
[stamp
][author
]['lines_added'] = self
.authors
[author
]['lines_added']
530 self
.changes_by_date_by_author
[stamp
][author
]['commits'] = self
.authors
[author
]['commits']
531 files
, inserted
, deleted
= 0, 0, 0
533 print 'Warning: unexpected line "%s"' % line
535 print 'Warning: unexpected line "%s"' % line
537 numbers
= re
.findall('\d+', line
)
538 if len(numbers
) == 3:
539 (files
, inserted
, deleted
) = map(lambda el
: int(el
), numbers
)
541 print 'Warning: failed to handle line "%s"' % line
542 (files
, inserted
, deleted
) = (0, 0, 0)
546 # name -> {place_by_commits, commits_frac, date_first, date_last, timedelta}
547 self
.authors_by_commits
= getkeyssortedbyvaluekey(self
.authors
, 'commits')
548 self
.authors_by_commits
.reverse() # most first
549 for i
, name
in enumerate(self
.authors_by_commits
):
550 self
.authors
[name
]['place_by_commits'] = i
+ 1
552 for name
in self
.authors
.keys():
553 a
= self
.authors
[name
]
554 a
['commits_frac'] = (100 * float(a
['commits'])) / self
.getTotalCommits()
555 date_first
= datetime
.datetime
.fromtimestamp(a
['first_commit_stamp'])
556 date_last
= datetime
.datetime
.fromtimestamp(a
['last_commit_stamp'])
557 delta
= date_last
- date_first
558 a
['date_first'] = date_first
.strftime('%Y-%m-%d')
559 a
['date_last'] = date_last
.strftime('%Y-%m-%d')
560 a
['timedelta'] = delta
561 if 'lines_added' not in a
: a
['lines_added'] = 0
562 if 'lines_removed' not in a
: a
['lines_removed'] = 0
564 def getActiveDays(self
):
565 return self
.active_days
567 def getActivityByDayOfWeek(self
):
568 return self
.activity_by_day_of_week
570 def getActivityByHourOfDay(self
):
571 return self
.activity_by_hour_of_day
573 def getAuthorInfo(self
, author
):
574 return self
.authors
[author
]
576 def getAuthors(self
, limit
= None):
577 res
= getkeyssortedbyvaluekey(self
.authors
, 'commits')
581 def getCommitDeltaDays(self
):
582 return (self
.last_commit_stamp
- self
.first_commit_stamp
) / 86400 + 1
584 def getDomainInfo(self
, domain
):
585 return self
.domains
[domain
]
587 def getDomains(self
):
588 return self
.domains
.keys()
590 def getFilesInCommit(self
, rev
):
592 res
= self
.cache
['files_in_tree'][rev
]
594 res
= int(getpipeoutput(['git ls-tree -r --name-only "%s"' % rev
, 'wc -l']).split('\n')[0])
595 if 'files_in_tree' not in self
.cache
:
596 self
.cache
['files_in_tree'] = {}
597 self
.cache
['files_in_tree'][rev
] = res
601 def getFirstCommitDate(self
):
602 return datetime
.datetime
.fromtimestamp(self
.first_commit_stamp
)
604 def getLastCommitDate(self
):
605 return datetime
.datetime
.fromtimestamp(self
.last_commit_stamp
)
607 def getLinesInBlob(self
, sha1
):
609 res
= self
.cache
['lines_in_blob'][sha1
]
611 res
= int(getpipeoutput(['git cat-file blob %s' % sha1
, 'wc -l']).split()[0])
612 if 'lines_in_blob' not in self
.cache
:
613 self
.cache
['lines_in_blob'] = {}
614 self
.cache
['lines_in_blob'][sha1
] = res
618 lines
= getpipeoutput(['git show-ref --tags', 'cut -d/ -f3'])
619 return lines
.split('\n')
621 def getTagDate(self
, tag
):
622 return self
.revToDate('tags/' + tag
)
624 def getTotalAuthors(self
):
625 return self
.total_authors
627 def getTotalCommits(self
):
628 return self
.total_commits
630 def getTotalFiles(self
):
631 return self
.total_files
633 def getTotalLOC(self
):
634 return self
.total_lines
636 def getTotalSize(self
):
637 return self
.total_size
639 def revToDate(self
, rev
):
640 stamp
= int(getpipeoutput(['git log --pretty=format:%%at "%s" -n 1' % rev
]))
641 return datetime
.datetime
.fromtimestamp(stamp
).strftime('%Y-%m-%d')
644 """Creates the actual report based on given data."""
648 def create(self
, data
, path
):
652 def html_linkify(text
):
653 return text
.lower().replace(' ', '_')
655 def html_header(level
, text
):
656 name
= html_linkify(text
)
657 return '\n<h%d><a href="#%s" name="%s">%s</a></h%d>\n\n' % (level
, name
, name
, text
, level
)
659 class HTMLReportCreator(ReportCreator
):
660 def create(self
, data
, path
):
661 ReportCreator
.create(self
, data
, path
)
662 self
.title
= data
.projectname
664 # copy static files. Looks in the binary directory, ../share/gitstats and /usr/share/gitstats
665 binarypath
= os
.path
.dirname(os
.path
.abspath(__file__
))
666 secondarypath
= os
.path
.join(binarypath
, '..', 'share', 'gitstats')
667 basedirs
= [binarypath
, secondarypath
, '/usr/share/gitstats']
668 for file in ('gitstats.css', 'sortable.js', 'arrow-up.gif', 'arrow-down.gif', 'arrow-none.gif'):
669 for base
in basedirs
:
670 src
= base
+ '/' + file
671 if os
.path
.exists(src
):
672 shutil
.copyfile(src
, path
+ '/' + file)
675 print 'Warning: "%s" not found, so not copied (searched: %s)' % (file, basedirs
)
677 f
= open(path
+ "/index.html", 'w')
678 format
= '%Y-%m-%d %H:%M:%S'
681 f
.write('<h1>GitStats - %s</h1>' % data
.projectname
)
686 f
.write('<dt>Project name</dt><dd>%s</dd>' % (data
.projectname
))
687 f
.write('<dt>Generated</dt><dd>%s (in %d seconds)</dd>' % (datetime
.datetime
.now().strftime(format
), time
.time() - data
.getStampCreated()))
688 f
.write('<dt>Generator</dt><dd><a href="http://gitstats.sourceforge.net/">GitStats</a> (version %s), %s, %s</dd>' % (getversion(), getgitversion(), getgnuplotversion()))
689 f
.write('<dt>Report Period</dt><dd>%s to %s</dd>' % (data
.getFirstCommitDate().strftime(format
), data
.getLastCommitDate().strftime(format
)))
690 f
.write('<dt>Age</dt><dd>%d days, %d active days (%3.2f%%)</dd>' % (data
.getCommitDeltaDays(), len(data
.getActiveDays()), (100.0 * len(data
.getActiveDays()) / data
.getCommitDeltaDays())))
691 f
.write('<dt>Total Files</dt><dd>%s</dd>' % data
.getTotalFiles())
692 f
.write('<dt>Total Lines of Code</dt><dd>%s (%d added, %d removed)</dd>' % (data
.getTotalLOC(), data
.total_lines_added
, data
.total_lines_removed
))
693 f
.write('<dt>Total Commits</dt><dd>%s (average %.1f commits per active day, %.1f per all days)</dd>' % (data
.getTotalCommits(), float(data
.getTotalCommits()) / len(data
.getActiveDays()), float(data
.getTotalCommits()) / data
.getCommitDeltaDays()))
694 f
.write('<dt>Authors</dt><dd>%s (average %.1f commits per author)</dd>' % (data
.getTotalAuthors(), (1.0 * data
.getTotalCommits()) / data
.getTotalAuthors()))
697 f
.write('</body>\n</html>')
702 f
= open(path
+ '/activity.html', 'w')
704 f
.write('<h1>Activity</h1>')
707 #f.write('<h2>Last 30 days</h2>')
709 #f.write('<h2>Last 12 months</h2>')
713 f
.write(html_header(2, 'Weekly activity'))
714 f
.write('<p>Last %d weeks</p>' % WEEKS
)
716 # generate weeks to show (previous N weeks from now)
717 now
= datetime
.datetime
.now()
718 deltaweek
= datetime
.timedelta(7)
721 for i
in range(0, WEEKS
):
722 weeks
.insert(0, stampcur
.strftime('%Y-%W'))
723 stampcur
-= deltaweek
725 # top row: commits & bar
726 f
.write('<table class="noborders"><tr>')
727 for i
in range(0, WEEKS
):
729 if weeks
[i
] in data
.activity_by_year_week
:
730 commits
= data
.activity_by_year_week
[weeks
[i
]]
733 if weeks
[i
] in data
.activity_by_year_week
:
734 percentage
= float(data
.activity_by_year_week
[weeks
[i
]]) / data
.activity_by_year_week_peak
735 height
= max(1, int(200 * percentage
))
736 f
.write('<td style="text-align: center; vertical-align: bottom">%d<div style="display: block; background-color: red; width: 20px; height: %dpx"></div></td>' % (commits
, height
))
738 # bottom row: year/week
740 for i
in range(0, WEEKS
):
741 f
.write('<td>%s</td>' % (WEEKS
- i
))
742 f
.write('</tr></table>')
745 f
.write(html_header(2, 'Hour of Day'))
746 hour_of_day
= data
.getActivityByHourOfDay()
747 f
.write('<table><tr><th>Hour</th>')
748 for i
in range(0, 24):
749 f
.write('<th>%d</th>' % i
)
750 f
.write('</tr>\n<tr><th>Commits</th>')
751 fp
= open(path
+ '/hour_of_day.dat', 'w')
752 for i
in range(0, 24):
754 r
= 127 + int((float(hour_of_day
[i
]) / data
.activity_by_hour_of_day_busiest
) * 128)
755 f
.write('<td style="background-color: rgb(%d, 0, 0)">%d</td>' % (r
, hour_of_day
[i
]))
756 fp
.write('%d %d\n' % (i
, hour_of_day
[i
]))
758 f
.write('<td>0</td>')
759 fp
.write('%d 0\n' % i
)
761 f
.write('</tr>\n<tr><th>%</th>')
762 totalcommits
= data
.getTotalCommits()
763 for i
in range(0, 24):
765 r
= 127 + int((float(hour_of_day
[i
]) / data
.activity_by_hour_of_day_busiest
) * 128)
766 f
.write('<td style="background-color: rgb(%d, 0, 0)">%.2f</td>' % (r
, (100.0 * hour_of_day
[i
]) / totalcommits
))
768 f
.write('<td>0.00</td>')
769 f
.write('</tr></table>')
770 f
.write('<img src="hour_of_day.png" alt="Hour of Day" />')
771 fg
= open(path
+ '/hour_of_day.dat', 'w')
772 for i
in range(0, 24):
774 fg
.write('%d %d\n' % (i
+ 1, hour_of_day
[i
]))
776 fg
.write('%d 0\n' % (i
+ 1))
780 f
.write(html_header(2, 'Day of Week'))
781 day_of_week
= data
.getActivityByDayOfWeek()
782 f
.write('<div class="vtable"><table>')
783 f
.write('<tr><th>Day</th><th>Total (%)</th></tr>')
784 fp
= open(path
+ '/day_of_week.dat', 'w')
785 for d
in range(0, 7):
788 commits
= day_of_week
[d
]
789 fp
.write('%d %s %d\n' % (d
+ 1, WEEKDAYS
[d
], commits
))
791 f
.write('<th>%s</th>' % (WEEKDAYS
[d
]))
793 f
.write('<td>%d (%.2f%%)</td>' % (day_of_week
[d
], (100.0 * day_of_week
[d
]) / totalcommits
))
795 f
.write('<td>0</td>')
797 f
.write('</table></div>')
798 f
.write('<img src="day_of_week.png" alt="Day of Week" />')
802 f
.write(html_header(2, 'Hour of Week'))
805 f
.write('<tr><th>Weekday</th>')
806 for hour
in range(0, 24):
807 f
.write('<th>%d</th>' % (hour
))
810 for weekday
in range(0, 7):
811 f
.write('<tr><th>%s</th>' % (WEEKDAYS
[weekday
]))
812 for hour
in range(0, 24):
814 commits
= data
.activity_by_hour_of_week
[weekday
][hour
]
819 r
= 127 + int((float(commits
) / data
.activity_by_hour_of_week_busiest
) * 128)
820 f
.write(' style="background-color: rgb(%d, 0, 0)"' % r
)
821 f
.write('>%d</td>' % commits
)
829 f
.write(html_header(2, 'Month of Year'))
830 f
.write('<div class="vtable"><table>')
831 f
.write('<tr><th>Month</th><th>Commits (%)</th></tr>')
832 fp
= open (path
+ '/month_of_year.dat', 'w')
833 for mm
in range(1, 13):
835 if mm
in data
.activity_by_month_of_year
:
836 commits
= data
.activity_by_month_of_year
[mm
]
837 f
.write('<tr><td>%d</td><td>%d (%.2f %%)</td></tr>' % (mm
, commits
, (100.0 * commits
) / data
.getTotalCommits()))
838 fp
.write('%d %d\n' % (mm
, commits
))
840 f
.write('</table></div>')
841 f
.write('<img src="month_of_year.png" alt="Month of Year" />')
843 # Commits by year/month
844 f
.write(html_header(2, 'Commits by year/month'))
845 f
.write('<div class="vtable"><table><tr><th>Month</th><th>Commits</th><th>Lines added</th><th>Lines removed</th></tr>')
846 for yymm
in reversed(sorted(data
.commits_by_month
.keys())):
847 f
.write('<tr><td>%s</td><td>%d</td><td>%d</td><td>%d</td></tr>' % (yymm
, data
.commits_by_month
.get(yymm
,0), data
.lines_added_by_month
.get(yymm
,0), data
.lines_removed_by_month
.get(yymm
,0)))
848 f
.write('</table></div>')
849 f
.write('<img src="commits_by_year_month.png" alt="Commits by year/month" />')
850 fg
= open(path
+ '/commits_by_year_month.dat', 'w')
851 for yymm
in sorted(data
.commits_by_month
.keys()):
852 fg
.write('%s %s\n' % (yymm
, data
.commits_by_month
[yymm
]))
856 f
.write(html_header(2, 'Commits by Year'))
857 f
.write('<div class="vtable"><table><tr><th>Year</th><th>Commits (% of all)</th><th>Lines added</th><th>Lines removed</th></tr>')
858 for yy
in reversed(sorted(data
.commits_by_year
.keys())):
859 f
.write('<tr><td>%s</td><td>%d (%.2f%%)</td><td>%d</td><td>%d</td></tr>' % (yy
, data
.commits_by_year
.get(yy
,0), (100.0 * data
.commits_by_year
.get(yy
,0)) / data
.getTotalCommits(), data
.lines_added_by_year
.get(yy
,0), data
.lines_removed_by_year
.get(yy
,0)))
860 f
.write('</table></div>')
861 f
.write('<img src="commits_by_year.png" alt="Commits by Year" />')
862 fg
= open(path
+ '/commits_by_year.dat', 'w')
863 for yy
in sorted(data
.commits_by_year
.keys()):
864 fg
.write('%d %d\n' % (yy
, data
.commits_by_year
[yy
]))
867 # Commits by timezone
868 f
.write(html_header(2, 'Commits by Timezone'))
869 f
.write('<table><tr>')
870 f
.write('<th>Timezone</th><th>Commits</th>')
871 max_commits_on_tz
= max(data
.commits_by_timezone
.values())
872 for i
in sorted(data
.commits_by_timezone
.keys(), key
= lambda n
: int(n
)):
873 commits
= data
.commits_by_timezone
[i
]
874 r
= 127 + int((float(commits
) / max_commits_on_tz
) * 128)
875 f
.write('<tr><th>%s</th><td style="background-color: rgb(%d, 0, 0)">%d</td></tr>' % (i
, r
, commits
))
876 f
.write('</tr></table>')
878 f
.write('</body></html>')
883 f
= open(path
+ '/authors.html', 'w')
886 f
.write('<h1>Authors</h1>')
889 # Authors :: List of authors
890 f
.write(html_header(2, 'List of Authors'))
892 f
.write('<table class="authors sortable" id="authors">')
893 f
.write('<tr><th>Author</th><th>Commits (%)</th><th>+ lines</th><th>- lines</th><th>First commit</th><th>Last commit</th><th class="unsortable">Age</th><th>Active days</th><th># by commits</th></tr>')
894 for author
in data
.getAuthors(conf
['max_authors']):
895 info
= data
.getAuthorInfo(author
)
896 f
.write('<tr><td>%s</td><td>%d (%.2f%%)</td><td>%d</td><td>%d</td><td>%s</td><td>%s</td><td>%s</td><td>%d</td><td>%d</td></tr>' % (author
, info
['commits'], info
['commits_frac'], info
['lines_added'], info
['lines_removed'], info
['date_first'], info
['date_last'], info
['timedelta'], len(info
['active_days']), info
['place_by_commits']))
899 allauthors
= data
.getAuthors()
900 if len(allauthors
) > conf
['max_authors']:
901 rest
= allauthors
[conf
['max_authors']:]
902 f
.write('<p class="moreauthors">These didn\'t make it to the top: %s</p>' % ', '.join(rest
))
904 f
.write(html_header(2, 'Cumulated Added Lines of Code per Author'))
905 f
.write('<img src="lines_of_code_by_author.png" alt="Lines of code per Author" />')
906 if len(allauthors
) > conf
['max_authors']:
907 f
.write('<p class="moreauthors">Only top %d authors shown</p>' % conf
['max_authors'])
909 f
.write(html_header(2, 'Commits per Author'))
910 f
.write('<img src="commits_by_author.png" alt="Commits per Author" />')
911 if len(allauthors
) > conf
['max_authors']:
912 f
.write('<p class="moreauthors">Only top %d authors shown</p>' % conf
['max_authors'])
914 fgl
= open(path
+ '/lines_of_code_by_author.dat', 'w')
915 fgc
= open(path
+ '/commits_by_author.dat', 'w')
917 lines_by_authors
= {} # cumulated added lines by
918 # author. to save memory,
919 # changes_by_date_by_author[stamp][author] is defined
920 # only at points where author commits.
921 # lines_by_authors allows us to generate all the
922 # points in the .dat file.
924 # Don't rely on getAuthors to give the same order each
925 # time. Be robust and keep the list in a variable.
926 commits_by_authors
= {} # cumulated added lines by
928 self
.authors_to_plot
= data
.getAuthors(conf
['max_authors'])
929 for author
in self
.authors_to_plot
:
930 lines_by_authors
[author
] = 0
931 commits_by_authors
[author
] = 0
932 for stamp
in sorted(data
.changes_by_date_by_author
.keys()):
933 fgl
.write('%d' % stamp
)
934 fgc
.write('%d' % stamp
)
935 for author
in self
.authors_to_plot
:
936 if author
in data
.changes_by_date_by_author
[stamp
].keys():
937 lines_by_authors
[author
] = data
.changes_by_date_by_author
[stamp
][author
]['lines_added']
938 commits_by_authors
[author
] = data
.changes_by_date_by_author
[stamp
][author
]['commits']
939 fgl
.write(' %d' % lines_by_authors
[author
])
940 fgc
.write(' %d' % commits_by_authors
[author
])
946 # Authors :: Author of Month
947 f
.write(html_header(2, 'Author of Month'))
948 f
.write('<table class="sortable" id="aom">')
949 f
.write('<tr><th>Month</th><th>Author</th><th>Commits (%%)</th><th class="unsortable">Next top %d</th><th>Number of authors</th></tr>' % conf
['authors_top'])
950 for yymm
in reversed(sorted(data
.author_of_month
.keys())):
951 authordict
= data
.author_of_month
[yymm
]
952 authors
= getkeyssortedbyvalues(authordict
)
954 commits
= data
.author_of_month
[yymm
][authors
[0]]
955 next
= ', '.join(authors
[1:conf
['authors_top']+1])
956 f
.write('<tr><td>%s</td><td>%s</td><td>%d (%.2f%% of %d)</td><td>%s</td><td>%d</td></tr>' % (yymm
, authors
[0], commits
, (100.0 * commits
) / data
.commits_by_month
[yymm
], data
.commits_by_month
[yymm
], next
, len(authors
)))
960 f
.write(html_header(2, 'Author of Year'))
961 f
.write('<table class="sortable" id="aoy"><tr><th>Year</th><th>Author</th><th>Commits (%%)</th><th class="unsortable">Next top %d</th><th>Number of authors</th></tr>' % conf
['authors_top'])
962 for yy
in reversed(sorted(data
.author_of_year
.keys())):
963 authordict
= data
.author_of_year
[yy
]
964 authors
= getkeyssortedbyvalues(authordict
)
966 commits
= data
.author_of_year
[yy
][authors
[0]]
967 next
= ', '.join(authors
[1:conf
['authors_top']+1])
968 f
.write('<tr><td>%s</td><td>%s</td><td>%d (%.2f%% of %d)</td><td>%s</td><td>%d</td></tr>' % (yy
, authors
[0], commits
, (100.0 * commits
) / data
.commits_by_year
[yy
], data
.commits_by_year
[yy
], next
, len(authors
)))
972 f
.write(html_header(2, 'Commits by Domains'))
973 domains_by_commits
= getkeyssortedbyvaluekey(data
.domains
, 'commits')
974 domains_by_commits
.reverse() # most first
975 f
.write('<div class="vtable"><table>')
976 f
.write('<tr><th>Domains</th><th>Total (%)</th></tr>')
977 fp
= open(path
+ '/domains.dat', 'w')
979 for domain
in domains_by_commits
:
980 if n
== conf
['max_domains']:
984 info
= data
.getDomainInfo(domain
)
985 fp
.write('%s %d %d\n' % (domain
, n
, info
['commits']))
986 f
.write('<tr><th>%s</th><td>%d (%.2f%%)</td></tr>' % (domain
, info
['commits'], (100.0 * info
['commits'] / totalcommits
)))
987 f
.write('</table></div>')
988 f
.write('<img src="domains.png" alt="Commits by Domains" />')
991 f
.write('</body></html>')
996 f
= open(path
+ '/files.html', 'w')
998 f
.write('<h1>Files</h1>')
1002 f
.write('<dt>Total files</dt><dd>%d</dd>' % data
.getTotalFiles())
1003 f
.write('<dt>Total lines</dt><dd>%d</dd>' % data
.getTotalLOC())
1004 f
.write('<dt>Average file size</dt><dd>%.2f bytes</dd>' % (float(data
.getTotalSize()) / data
.getTotalFiles()))
1007 # Files :: File count by date
1008 f
.write(html_header(2, 'File count by date'))
1010 # use set to get rid of duplicate/unnecessary entries
1011 files_by_date
= set()
1012 for stamp
in sorted(data
.files_by_stamp
.keys()):
1013 files_by_date
.add('%s %d' % (datetime
.datetime
.fromtimestamp(stamp
).strftime('%Y-%m-%d'), data
.files_by_stamp
[stamp
]))
1015 fg
= open(path
+ '/files_by_date.dat', 'w')
1016 for line
in sorted(list(files_by_date
)):
1017 fg
.write('%s\n' % line
)
1018 #for stamp in sorted(data.files_by_stamp.keys()):
1019 # fg.write('%s %d\n' % (datetime.datetime.fromtimestamp(stamp).strftime('%Y-%m-%d'), data.files_by_stamp[stamp]))
1022 f
.write('<img src="files_by_date.png" alt="Files by Date" />')
1024 #f.write('<h2>Average file size by date</h2>')
1026 # Files :: Extensions
1027 f
.write(html_header(2, 'Extensions'))
1028 f
.write('<table class="sortable" id="ext"><tr><th>Extension</th><th>Files (%)</th><th>Lines (%)</th><th>Lines/file</th></tr>')
1029 for ext
in sorted(data
.extensions
.keys()):
1030 files
= data
.extensions
[ext
]['files']
1031 lines
= data
.extensions
[ext
]['lines']
1032 f
.write('<tr><td>%s</td><td>%d (%.2f%%)</td><td>%d (%.2f%%)</td><td>%d</td></tr>' % (ext
, files
, (100.0 * files
) / data
.getTotalFiles(), lines
, (100.0 * lines
) / data
.getTotalLOC(), lines
/ files
))
1035 f
.write('</body></html>')
1040 f
= open(path
+ '/lines.html', 'w')
1042 f
.write('<h1>Lines</h1>')
1046 f
.write('<dt>Total lines</dt><dd>%d</dd>' % data
.getTotalLOC())
1049 f
.write(html_header(2, 'Lines of Code'))
1050 f
.write('<img src="lines_of_code.png" />')
1052 fg
= open(path
+ '/lines_of_code.dat', 'w')
1053 for stamp
in sorted(data
.changes_by_date
.keys()):
1054 fg
.write('%d %d\n' % (stamp
, data
.changes_by_date
[stamp
]['lines']))
1057 f
.write('</body></html>')
1062 f
= open(path
+ '/tags.html', 'w')
1064 f
.write('<h1>Tags</h1>')
1068 f
.write('<dt>Total tags</dt><dd>%d</dd>' % len(data
.tags
))
1069 if len(data
.tags
) > 0:
1070 f
.write('<dt>Average commits per tag</dt><dd>%.2f</dd>' % (1.0 * data
.getTotalCommits() / len(data
.tags
)))
1073 f
.write('<table class="tags">')
1074 f
.write('<tr><th>Name</th><th>Date</th><th>Commits</th><th>Authors</th></tr>')
1075 # sort the tags by date desc
1076 tags_sorted_by_date_desc
= map(lambda el
: el
[1], reversed(sorted(map(lambda el
: (el
[1]['date'], el
[0]), data
.tags
.items()))))
1077 for tag
in tags_sorted_by_date_desc
:
1079 self
.authors_by_commits
= getkeyssortedbyvalues(data
.tags
[tag
]['authors'])
1080 for i
in reversed(self
.authors_by_commits
):
1081 authorinfo
.append('%s (%d)' % (i
, data
.tags
[tag
]['authors'][i
]))
1082 f
.write('<tr><td>%s</td><td>%s</td><td>%d</td><td>%s</td></tr>' % (tag
, data
.tags
[tag
]['date'], data
.tags
[tag
]['commits'], ', '.join(authorinfo
)))
1085 f
.write('</body></html>')
1088 self
.createGraphs(path
)
1090 def createGraphs(self
, path
):
1091 print 'Generating graphs...'
1094 f
= open(path
+ '/hour_of_day.plot', 'w')
1095 f
.write(GNUPLOT_COMMON
)
1098 set output 'hour_of_day.png'
1100 set xrange [0.5:24.5]
1103 set ylabel "Commits"
1104 plot 'hour_of_day.dat' using 1:2:(0.5) w boxes fs solid
1109 f
= open(path
+ '/day_of_week.plot', 'w')
1110 f
.write(GNUPLOT_COMMON
)
1113 set output 'day_of_week.png'
1115 set xrange [0.5:7.5]
1118 set ylabel "Commits"
1119 plot 'day_of_week.dat' using 1:3:(0.5):xtic(2) w boxes fs solid
1124 f
= open(path
+ '/domains.plot', 'w')
1125 f
.write(GNUPLOT_COMMON
)
1128 set output 'domains.png'
1133 set ylabel "Commits"
1134 plot 'domains.dat' using 2:3:(0.5) with boxes fs solid, '' using 2:3:1 with labels rotate by 45 offset 0,1
1139 f
= open(path
+ '/month_of_year.plot', 'w')
1140 f
.write(GNUPLOT_COMMON
)
1143 set output 'month_of_year.png'
1145 set xrange [0.5:12.5]
1148 set ylabel "Commits"
1149 plot 'month_of_year.dat' using 1:2:(0.5) w boxes fs solid
1153 # commits_by_year_month
1154 f
= open(path
+ '/commits_by_year_month.plot', 'w')
1155 f
.write(GNUPLOT_COMMON
)
1158 set output 'commits_by_year_month.png'
1162 set format x "%Y-%m"
1166 set ylabel "Commits"
1167 plot 'commits_by_year_month.dat' using 1:2:(0.5) w boxes fs solid
1172 f
= open(path
+ '/commits_by_year.plot', 'w')
1173 f
.write(GNUPLOT_COMMON
)
1176 set output 'commits_by_year.png'
1180 set ylabel "Commits"
1182 plot 'commits_by_year.dat' using 1:2:(0.5) w boxes fs solid
1187 f
= open(path
+ '/files_by_date.plot', 'w')
1188 f
.write(GNUPLOT_COMMON
)
1191 set output 'files_by_date.png'
1194 set timefmt "%Y-%m-%d"
1195 set format x "%Y-%m-%d"
1201 plot 'files_by_date.dat' using 1:2 w steps
1206 f
= open(path
+ '/lines_of_code.plot', 'w')
1207 f
.write(GNUPLOT_COMMON
)
1210 set output 'lines_of_code.png'
1214 set format x "%Y-%m-%d"
1219 plot 'lines_of_code.dat' using 1:2 w lines
1223 # Lines of Code Added per author
1224 f
= open(path
+ '/lines_of_code_by_author.plot', 'w')
1225 f
.write(GNUPLOT_COMMON
)
1228 set terminal png transparent size 640,480
1229 set output 'lines_of_code_by_author.png'
1233 set format x "%Y-%m-%d"
1242 for a
in self
.authors_to_plot
:
1244 plots
.append("""'lines_of_code_by_author.dat' using 1:%d title "%s" w lines""" % (i
, a
.replace("\"", "\\\"")))
1245 f
.write(", ".join(plots
))
1250 # Commits per author
1251 f
= open(path
+ '/commits_by_author.plot', 'w')
1252 f
.write(GNUPLOT_COMMON
)
1255 set terminal png transparent size 640,480
1256 set output 'commits_by_author.png'
1260 set format x "%Y-%m-%d"
1262 set ylabel "Commits"
1269 for a
in self
.authors_to_plot
:
1271 plots
.append("""'commits_by_author.dat' using 1:%d title "%s" w lines""" % (i
, a
.replace("\"", "\\\"")))
1272 f
.write(", ".join(plots
))
1278 files
= glob
.glob(path
+ '/*.plot')
1280 out
= getpipeoutput([gnuplot_cmd
+ ' "%s"' % f
])
1284 def printHeader(self
, f
, title
= ''):
1286 """<?xml version="1.0" encoding="UTF-8"?>
1287 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
1288 <html xmlns="http://www.w3.org/1999/xhtml">
1290 <title>GitStats - %s</title>
1291 <link rel="stylesheet" href="%s" type="text/css" />
1292 <meta name="generator" content="GitStats %s" />
1293 <script type="text/javascript" src="sortable.js"></script>
1296 """ % (self
.title
, conf
['style'], getversion()))
1298 def printNav(self
, f
):
1302 <li><a href="index.html">General</a></li>
1303 <li><a href="activity.html">Activity</a></li>
1304 <li><a href="authors.html">Authors</a></li>
1305 <li><a href="files.html">Files</a></li>
1306 <li><a href="lines.html">Lines</a></li>
1307 <li><a href="tags.html">Tags</a></li>
1314 def run(self
, args_orig
):
1315 optlist
, args
= getopt
.getopt(args_orig
, 'c:')
1318 key
, value
= v
.split('=', 1)
1320 raise KeyError('no such key "%s" in config' % key
)
1321 if isinstance(conf
[key
], int):
1322 conf
[key
] = int(value
)
1328 Usage: gitstats [options] <gitpath..> <outputpath>
1331 -c key=value Override configuration value
1333 Default config values:
1338 outputpath
= os
.path
.abspath(args
[-1])
1339 rundir
= os
.getcwd()
1342 os
.makedirs(outputpath
)
1345 if not os
.path
.isdir(outputpath
):
1346 print 'FATAL: Output path is not a directory or does not exist'
1349 print 'Output path: %s' % outputpath
1350 cachefile
= os
.path
.join(outputpath
, 'gitstats.cache')
1352 data
= GitDataCollector()
1353 data
.loadCache(cachefile
)
1355 for gitpath
in args
[0:-1]:
1356 print 'Git path: %s' % gitpath
1360 print 'Collecting data...'
1361 data
.collect(gitpath
)
1363 print 'Refining data...'
1364 data
.saveCache(cachefile
)
1369 print 'Generating report...'
1370 report
= HTMLReportCreator()
1371 report
.create(data
, outputpath
)
1373 time_end
= time
.time()
1374 exectime_internal
= time_end
- time_start
1375 print 'Execution time %.5f secs, %.5f secs (%.2f %%) in external commands)' % (exectime_internal
, exectime_external
, (100.0 * exectime_external
) / exectime_internal
)
1377 if __name__
=='__main__':