Przeglądaj źródła

Added tags page.

Heikki Hokkanen 18 lat temu
rodzic
commit
2dd78ed2cf
2 zmienionych plików z 51 dodań i 12 usunięć
  1. 6
    2
      TODO.txt
  2. 45
    10
      statgit

+ 6
- 2
TODO.txt Wyświetl plik

@@ -5,6 +5,8 @@
5 5
 - git-log
6 6
 - git-ls-files
7 7
 	- Current list of files
8
+- git-ls-tree -r <revision>
9
+	- get a list of files in each revision
8 10
 - git-log --stat or --shortstat - N files changed, N insertions, N deletions
9 11
 - git-log --name-status - svn-like list of modifications for each commit
10 12
 - git-rev-list --all
@@ -21,7 +23,7 @@
21 23
 - General
22 24
 	- Report Period (git-log)
23 25
 	- DONE Total Files (git-ls-files)
24
-	- WIP Total LOC?
26
+	- DONE Total LOC?
25 27
 	- DONE Total Commits
26 28
 	- DONE Authors
27 29
 
@@ -53,7 +55,9 @@
53 55
 - (G) Lines of Code: x = date, y = lines
54 56
 
55 57
 - Tags
56
-	- (T): Name, Date, LOC?, Developers
58
+	- DONE (T): Name, Date
59
+	- Lines
60
+	- Authors (count of people contributing after last version)?
57 61
 
58 62
 - Author page for each author
59 63
 	- Name, mail

+ 45
- 10
statgit Wyświetl plik

@@ -82,6 +82,23 @@ class GitDataCollector(DataCollector):
82 82
 		self.first_commit_stamp = 0
83 83
 		self.last_commit_stamp = 0
84 84
 
85
+		# tags
86
+		self.tags = {}
87
+		lines = getoutput('git-show-ref --tags').split('\n')
88
+		for line in lines:
89
+			(hash, tag) = line.split(' ')
90
+			tag = tag.replace('refs/tags/', '')
91
+			output = getoutput('git-log "%s" --pretty=format:"%%at %%an" -n 1' % hash)
92
+			if len(output) > 0:
93
+				parts = output.split(' ')
94
+				stamp = 0
95
+				try:
96
+					stamp = int(parts[0])
97
+				except ValueError:
98
+					stamp = 0
99
+				self.tags[tag] = { 'stamp': stamp, 'hash' : hash, 'date' : datetime.datetime.fromtimestamp(stamp).strftime('%Y-%m-%d') }
100
+			pass
101
+
85 102
 		# TODO also collect statistics for "last 30 days"/"last 12 months"
86 103
 		lines = getoutput('git-rev-list --pretty=format:"%at %an" HEAD |grep -v ^commit').split('\n')
87 104
 		for line in lines:
@@ -231,18 +248,11 @@ class HTMLReportCreator(ReportCreator):
231 248
 		f.write('<dt>Authors</dt><dd>%s</dd>' % data.getTotalAuthors())
232 249
 		f.write('</dl>');
233 250
 
234
-
235
-		#f.write('<h2>Tags</h2>')
236
-		#f.write('<table>')
237
-		#f.write('<tr><th>Name</th><th>Date</th><th>Developers</th></tr>')
238
-		#for tag in data.getTags():
239
-		#	f.write('<tr><td>%s</td><td></td></tr>' % tag)
240
-		#f.write('</table>')
241
-
242 251
 		f.write('</body>\n</html>');
243 252
 		f.close()
244 253
 
245
-		# activity.html
254
+		###
255
+		# Activity
246 256
 		f = open(path + '/activity.html', 'w')
247 257
 		self.printHeader(f)
248 258
 		f.write('<h1>Activity</h1>')
@@ -252,17 +262,22 @@ class HTMLReportCreator(ReportCreator):
252 262
 
253 263
 		f.write('<h2>Last 12 months</h2>')
254 264
 
265
+		# Hour of Day
255 266
 		f.write('\n<h2>Hour of Day</h2>\n\n')
256 267
 		hour_of_day = data.getActivityByHourOfDay()
257 268
 		f.write('<table><tr><th>Hour</th>')
258 269
 		for i in range(1, 25):
259 270
 			f.write('<th>%d</th>' % i)
260 271
 		f.write('</tr>\n<tr><th>Commits</th>')
272
+		fp = open(path + '/hour_of_day.dat', 'w')
261 273
 		for i in range(0, 24):
262 274
 			if i in hour_of_day:
263 275
 				f.write('<td>%d</td>' % hour_of_day[i])
276
+				fp.write('%d %d\n' % (i, hour_of_day[i]))
264 277
 			else:
265 278
 				f.write('<td>0</td>')
279
+				fp.write('%d 0\n' % i)
280
+		fp.close()
266 281
 		f.write('</tr>\n<tr><th>%</th>')
267 282
 		totalcommits = data.getTotalCommits()
268 283
 		for i in range(0, 24):
@@ -272,13 +287,15 @@ class HTMLReportCreator(ReportCreator):
272 287
 				f.write('<td>0.00</td>')
273 288
 		f.write('</tr></table>')
274 289
 
275
-		### Day of Week
290
+		# Day of Week
276 291
 		# TODO show also by hour of weekday?
277 292
 		f.write('\n<h2>Day of Week</h2>\n\n')
278 293
 		day_of_week = data.getActivityByDayOfWeek()
279 294
 		f.write('<table>')
280 295
 		f.write('<tr><th>Day</th><th>Total (%)</th></tr>')
296
+		fp = open(path + '/day_of_week.dat', 'w')
281 297
 		for d in range(0, 7):
298
+			fp.write('%d %d\n' % (d + 1, day_of_week[d]))
282 299
 			f.write('<tr>')
283 300
 			f.write('<th>%d</th>' % (d + 1))
284 301
 			if d in day_of_week:
@@ -287,6 +304,7 @@ class HTMLReportCreator(ReportCreator):
287 304
 				f.write('<td>0</td>')
288 305
 			f.write('</tr>')
289 306
 		f.write('</table>')
307
+		fp.close()
290 308
 
291 309
 		f.close()
292 310
 
@@ -330,6 +348,22 @@ class HTMLReportCreator(ReportCreator):
330 348
 
331 349
 		f.write('</body></html>')
332 350
 		f.close()
351
+
352
+		###
353
+		# tags.html
354
+		f = open(path + '/tags.html', 'w')
355
+		self.printHeader(f)
356
+		f.write('<h1>Tags</h1>')
357
+		self.printNav(f)
358
+
359
+		f.write('<table>')
360
+		f.write('<tr><th>Name</th><th>Date</th></tr>')
361
+		for tag in data.tags.keys():
362
+			f.write('<tr><td>%s</td><td>%s</td></tr>' % (tag, data.tags[tag]['date']))
363
+		f.write('</table>')
364
+
365
+		f.write('</body></html>')
366
+		f.close()
333 367
 	pass
334 368
 
335 369
 	def printHeader(self, f):
@@ -349,6 +383,7 @@ class HTMLReportCreator(ReportCreator):
349 383
 <li><a href="authors.html">Authors</a></li>
350 384
 <li><a href="files.html">Files</a></li>
351 385
 <li><a href="lines.html">Lines</a></li>
386
+<li><a href="tags.html">Tags</a></li>
352 387
 </ul>
353 388
 </div>
354 389
 """)