From c00bb58dbe86e7d9b656dd4bac2e76e7c80b456c Mon Sep 17 00:00:00 2001 From: Heikki Hokkanen Date: Thu, 2 Aug 2007 15:07:18 +0300 Subject: [PATCH] More todo items and stubs. --- TODO.txt | 29 ++++++++++++++++++++--------- statgit | 47 +++++++++++++++++++++++++++++++++++------------ statgit.css | 20 ++++++++++++++++++++ 3 files changed, 75 insertions(+), 21 deletions(-) create mode 100644 statgit.css diff --git a/TODO.txt b/TODO.txt index 83fee50..eecfe47 100644 --- a/TODO.txt +++ b/TODO.txt @@ -1,15 +1,6 @@ - development statistics generator for git - should be as versatile as statcvs / statsvn -- language? - - perl or python? - -- make git data collection part separate so that portage to other DVCS's is easier - - DataCollector - -- make output thingies modular as well (HTML first, plain text later etc) - - ReportCreator - [Information] - git-log - git-ls-files @@ -19,6 +10,7 @@ - git-rev-list --all - first and last commit - git-show-ref --tags + - not all tags are tags on refs? - git-log |git-shortlog -s - author: number of commits - git-what-changed @@ -33,9 +25,27 @@ - Authors - List of authors + - show only first 10 and rest on separate page? - DONE (T): author, commits (%), LOC?, first commit, last commit - (T): Developer of the Month: month, author, commits, LOC? +- Files + - Total Files + - Average file size + - Average revisions per file + - (G) File Count: x = date, y = files + - (G) Average file size: x = date, y = lines/file + - (T) File Extensions (or mime types from "file"?): extension, files (%), lines (%), lines/file + - (T) Largest Files? + - (T) Files With Most Revisions? + +- Activity by Time? + - Hour of Day + - Day of Week (+ Hour of weekday -> 7x24) + - Month of Year + - (G?) Last 30 days + - (G?) Last 12 months + - (G) Lines of Code: x = date, y = lines - Tags @@ -102,3 +112,4 @@ [Misc] - use sortable.js ? +- could show some statistics from last year, month, etc... pisg-like? diff --git a/statgit b/statgit index 6540985..f417204 100755 --- a/statgit +++ b/statgit @@ -7,6 +7,11 @@ import os import re import sys +def getoutput(cmd): + print '>> %s' % cmd + output = commands.getoutput(cmd) + return output + class DataCollector: def __init__(self): pass @@ -17,7 +22,7 @@ class DataCollector: self.dir = dir ## - # TODO: get a dictionary of author + # : get a dictionary of author def getAuthorInfo(self, author): return None @@ -32,6 +37,9 @@ class DataCollector: def getLastCommitDate(self): return datetime.datetime.now() + def getTags(self): + return [] + def getTotalAuthors(self): return -1 @@ -48,18 +56,18 @@ class GitDataCollector(DataCollector): def collect(self, dir): DataCollector.collect(self, dir) - self.total_authors = int(commands.getoutput('git-log |git-shortlog -s |wc -l')) - self.total_commits = int(commands.getoutput('git-rev-list --all |wc -l')) - self.total_files = int(commands.getoutput('git-ls-files |wc -l')) - self.total_lines = int(commands.getoutput('git-ls-files |xargs cat |wc -l')) + self.total_authors = int(getoutput('git-log |git-shortlog -s |wc -l')) + self.total_commits = int(getoutput('git-rev-list --all |wc -l')) + self.total_files = int(getoutput('git-ls-files |wc -l')) + self.total_lines = int(getoutput('git-ls-files |xargs cat |wc -l')) def getAuthorInfo(self, author): - commits = int(commands.getoutput('git-rev-list --all --author="%s" |wc -l' % author)) + commits = int(getoutput('git-rev-list --all --author="%s" |wc -l' % author)) commits_frac = (100 * float(commits)) / self.getTotalCommits() date_first = '0000-00-00' date_last = '0000-00-00' - rev_last = commands.getoutput('git-rev-list --all --author="%s" -n 1' % author) - rev_first = commands.getoutput('git-rev-list --all --author="%s" |tail -n 1' % author) + rev_last = getoutput('git-rev-list --all --author="%s" -n 1' % author) + rev_first = getoutput('git-rev-list --all --author="%s" |tail -n 1' % author) date_first = self.revToDate(rev_first) date_last = self.revToDate(rev_last) @@ -67,9 +75,16 @@ class GitDataCollector(DataCollector): return res def getAuthors(self): - lines = commands.getoutput('git-rev-list --all --pretty=format:%an |grep -v ^commit |sort |uniq') + lines = getoutput('git-rev-list --all --pretty=format:%an |grep -v ^commit |sort |uniq') return lines.split('\n') + def getTags(self): + lines = getoutput('git-show-ref --tags |cut -d/ -f3') + return lines.split('\n') + + def getTagDate(self, tag): + return self.revToDate('tags/' + tag) + def getTotalAuthors(self): return self.total_authors @@ -83,7 +98,7 @@ class GitDataCollector(DataCollector): return self.total_lines def revToDate(self, rev): - stamp = int(commands.getoutput('git-log --pretty=format:%%at "%s" -n 1' % rev)) + stamp = int(getoutput('git-log --pretty=format:%%at "%s" -n 1' % rev)) return datetime.datetime.fromtimestamp(stamp).strftime('%Y-%m-%d') class ReportCreator: @@ -102,6 +117,7 @@ class HTMLReportCreator(ReportCreator): f.write(""" StatGit + """) @@ -118,6 +134,13 @@ class HTMLReportCreator(ReportCreator): f.write('
Authors
%s
' % data.getTotalAuthors()) f.write(''); + f.write(""" +""") + f.write('

Authors

') f.write('') @@ -128,10 +151,10 @@ class HTMLReportCreator(ReportCreator): f.write('
') f.write('

Tags

') - f.write('') f.write('') - + for tag in data.getTags(): + f.write('' % tag) f.write('
NameDateDevelopers
%s
') f.write('\n'); diff --git a/statgit.css b/statgit.css new file mode 100644 index 0000000..d3c1823 --- /dev/null +++ b/statgit.css @@ -0,0 +1,20 @@ +body { + color: black; + background-color: #cc9; +} + +dt { + font-weight: bold; + float: left; + margin-right: 1em; +} + +dt:after { + content: ': '; +} + +dd { + display: block; + clear: right; +} +