diff --git a/doc/TODO.txt b/doc/TODO.txt index 8d5af69..098ae03 100644 --- a/doc/TODO.txt +++ b/doc/TODO.txt @@ -3,15 +3,6 @@ - git-log --pretty=format:"%at %an" |grep -C3 unknown - git-rev-list (for number of files in each revision) says "Warning: failed to parse line " 17741" -- Tags - - sort tags by date and collect info starting from latest - - show how many commits per tag - - git rev-list v0.0.1 |wc -l - - git rev-list v0.0.2 |wc -l - - git rev-list v0.0.2 ^v0.0.1 |wc -l - - Authors (count of people contributing after last version)? - - git shortlog -s v0.0.2 ^v0.0.1 - [Unsorted] - clean up after running gnuplot (option to keep .dat files around?) - show raw data in some way (the tables used currently aren't very nice) diff --git a/gitstats b/gitstats index 9830b57..70fe910 100755 --- a/gitstats +++ b/gitstats @@ -183,7 +183,26 @@ class GitDataCollector(DataCollector): stamp = int(parts[0]) except ValueError: stamp = 0 - self.tags[tag] = { 'stamp': stamp, 'hash' : hash, 'date' : datetime.datetime.fromtimestamp(stamp).strftime('%Y-%m-%d') } + self.tags[tag] = { 'stamp': stamp, 'hash' : hash, 'date' : datetime.datetime.fromtimestamp(stamp).strftime('%Y-%m-%d'), 'commits': 0, 'authors': {} } + + # collect info on tags, starting from latest + tags_sorted_by_date_desc = map(lambda el : el[1], reversed(sorted(map(lambda el : (el[1]['date'], el[0]), data.tags.items())))) + prev = None + for tag in reversed(tags_sorted_by_date_desc): + #print prev, tag + cmd = 'git shortlog -s "%s"' % tag + if prev != None: + cmd += ' "^%s"' % prev + output = getpipeoutput([cmd]) + prev = tag + for line in output.split('\n'): + parts = re.split('\s+', line, 2) + #print parts + commits = int(parts[1]) + author = parts[2] + self.tags[tag]['commits'] += commits + self.tags[tag]['authors'][author] = commits + #print self.tags # Collect revision statistics # Outputs " " @@ -740,11 +759,15 @@ class HTMLReportCreator(ReportCreator): f.write('') f.write('') - f.write('') + f.write('') # sort the tags by date desc tags_sorted_by_date_desc = map(lambda el : el[1], reversed(sorted(map(lambda el : (el[1]['date'], el[0]), data.tags.items())))) for tag in tags_sorted_by_date_desc: - f.write('' % (tag, data.tags[tag]['date'])) + authorinfo = [] + authors_by_commits = getkeyssortedbyvalues(data.tags[tag]['authors']) + for i in reversed(authors_by_commits): + authorinfo.append('%s (%d)' % (i, data.tags[tag]['authors'][i])) + f.write('' % (tag, data.tags[tag]['date'], data.tags[tag]['commits'], ', '.join(authorinfo))) f.write('
NameDate
NameDateCommitsAuthors
%s%s
%s%s%d%s
') f.write('')