From 0212bf1ce9331f444597efd109dc4bddfc471916 Mon Sep 17 00:00:00 2001 From: Heikki Hokkanen Date: Thu, 18 Jun 2009 21:07:35 +0300 Subject: [PATCH] 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. --- doc/TODO.txt | 9 --------- gitstats | 29 ++++++++++++++++++++++++++--- 2 files changed, 26 insertions(+), 12 deletions(-) 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('') -- 2.11.4.GIT