Browse Source

Checking OS to replace wc and grep to findstr, their equivalent command on Windows.

miopeciclope 8 years ago
parent
commit
e53043d00b
1 changed files with 7 additions and 7 deletions
  1. 7
    7
      gitstats

+ 7
- 7
gitstats View File

124
 	Get number of files changed in commit
124
 	Get number of files changed in commit
125
 	"""
125
 	"""
126
 	time, rev = time_rev
126
 	time, rev = time_rev
127
-	return (int(time), rev, int(getpipeoutput(['git ls-tree -r --name-only "%s"' % rev, 'wc -l']).split('\n')[0]))
127
+	return (int(time), rev, int(getpipeoutput(['git ls-tree -r --name-only "%s"' % rev, ('find /c /v ""', 'wc -l')[ON_LINUX]]).split('\n')[0]))
128
 
128
 
129
 def getnumoflinesinblob(ext_blob):
129
 def getnumoflinesinblob(ext_blob):
130
 	"""
130
 	"""
131
 	Get number of lines in blob
131
 	Get number of lines in blob
132
 	"""
132
 	"""
133
 	ext, blob_id = ext_blob
133
 	ext, blob_id = ext_blob
134
-	return (ext, blob_id, int(getpipeoutput(['git cat-file blob %s' % blob_id, 'wc -l']).split()[0]))
134
+	return (ext, blob_id, int(getpipeoutput(['git cat-file blob %s' % blob_id, ('find /c /v ""', 'wc -l')[ON_LINUX]]).split()[0]))
135
 
135
 
136
 class DataCollector:
136
 class DataCollector:
137
 	"""Manages data collection from a revision control repository."""
137
 	"""Manages data collection from a revision control repository."""
286
 	def collect(self, dir):
286
 	def collect(self, dir):
287
 		DataCollector.collect(self, dir)
287
 		DataCollector.collect(self, dir)
288
 
288
 
289
-		self.total_authors += int(getpipeoutput(['git shortlog -s %s' % getlogrange(), 'wc -l']))
290
-		#self.total_lines = int(getoutput('git-ls-files -z |xargs -0 cat |wc -l'))
289
+		self.total_authors += int(getpipeoutput(['git shortlog -s %s' % getlogrange(), ('find /c /v ""', 'wc -l')[ON_LINUX]]))
290
+		#self.total_lines = int(getoutput('git-ls-files -z |xargs -0 cat |find /c /v ""'))
291
 
291
 
292
-		# tags
292
+		# tags		
293
 		lines = getpipeoutput(['git show-ref --tags']).split('\n')
293
 		lines = getpipeoutput(['git show-ref --tags']).split('\n')
294
 		for line in lines:
294
 		for line in lines:
295
 			if len(line) == 0:
295
 			if len(line) == 0:
327
 
327
 
328
 		# Collect revision statistics
328
 		# Collect revision statistics
329
 		# Outputs "<stamp> <date> <time> <timezone> <author> '<' <mail> '>'"
329
 		# Outputs "<stamp> <date> <time> <timezone> <author> '<' <mail> '>'"
330
-		lines = getpipeoutput(['git rev-list --pretty=format:"%%at %%ai %%aN <%%aE>" %s' % getlogrange('HEAD'), 'grep -v ^commit']).split('\n')
330
+		lines = getpipeoutput(['git rev-list --pretty=format:"%%at %%ai %%aN <%%aE>" %s' % getlogrange('HEAD'), ('findstr /v ', 'grep -v ')[ON_LINUX] + '^commit']).split('\n')
331
 		for line in lines:
331
 		for line in lines:
332
 			parts = line.split(' ', 4)
332
 			parts = line.split(' ', 4)
333
 			author = ''
333
 			author = ''
434
 			self.commits_by_timezone[timezone] = self.commits_by_timezone.get(timezone, 0) + 1
434
 			self.commits_by_timezone[timezone] = self.commits_by_timezone.get(timezone, 0) + 1
435
 
435
 
436
 		# outputs "<stamp> <files>" for each revision
436
 		# outputs "<stamp> <files>" for each revision
437
-		revlines = getpipeoutput(['git rev-list --pretty=format:"%%at %%T" %s' % getlogrange('HEAD'), 'grep -v ^commit']).strip().split('\n')
437
+		revlines = getpipeoutput(['git rev-list --pretty=format:"%%at %%T" %s' % getlogrange('HEAD'), ('findstr /v ',  'grep -v ')[ON_LINUX] + '^commit']).strip().split('\n')
438
 		lines = []
438
 		lines = []
439
 		revs_to_read = []
439
 		revs_to_read = []
440
 		time_rev_count = []
440
 		time_rev_count = []