Quellcode durchsuchen

Collect some data for inserted/deleted lines each commit.

Heikki Hokkanen vor 18 Jahren
Ursprung
Commit
012cf6be52
2 geänderte Dateien mit 30 neuen und 3 gelöschten Zeilen
  1. 7
    3
      doc/TODO.txt
  2. 23
    0
      gitstats

+ 7
- 3
doc/TODO.txt Datei anzeigen

@@ -6,11 +6,18 @@
6 6
 - parameter --style default.css
7 7
 - styles/default.css
8 8
 
9
+- Lines
10
+	- get line counts from "git-log --numstat"?
11
+	- git log --shortstat --pretty=format:"%at %an"
12
+		<stamp> <author>
13
+		 N files changed, N insertions (+), N deletions(-)
14
+
9 15
 [0.0.1]
10 16
 - copy/link gitstats.css to target dir
11 17
 	- find out pwd or home dir?
12 18
 
13 19
 [Unsorted]
20
+- could show some statistics from last year, month, etc... pisg-like?
14 21
 - use sortable.js
15 22
 
16 23
 [Information]
@@ -84,6 +91,3 @@
84 91
 	- Author top ten
85 92
 	- Month statistics
86 93
 
87
-[Misc]
88
-- use sortable.js ?
89
-- could show some statistics from last year, month, etc... pisg-like?

+ 23
- 0
gitstats Datei anzeigen

@@ -237,6 +237,29 @@ class GitDataCollector(DataCollector):
237 237
 				self.extensions[ext]['lines'] += int(getoutput('wc -l < %s' % line, quiet = True))
238 238
 			except:
239 239
 				print 'Warning: Could not count lines for file "%s"' % line
240
+
241
+		# line statistics
242
+		# outputs:
243
+		# <stamp> <author>
244
+		#  N files changed, N insertions (+), N deletions(-)
245
+		self.changes_by_date = {} # stamp -> { files, ins, del }
246
+		lines = getoutput('git-log --shortstat --pretty=format:"%at %an"').split('\n')
247
+		# TODO |tac this and go it through in reverse, to calculate total lines in each rev?
248
+		stamp = 0
249
+		author = ''
250
+		for line in lines:
251
+			# <stamp> <author>
252
+			if line.find(',') == -1:
253
+				pos = line.find(' ')
254
+				(stamp, author) = (line[:pos], line[pos+1:])
255
+			else:
256
+				numbers = re.findall('\d+', line)
257
+				if len(numbers) == 3:
258
+					(files, inserted, deleted) = numbers
259
+				else:
260
+					print 'Warning: failed to handle line "%s"' % line
261
+					(files, inserted, deleted) = (0, 0, 0)
262
+				self.changes_by_date[stamp] = { 'files': files, 'ins': inserted, 'del': deleted }
240 263
 	
241 264
 	def getActivityByDayOfWeek(self):
242 265
 		return self.activity_by_day_of_week