Tags: show commits & authors for each tag.

A simple assumption is made about the tags: it's assumed that they come in
chronological order, and share the same history (eg. v0.0.1, v0.0.2). That way,
to get commits made for v0.0.2, we simply look for history from v0.0.1 to
v0.0.2.
This commit is contained in:
Heikki Hokkanen 2009-06-18 21:07:35 +03:00
parent c41e414173
commit 0212bf1ce9
2 changed files with 26 additions and 12 deletions

View File

@ -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 "<unknown> 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)

View File

@ -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 "<stamp> <author>"
@ -740,11 +759,15 @@ class HTMLReportCreator(ReportCreator):
f.write('</dl>')
f.write('<table>')
f.write('<tr><th>Name</th><th>Date</th></tr>')
f.write('<tr><th>Name</th><th>Date</th><th>Commits</th><th>Authors</th></tr>')
# 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('<tr><td>%s</td><td>%s</td></tr>' % (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('<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)))
f.write('</table>')
f.write('</body></html>')