2 # Copyright (c) 2007 Heikki Hokkanen <hoxu@users.sf.net>
13 GNUPLOT_COMMON
= 'set terminal png transparent\nset size 0.5,0.5\n'
15 def getoutput(cmd
, quiet
= False):
20 output
= commands
.getoutput(cmd
)
23 print '\r[%.5f] >> %s' % (end
- start
, cmd
)
26 def getkeyssortedbyvalues(dict):
27 return map(lambda el
: el
[1], sorted(map(lambda el
: (el
[1], el
[0]), dict.items())))
29 # TODO getdictkeyssortedbyvaluekey(dict, key) - eg. dict['author'] = { 'commits' : 512 } - ...key(dict, 'commits')
32 """Manages data collection from a revision control repository."""
34 self
.stamp_created
= time
.time()
38 # This should be the main function to extract data from the repository.
39 def collect(self
, dir):
41 self
.projectname
= os
.path
.basename(os
.path
.abspath(dir))
44 # : get a dictionary of author
45 def getAuthorInfo(self
, author
):
48 def getActivityByDayOfWeek(self
):
51 def getActivityByHourOfDay(self
):
55 # Get a list of authors
59 def getFirstCommitDate(self
):
60 return datetime
.datetime
.now()
62 def getLastCommitDate(self
):
63 return datetime
.datetime
.now()
65 def getStampCreated(self
):
66 return self
.stamp_created
71 def getTotalAuthors(self
):
74 def getTotalCommits(self
):
77 def getTotalFiles(self
):
80 def getTotalLOC(self
):
83 class GitDataCollector(DataCollector
):
84 def collect(self
, dir):
85 DataCollector
.collect(self
, dir)
87 self
.total_authors
= int(getoutput('git-log |git-shortlog -s |wc -l'))
88 self
.total_files
= int(getoutput('git-ls-files |wc -l'))
89 #self.total_lines = int(getoutput('git-ls-files -z |xargs -0 cat |wc -l'))
91 self
.activity_by_hour_of_day
= {} # hour -> commits
92 self
.activity_by_day_of_week
= {} # day -> commits
93 self
.activity_by_month_of_year
= {} # month [1-12] -> commits
94 self
.activity_by_hour_of_week
= {} # weekday -> hour -> commits
96 self
.authors
= {} # name -> {commits, first_commit_stamp, last_commit_stamp}
99 self
.author_of_month
= {} # month -> author -> commits
100 self
.author_of_year
= {} # year -> author -> commits
101 self
.commits_by_month
= {} # month -> commits
102 self
.commits_by_year
= {} # year -> commits
103 self
.first_commit_stamp
= 0
104 self
.last_commit_stamp
= 0
108 lines
= getoutput('git-show-ref --tags').split('\n')
112 (hash, tag
) = line
.split(' ')
113 tag
= tag
.replace('refs/tags/', '')
114 output
= getoutput('git-log "%s" --pretty=format:"%%at %%an" -n 1' % hash)
116 parts
= output
.split(' ')
119 stamp
= int(parts
[0])
122 self
.tags
[tag
] = { 'stamp': stamp
, 'hash' : hash, 'date' : datetime
.datetime
.fromtimestamp(stamp
).strftime('%Y-%m-%d') }
125 # Collect revision statistics
126 # Outputs "<stamp> <author>"
127 lines
= getoutput('git-rev-list --pretty=format:"%at %an" HEAD |grep -v ^commit').split('\n')
129 # linux-2.6 says "<unknown>" for one line O_o
130 parts
= line
.split(' ')
133 stamp
= int(parts
[0])
137 author
= ' '.join(parts
[1:])
138 date
= datetime
.datetime
.fromtimestamp(float(stamp
))
140 # First and last commit stamp
141 if self
.last_commit_stamp
== 0:
142 self
.last_commit_stamp
= stamp
143 self
.first_commit_stamp
= stamp
148 if hour
in self
.activity_by_hour_of_day
:
149 self
.activity_by_hour_of_day
[hour
] += 1
151 self
.activity_by_hour_of_day
[hour
] = 1
155 if day
in self
.activity_by_day_of_week
:
156 self
.activity_by_day_of_week
[day
] += 1
158 self
.activity_by_day_of_week
[day
] = 1
161 if day
not in self
.activity_by_hour_of_week
:
162 self
.activity_by_hour_of_week
[day
] = {}
163 if hour
not in self
.activity_by_hour_of_week
[day
]:
164 self
.activity_by_hour_of_week
[day
][hour
] = 1
166 self
.activity_by_hour_of_week
[day
][hour
] += 1
170 if month
in self
.activity_by_month_of_year
:
171 self
.activity_by_month_of_year
[month
] += 1
173 self
.activity_by_month_of_year
[month
] = 1
176 if author
not in self
.authors
:
177 self
.authors
[author
] = {}
179 if 'last_commit_stamp' not in self
.authors
[author
]:
180 self
.authors
[author
]['last_commit_stamp'] = stamp
181 self
.authors
[author
]['first_commit_stamp'] = stamp
182 if 'commits' in self
.authors
[author
]:
183 self
.authors
[author
]['commits'] += 1
185 self
.authors
[author
]['commits'] = 1
187 # author of the month/year
188 yymm
= datetime
.datetime
.fromtimestamp(stamp
).strftime('%Y-%m')
189 if yymm
in self
.author_of_month
:
190 if author
in self
.author_of_month
[yymm
]:
191 self
.author_of_month
[yymm
][author
] += 1
193 self
.author_of_month
[yymm
][author
] = 1
195 self
.author_of_month
[yymm
] = {}
196 self
.author_of_month
[yymm
][author
] = 1
197 if yymm
in self
.commits_by_month
:
198 self
.commits_by_month
[yymm
] += 1
200 self
.commits_by_month
[yymm
] = 1
202 yy
= datetime
.datetime
.fromtimestamp(stamp
).year
203 if yy
in self
.author_of_year
:
204 if author
in self
.author_of_year
[yy
]:
205 self
.author_of_year
[yy
][author
] += 1
207 self
.author_of_year
[yy
][author
] = 1
209 self
.author_of_year
[yy
] = {}
210 self
.author_of_year
[yy
][author
] = 1
211 if yy
in self
.commits_by_year
:
212 self
.commits_by_year
[yy
] += 1
214 self
.commits_by_year
[yy
] = 1
216 # TODO Optimize this, it's the worst bottleneck
217 # outputs "<stamp> <files>" for each revision
218 self
.files_by_stamp
= {} # stamp -> files
219 lines
= getoutput('git-rev-list --pretty=format:"%at %H" HEAD |grep -v ^commit |while read line; do set $line; echo "$1 $(git-ls-tree -r "$2" |wc -l)"; done').split('\n')
220 self
.total_commits
= len(lines
)
222 parts
= line
.split(' ')
225 (stamp
, files
) = parts
[0:2]
227 self
.files_by_stamp
[int(stamp
)] = int(files
)
229 print 'Warning: failed to parse line "%s"' % line
232 self
.extensions
= {} # extension -> files, lines
233 lines
= getoutput('git-ls-files').split('\n')
235 base
= os
.path
.basename(line
)
236 if base
.find('.') == -1:
239 ext
= base
[(base
.rfind('.') + 1):]
241 if ext
not in self
.extensions
:
242 self
.extensions
[ext
] = {'files': 0, 'lines': 0}
244 self
.extensions
[ext
]['files'] += 1
246 # FIXME filenames with spaces or special characters are broken
247 self
.extensions
[ext
]['lines'] += int(getoutput('wc -l < %s' % line
, quiet
= True))
249 print 'Warning: Could not count lines for file "%s"' % line
253 # N files changed, N insertions (+), N deletions(-)
255 self
.changes_by_date
= {} # stamp -> { files, ins, del }
256 lines
= getoutput('git-log --shortstat --pretty=format:"%at %an" |tac').split('\n')
257 files
= 0; inserted
= 0; deleted
= 0; total_lines
= 0
263 if line
.find(',') == -1:
265 (stamp
, author
) = (int(line
[:pos
]), line
[pos
+1:])
266 self
.changes_by_date
[stamp
] = { 'files': files
, 'ins': inserted
, 'del': deleted
, 'lines': total_lines
}
268 numbers
= re
.findall('\d+', line
)
269 if len(numbers
) == 3:
270 (files
, inserted
, deleted
) = map(lambda el
: int(el
), numbers
)
271 total_lines
+= inserted
272 total_lines
-= deleted
274 print 'Warning: failed to handle line "%s"' % line
275 (files
, inserted
, deleted
) = (0, 0, 0)
276 #self.changes_by_date[stamp] = { 'files': files, 'ins': inserted, 'del': deleted }
277 self
.total_lines
= total_lines
279 def getActivityByDayOfWeek(self
):
280 return self
.activity_by_day_of_week
282 def getActivityByHourOfDay(self
):
283 return self
.activity_by_hour_of_day
285 def getAuthorInfo(self
, author
):
286 a
= self
.authors
[author
]
288 commits
= a
['commits']
289 commits_frac
= (100 * float(commits
)) / self
.getTotalCommits()
290 date_first
= datetime
.datetime
.fromtimestamp(a
['first_commit_stamp'])
291 date_last
= datetime
.datetime
.fromtimestamp(a
['last_commit_stamp'])
292 delta
= date_last
- date_first
294 res
= { 'commits': commits
, 'commits_frac': commits_frac
, 'date_first': date_first
.strftime('%Y-%m-%d'), 'date_last': date_last
.strftime('%Y-%m-%d'), 'timedelta' : delta
}
297 def getAuthors(self
):
298 return self
.authors
.keys()
300 def getFirstCommitDate(self
):
301 return datetime
.datetime
.fromtimestamp(self
.first_commit_stamp
)
303 def getLastCommitDate(self
):
304 return datetime
.datetime
.fromtimestamp(self
.last_commit_stamp
)
307 lines
= getoutput('git-show-ref --tags |cut -d/ -f3')
308 return lines
.split('\n')
310 def getTagDate(self
, tag
):
311 return self
.revToDate('tags/' + tag
)
313 def getTotalAuthors(self
):
314 return self
.total_authors
316 def getTotalCommits(self
):
317 return self
.total_commits
319 def getTotalFiles(self
):
320 return self
.total_files
322 def getTotalLOC(self
):
323 return self
.total_lines
325 def revToDate(self
, rev
):
326 stamp
= int(getoutput('git-log --pretty=format:%%at "%s" -n 1' % rev
))
327 return datetime
.datetime
.fromtimestamp(stamp
).strftime('%Y-%m-%d')
330 """Creates the actual report based on given data."""
334 def create(self
, data
, path
):
338 def html_linkify(text
):
339 return text
.lower().replace(' ', '_')
341 def html_header(level
, text
):
342 name
= html_linkify(text
)
343 return '\n<h%d><a href="#%s" name="%s">%s</a></h%d>\n\n' % (level
, name
, name
, text
, level
)
345 class HTMLReportCreator(ReportCreator
):
346 def create(self
, data
, path
):
347 ReportCreator
.create(self
, data
, path
)
348 self
.title
= data
.projectname
350 # TODO copy the CSS if it does not exist
351 if not os
.path
.exists(path
+ '/gitstats.css'):
352 shutil
.copyfile('gitstats.css', path
+ '/gitstats.css')
355 f
= open(path
+ "/index.html", 'w')
356 format
= '%Y-%m-%d %H:%m:%S'
359 f
.write('<h1>GitStats - %s</h1>' % data
.projectname
)
364 f
.write('<dt>Project name</dt><dd>%s</dd>' % (data
.projectname
))
365 f
.write('<dt>Generated</dt><dd>%s (in %d seconds)</dd>' % (datetime
.datetime
.now().strftime(format
), time
.time() - data
.getStampCreated()));
366 f
.write('<dt>Report Period</dt><dd>%s to %s</dd>' % (data
.getFirstCommitDate().strftime(format
), data
.getLastCommitDate().strftime(format
)))
367 f
.write('<dt>Total Files</dt><dd>%s</dd>' % data
.getTotalFiles())
368 f
.write('<dt>Total Lines of Code</dt><dd>%s</dd>' % data
.getTotalLOC())
369 f
.write('<dt>Total Commits</dt><dd>%s</dd>' % data
.getTotalCommits())
370 f
.write('<dt>Authors</dt><dd>%s</dd>' % data
.getTotalAuthors())
373 f
.write('</body>\n</html>');
378 f
= open(path
+ '/activity.html', 'w')
380 f
.write('<h1>Activity</h1>')
383 #f.write('<h2>Last 30 days</h2>')
385 #f.write('<h2>Last 12 months</h2>')
388 f
.write(html_header(2, 'Hour of Day'))
389 hour_of_day
= data
.getActivityByHourOfDay()
390 f
.write('<table><tr><th>Hour</th>')
391 for i
in range(1, 25):
392 f
.write('<th>%d</th>' % i
)
393 f
.write('</tr>\n<tr><th>Commits</th>')
394 fp
= open(path
+ '/hour_of_day.dat', 'w')
395 for i
in range(0, 24):
397 f
.write('<td>%d</td>' % hour_of_day
[i
])
398 fp
.write('%d %d\n' % (i
, hour_of_day
[i
]))
400 f
.write('<td>0</td>')
401 fp
.write('%d 0\n' % i
)
403 f
.write('</tr>\n<tr><th>%</th>')
404 totalcommits
= data
.getTotalCommits()
405 for i
in range(0, 24):
407 f
.write('<td>%.2f</td>' % ((100.0 * hour_of_day
[i
]) / totalcommits
))
409 f
.write('<td>0.00</td>')
410 f
.write('</tr></table>')
411 f
.write('<img src="hour_of_day.png" alt="Hour of Day" />')
412 fg
= open(path
+ '/hour_of_day.dat', 'w')
413 for i
in range(0, 24):
415 fg
.write('%d %d\n' % (i
+ 1, hour_of_day
[i
]))
417 fg
.write('%d 0\n' % (i
+ 1))
421 f
.write(html_header(2, 'Day of Week'))
422 day_of_week
= data
.getActivityByDayOfWeek()
423 f
.write('<div class="vtable"><table>')
424 f
.write('<tr><th>Day</th><th>Total (%)</th></tr>')
425 fp
= open(path
+ '/day_of_week.dat', 'w')
426 for d
in range(0, 7):
429 commits
= day_of_week
[d
]
430 fp
.write('%d %d\n' % (d
+ 1, commits
))
432 f
.write('<th>%d</th>' % (d
+ 1))
434 f
.write('<td>%d (%.2f%%)</td>' % (day_of_week
[d
], (100.0 * day_of_week
[d
]) / totalcommits
))
436 f
.write('<td>0</td>')
438 f
.write('</table></div>')
439 f
.write('<img src="day_of_week.png" alt="Day of Week" />')
443 f
.write(html_header(2, 'Hour of Week'))
446 f
.write('<tr><th>Weekday</th>')
447 for hour
in range(0, 24):
448 f
.write('<th>%d</th>' % (hour
+ 1))
451 for weekday
in range(0, 7):
452 f
.write('<tr><th>%d</th>' % (weekday
+ 1))
453 for hour
in range(0, 24):
455 commits
= data
.activity_by_hour_of_week
[weekday
][hour
]
459 f
.write('<td>%d</td>' % commits
)
467 f
.write(html_header(2, 'Month of Year'))
468 f
.write('<div class="vtable"><table>')
469 f
.write('<tr><th>Month</th><th>Commits (%)</th></tr>')
470 fp
= open (path
+ '/month_of_year.dat', 'w')
471 for mm
in range(1, 13):
473 if mm
in data
.activity_by_month_of_year
:
474 commits
= data
.activity_by_month_of_year
[mm
]
475 f
.write('<tr><td>%d</td><td>%d (%.2f %%)</td></tr>' % (mm
, commits
, (100.0 * commits
) / data
.getTotalCommits()))
476 fp
.write('%d %d\n' % (mm
, commits
))
478 f
.write('</table></div>')
479 f
.write('<img src="month_of_year.png" alt="Month of Year" />')
481 # Commits by year/month
482 f
.write(html_header(2, 'Commits by year/month'))
483 f
.write('<div class="vtable"><table><tr><th>Month</th><th>Commits</th></tr>')
484 for yymm
in reversed(sorted(data
.commits_by_month
.keys())):
485 f
.write('<tr><td>%s</td><td>%d</td></tr>' % (yymm
, data
.commits_by_month
[yymm
]))
486 f
.write('</table></div>')
487 f
.write('<img src="commits_by_year_month.png" alt="Commits by year/month" />')
488 fg
= open(path
+ '/commits_by_year_month.dat', 'w')
489 for yymm
in sorted(data
.commits_by_month
.keys()):
490 fg
.write('%s %s\n' % (yymm
, data
.commits_by_month
[yymm
]))
494 f
.write(html_header(2, 'Commits by Year'))
495 f
.write('<div class="vtable"><table><tr><th>Year</th><th>Commits (% of all)</th></tr>')
496 for yy
in reversed(sorted(data
.commits_by_year
.keys())):
497 f
.write('<tr><td>%s</td><td>%d (%.2f%%)</td></tr>' % (yy
, data
.commits_by_year
[yy
], (100.0 * data
.commits_by_year
[yy
]) / data
.getTotalCommits()))
498 f
.write('</table></div>')
499 f
.write('<img src="commits_by_year.png" alt="Commits by Year" />')
500 fg
= open(path
+ '/commits_by_year.dat', 'w')
501 for yy
in sorted(data
.commits_by_year
.keys()):
502 fg
.write('%d %d\n' % (yy
, data
.commits_by_year
[yy
]))
505 f
.write('</body></html>')
510 f
= open(path
+ '/authors.html', 'w')
513 f
.write('<h1>Authors</h1>')
516 # Authors :: List of authors
517 f
.write(html_header(2, 'List of Authors'))
519 f
.write('<table class="authors">')
520 f
.write('<tr><th>Author</th><th>Commits (%)</th><th>First commit</th><th>Last commit</th><th>Age</th></tr>')
521 for author
in sorted(data
.getAuthors()):
522 info
= data
.getAuthorInfo(author
)
523 f
.write('<tr><td>%s</td><td>%d (%.2f%%)</td><td>%s</td><td>%s</td><td>%s</td></tr>' % (author
, info
['commits'], info
['commits_frac'], info
['date_first'], info
['date_last'], info
['timedelta']))
526 # Authors :: Author of Month
527 f
.write(html_header(2, 'Author of Month'))
529 f
.write('<tr><th>Month</th><th>Author</th><th>Commits (%)</th></tr>')
530 for yymm
in reversed(sorted(data
.author_of_month
.keys())):
531 authordict
= data
.author_of_month
[yymm
]
532 authors
= getkeyssortedbyvalues(authordict
)
534 commits
= data
.author_of_month
[yymm
][authors
[0]]
535 f
.write('<tr><td>%s</td><td>%s</td><td>%d (%.2f%% of %d)</td></tr>' % (yymm
, authors
[0], commits
, (100 * commits
) / data
.commits_by_month
[yymm
], data
.commits_by_month
[yymm
]))
539 f
.write(html_header(2, 'Author of Year'))
540 f
.write('<table><tr><th>Year</th><th>Author</th><th>Commits (%)</th></tr>')
541 for yy
in reversed(sorted(data
.author_of_year
.keys())):
542 authordict
= data
.author_of_year
[yy
]
543 authors
= getkeyssortedbyvalues(authordict
)
545 commits
= data
.author_of_year
[yy
][authors
[0]]
546 f
.write('<tr><td>%s</td><td>%s</td><td>%d (%.2f%% of %d)</td></tr>' % (yy
, authors
[0], commits
, (100 * commits
) / data
.commits_by_year
[yy
], data
.commits_by_year
[yy
]))
549 f
.write('</body></html>')
554 f
= open(path
+ '/files.html', 'w')
556 f
.write('<h1>Files</h1>')
560 f
.write('<dt>Total files</dt><dd>%d</dd>' % data
.getTotalFiles())
561 f
.write('<dt>Total lines</dt><dd>%d</dd>' % data
.getTotalLOC())
562 f
.write('<dt>Average file size</dt><dd>%.2f bytes</dd>' % ((100.0 * data
.getTotalLOC()) / data
.getTotalFiles()))
565 # Files :: File count by date
566 f
.write(html_header(2, 'File count by date'))
568 fg
= open(path
+ '/files_by_date.dat', 'w')
569 for stamp
in sorted(data
.files_by_stamp
.keys()):
570 fg
.write('%s %d\n' % (datetime
.datetime
.fromtimestamp(stamp
).strftime('%Y-%m-%d'), data
.files_by_stamp
[stamp
]))
573 f
.write('<img src="files_by_date.png" alt="Files by Date" />')
575 #f.write('<h2>Average file size by date</h2>')
577 # Files :: Extensions
578 f
.write(html_header(2, 'Extensions'))
579 f
.write('<table><tr><th>Extension</th><th>Files (%)</th><th>Lines (%)</th><th>Lines/file</th></tr>')
580 for ext
in sorted(data
.extensions
.keys()):
581 files
= data
.extensions
[ext
]['files']
582 lines
= data
.extensions
[ext
]['lines']
583 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
))
586 f
.write('</body></html>')
591 f
= open(path
+ '/lines.html', 'w')
593 f
.write('<h1>Lines</h1>')
597 f
.write('<dt>Total lines</dt><dd>%d</dd>' % data
.getTotalLOC())
600 f
.write(html_header(2, 'Lines of Code'))
601 f
.write('<img src="lines_of_code.png" />')
603 fg
= open(path
+ '/lines_of_code.dat', 'w')
604 for stamp
in sorted(data
.changes_by_date
.keys()):
605 fg
.write('%d %d\n' % (stamp
, data
.changes_by_date
[stamp
]['lines']))
608 f
.write('</body></html>')
613 f
= open(path
+ '/tags.html', 'w')
615 f
.write('<h1>Tags</h1>')
619 f
.write('<dt>Total tags</dt><dd>%d</dd>' % len(data
.tags
))
620 if len(data
.tags
) > 0:
621 f
.write('<dt>Average commits per tag</dt><dd>%.2f</dd>' % (data
.getTotalCommits() / len(data
.tags
)))
625 f
.write('<tr><th>Name</th><th>Date</th></tr>')
626 # sort the tags by date desc
627 tags_sorted_by_date_desc
= map(lambda el
: el
[1], reversed(sorted(map(lambda el
: (el
[1]['date'], el
[0]), data
.tags
.items()))))
628 for tag
in tags_sorted_by_date_desc
:
629 f
.write('<tr><td>%s</td><td>%s</td></tr>' % (tag
, data
.tags
[tag
]['date']))
632 f
.write('</body></html>')
635 self
.createGraphs(path
)
638 def createGraphs(self
, path
):
639 print 'Generating graphs...'
642 f
= open(path
+ '/hour_of_day.plot', 'w')
643 f
.write(GNUPLOT_COMMON
)
646 set output 'hour_of_day.png'
648 set xrange [0.5:24.5]
651 plot 'hour_of_day.dat' using 1:2:(0.5) w boxes fs solid
656 f
= open(path
+ '/day_of_week.plot', 'w')
657 f
.write(GNUPLOT_COMMON
)
660 set output 'day_of_week.png'
665 plot 'day_of_week.dat' using 1:2:(0.5) w boxes fs solid
670 f
= open(path
+ '/month_of_year.plot', 'w')
671 f
.write(GNUPLOT_COMMON
)
674 set output 'month_of_year.png'
676 set xrange [0.5:12.5]
679 plot 'month_of_year.dat' using 1:2:(0.5) w boxes fs solid
683 # commits_by_year_month
684 f
= open(path
+ '/commits_by_year_month.plot', 'w')
685 f
.write(GNUPLOT_COMMON
)
688 set output 'commits_by_year_month.png'
693 set xtics rotate by 90 15768000
695 plot 'commits_by_year_month.dat' using 1:2:(0.5) w boxes fs solid
700 f
= open(path
+ '/commits_by_year.plot', 'w')
701 f
.write(GNUPLOT_COMMON
)
704 set output 'commits_by_year.png'
708 plot 'commits_by_year.dat' using 1:2:(0.5) w boxes fs solid
713 f
= open(path
+ '/files_by_date.plot', 'w')
714 f
.write(GNUPLOT_COMMON
)
717 set output 'files_by_date.png'
720 set timefmt "%Y-%m-%d"
721 set format x "%Y-%m-%d"
723 set xtics rotate by 90
724 plot 'files_by_date.dat' using 1:2 smooth csplines
729 f
= open(path
+ '/lines_of_code.plot', 'w')
730 f
.write(GNUPLOT_COMMON
)
733 set output 'lines_of_code.png'
737 set format x "%Y-%m-%d"
739 set xtics rotate by 90
740 plot 'lines_of_code.dat' using 1:2 w lines
745 files
= glob
.glob(path
+ '/*.plot')
747 out
= getoutput('gnuplot %s' % f
)
751 def printHeader(self
, f
, title
= ''):
753 """<?xml version="1.0" encoding="UTF-8"?>
754 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
755 <html xmlns="http://www.w3.org/1999/xhtml">
757 <title>GitStats - %s</title>
758 <link rel="stylesheet" href="gitstats.css" type="text/css" />
759 <meta name="generator" content="GitStats" />
764 def printNav(self
, f
):
768 <li><a href="index.html">General</a></li>
769 <li><a href="activity.html">Activity</a></li>
770 <li><a href="authors.html">Authors</a></li>
771 <li><a href="files.html">Files</a></li>
772 <li><a href="lines.html">Lines</a></li>
773 <li><a href="tags.html">Tags</a></li>
780 Usage: gitstats [options] <gitpath> <outputpath>
785 if len(sys
.argv
) < 3:
789 gitpath
= sys
.argv
[1]
790 outputpath
= os
.path
.abspath(sys
.argv
[2])
794 os
.makedirs(outputpath
)
797 if not os
.path
.isdir(outputpath
):
798 print 'FATAL: Output path is not a directory or does not exist'
801 print 'Git path: %s' % gitpath
802 print 'Output path: %s' % outputpath
806 print 'Collecting data...'
807 data
= GitDataCollector()
808 data
.collect(gitpath
)
812 print 'Generating report...'
813 report
= HTMLReportCreator()
814 report
.create(data
, outputpath
)