Explorar el Código

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.
Heikki Hokkanen hace 16 años
padre
commit
0212bf1ce9
Se han modificado 2 ficheros con 26 adiciones y 12 borrados
  1. 0
    9
      doc/TODO.txt
  2. 26
    3
      gitstats

+ 0
- 9
doc/TODO.txt Ver fichero

@@ -3,15 +3,6 @@
3 3
 	- git-log --pretty=format:"%at %an" |grep -C3 unknown
4 4
 	- git-rev-list (for number of files in each revision) says "Warning: failed to parse line "<unknown> 17741"
5 5
 
6
-- Tags
7
-	- sort tags by date and collect info starting from latest
8
-	- show how many commits per tag
9
-		- git rev-list v0.0.1 |wc -l
10
-		- git rev-list v0.0.2 |wc -l
11
-		- git rev-list v0.0.2 ^v0.0.1 |wc -l
12
-	- Authors (count of people contributing after last version)?
13
-		- git shortlog -s v0.0.2 ^v0.0.1
14
-
15 6
 [Unsorted]
16 7
 - clean up after running gnuplot (option to keep .dat files around?)
17 8
 - show raw data in some way (the tables used currently aren't very nice)

+ 26
- 3
gitstats Ver fichero

@@ -183,7 +183,26 @@ class GitDataCollector(DataCollector):
183 183
 					stamp = int(parts[0])
184 184
 				except ValueError:
185 185
 					stamp = 0
186
-				self.tags[tag] = { 'stamp': stamp, 'hash' : hash, 'date' : datetime.datetime.fromtimestamp(stamp).strftime('%Y-%m-%d') }
186
+				self.tags[tag] = { 'stamp': stamp, 'hash' : hash, 'date' : datetime.datetime.fromtimestamp(stamp).strftime('%Y-%m-%d'), 'commits': 0, 'authors': {} }
187
+
188
+		# collect info on tags, starting from latest
189
+		tags_sorted_by_date_desc = map(lambda el : el[1], reversed(sorted(map(lambda el : (el[1]['date'], el[0]), data.tags.items()))))
190
+		prev = None
191
+		for tag in reversed(tags_sorted_by_date_desc):
192
+			#print prev, tag
193
+			cmd = 'git shortlog -s "%s"' % tag
194
+			if prev != None:
195
+				cmd += ' "^%s"' % prev
196
+			output = getpipeoutput([cmd])
197
+			prev = tag
198
+			for line in output.split('\n'):
199
+				parts = re.split('\s+', line, 2)
200
+				#print parts
201
+				commits = int(parts[1])
202
+				author = parts[2]
203
+				self.tags[tag]['commits'] += commits
204
+				self.tags[tag]['authors'][author] = commits
205
+		#print self.tags
187 206
 
188 207
 		# Collect revision statistics
189 208
 		# Outputs "<stamp> <author>"
@@ -740,11 +759,15 @@ class HTMLReportCreator(ReportCreator):
740 759
 		f.write('</dl>')
741 760
 
742 761
 		f.write('<table>')
743
-		f.write('<tr><th>Name</th><th>Date</th></tr>')
762
+		f.write('<tr><th>Name</th><th>Date</th><th>Commits</th><th>Authors</th></tr>')
744 763
 		# sort the tags by date desc
745 764
 		tags_sorted_by_date_desc = map(lambda el : el[1], reversed(sorted(map(lambda el : (el[1]['date'], el[0]), data.tags.items()))))
746 765
 		for tag in tags_sorted_by_date_desc:
747
-			f.write('<tr><td>%s</td><td>%s</td></tr>' % (tag, data.tags[tag]['date']))
766
+			authorinfo = []
767
+			authors_by_commits = getkeyssortedbyvalues(data.tags[tag]['authors'])
768
+			for i in reversed(authors_by_commits):
769
+				authorinfo.append('%s (%d)' % (i, data.tags[tag]['authors'][i]))
770
+			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)))
748 771
 		f.write('</table>')
749 772
 
750 773
 		f.write('</body></html>')