Browse Source

Merge branch 'work' into windows

Heikki Hokkanen 17 years ago
parent
commit
14979d6dab
4 changed files with 9 additions and 29 deletions
  1. 0
    5
      commits_by_year.plot
  2. 0
    8
      commits_by_year_month.plot
  3. 0
    6
      day_of_week.plot
  4. 9
    10
      gitstats

+ 0
- 5
commits_by_year.plot View File

1
-set terminal png
2
-set size 0.5,0.5
3
-set output 'commits_by_year.png'
4
-unset key
5
-plot 'commits_by_year.dat' using 1:2 w lp

+ 0
- 8
commits_by_year_month.plot View File

1
-set terminal png
2
-set size 0.5,0.5
3
-set output 'commits_by_year_month.png'
4
-unset key
5
-set xdata time
6
-set timefmt "%Y-%m"
7
-set format x "%Y-%m"
8
-plot 'commits_by_year_month.dat' using 1:2 w lp

+ 0
- 6
day_of_week.plot View File

1
-set terminal png
2
-set size 0.5,0.5
3
-set output 'day_of_week.png'
4
-unset key
5
-set xrange [0.5:7.5]
6
-plot 'day_of_week.dat' using 1:2:(0.5) w boxes fs solid

+ 9
- 10
gitstats View File

51
 	"""Manages data collection from a revision control repository."""
51
 	"""Manages data collection from a revision control repository."""
52
 	def __init__(self):
52
 	def __init__(self):
53
 		self.stamp_created = time.time()
53
 		self.stamp_created = time.time()
54
-		pass
55
 	
54
 	
56
 	##
55
 	##
57
 	# This should be the main function to extract data from the repository.
56
 	# This should be the main function to extract data from the repository.
150
 				except ValueError:
149
 				except ValueError:
151
 					stamp = 0
150
 					stamp = 0
152
 				self.tags[tag] = { 'stamp': stamp, 'hash' : hash, 'date' : datetime.datetime.fromtimestamp(stamp).strftime('%Y-%m-%d') }
151
 				self.tags[tag] = { 'stamp': stamp, 'hash' : hash, 'date' : datetime.datetime.fromtimestamp(stamp).strftime('%Y-%m-%d') }
153
-			pass
154
 
152
 
155
 		# Collect revision statistics
153
 		# Collect revision statistics
156
 		# Outputs "<stamp> <author>"
154
 		# Outputs "<stamp> <author>"
208
 			# author stats
206
 			# author stats
209
 			if author not in self.authors:
207
 			if author not in self.authors:
210
 				self.authors[author] = {}
208
 				self.authors[author] = {}
211
-			# TODO commits
209
+			# commits
212
 			if 'last_commit_stamp' not in self.authors[author]:
210
 			if 'last_commit_stamp' not in self.authors[author]:
213
 				self.authors[author]['last_commit_stamp'] = stamp
211
 				self.authors[author]['last_commit_stamp'] = stamp
214
 			self.authors[author]['first_commit_stamp'] = stamp
212
 			self.authors[author]['first_commit_stamp'] = stamp
249
 		# TODO Optimize this, it's the worst bottleneck
247
 		# TODO Optimize this, it's the worst bottleneck
250
 		# outputs "<stamp> <files>" for each revision
248
 		# outputs "<stamp> <files>" for each revision
251
 		self.files_by_stamp = {} # stamp -> files
249
 		self.files_by_stamp = {} # stamp -> files
252
-		revlines = getpipeoutput(['git-rev-list --pretty=format:"%at %H" HEAD', 'grep -v ^commit']).strip().split('\n')
250
+		revlines = getpipeoutput(['git-rev-list --pretty=format:"%at %T" HEAD', 'grep -v ^commit']).strip().split('\n')
253
 		lines = []
251
 		lines = []
254
 		for revline in revlines:
252
 		for revline in revlines:
255
 			time, rev = revline.split(' ')
253
 			time, rev = revline.split(' ')
256
-			linecount = int(getpipeoutput(['git-ls-tree -r "%s"' % rev, 'wc -l']).split('\n')[0])
254
+			linecount = int(getpipeoutput(['git-ls-tree -r --name-only "%s"' % rev, 'wc -l']).split('\n')[0])
257
 			lines.append('%d %d' % (int(time), linecount))
255
 			lines.append('%d %d' % (int(time), linecount))
258
 
256
 
259
 		self.total_commits = len(lines)
257
 		self.total_commits = len(lines)
304
 			if line.find('files changed,') == -1:
302
 			if line.find('files changed,') == -1:
305
 				pos = line.find(' ')
303
 				pos = line.find(' ')
306
 				if pos != -1:
304
 				if pos != -1:
307
-					(stamp, author) = (int(line[:pos]), line[pos+1:])
308
-					self.changes_by_date[stamp] = { 'files': files, 'ins': inserted, 'del': deleted, 'lines': total_lines }
305
+					try:
306
+						(stamp, author) = (int(line[:pos]), line[pos+1:])
307
+						self.changes_by_date[stamp] = { 'files': files, 'ins': inserted, 'del': deleted, 'lines': total_lines }
308
+					except ValueError:
309
+						print 'Warning: unexpected line "%s"' % line
309
 				else:
310
 				else:
310
 					print 'Warning: unexpected line "%s"' % line
311
 					print 'Warning: unexpected line "%s"' % line
311
 			else:
312
 			else:
400
 		ReportCreator.create(self, data, path)
401
 		ReportCreator.create(self, data, path)
401
 		self.title = data.projectname
402
 		self.title = data.projectname
402
 
403
 
403
-		# TODO copy the CSS if it does not exist
404
+		# copy the CSS if it does not exist
404
 		if not os.path.exists(path + '/gitstats.css'):
405
 		if not os.path.exists(path + '/gitstats.css'):
405
 			basedir = os.path.dirname(os.path.abspath(__file__))
406
 			basedir = os.path.dirname(os.path.abspath(__file__))
406
 			shutil.copyfile(basedir + '/gitstats.css', path + '/gitstats.css')
407
 			shutil.copyfile(basedir + '/gitstats.css', path + '/gitstats.css')
407
-			pass
408
 
408
 
409
 		f = open(path + "/index.html", 'w')
409
 		f = open(path + "/index.html", 'w')
410
 		format = '%Y-%m-%d %H:%m:%S'
410
 		format = '%Y-%m-%d %H:%m:%S'
689
 		f.close()
689
 		f.close()
690
 
690
 
691
 		self.createGraphs(path)
691
 		self.createGraphs(path)
692
-	pass
693
 	
692
 	
694
 	def createGraphs(self, path):
693
 	def createGraphs(self, path):
695
 		print 'Generating graphs...'
694
 		print 'Generating graphs...'