Kaynağa Gözat

Save cache to output directory, not git repository.

This closes bug #2184326 on SourceForge. Some people may not have access to
their git repository, so we save the cache to the output directory instead
(which must always have write access anyway).
Heikki Hokkanen 17 yıl önce
ebeveyn
işleme
82e685fbe0
1 değiştirilmiş dosya ile 7 ekleme ve 6 silme
  1. 7
    6
      gitstats

+ 7
- 6
gitstats Dosyayı Görüntüle

@@ -64,8 +64,7 @@ class DataCollector:
64 64
 	
65 65
 	##
66 66
 	# Load cacheable data
67
-	def loadCache(self, dir):
68
-		cachefile = os.path.join(dir, '.git', 'gitstats.cache')
67
+	def loadCache(self, cachefile):
69 68
 		if not os.path.exists(cachefile):
70 69
 			return
71 70
 		print 'Loading cache...'
@@ -125,9 +124,9 @@ class DataCollector:
125 124
 	
126 125
 	##
127 126
 	# Save cacheable data
128
-	def saveCache(self, dir):
127
+	def saveCache(self, filename):
129 128
 		print 'Saving cache...'
130
-		f = open(os.path.join(dir, '.git', 'gitstats.cache'), 'w')
129
+		f = open(cachefile, 'w')
131 130
 		#pickle.dump(self.cache, f)
132 131
 		data = zlib.compress(pickle.dumps(self.cache))
133 132
 		f.write(data)
@@ -901,12 +900,14 @@ print 'Output path: %s' % outputpath
901 900
 
902 901
 os.chdir(gitpath)
903 902
 
903
+cachefile = os.path.join(outputpath, 'gitstats.cache')
904
+
904 905
 print 'Collecting data...'
905 906
 data = GitDataCollector()
906
-data.loadCache(gitpath)
907
+data.loadCache(cachefile)
907 908
 data.collect(gitpath)
908 909
 print 'Refining data...'
909
-data.saveCache(gitpath)
910
+data.saveCache(cachefile)
910 911
 data.refine()
911 912
 
912 913
 os.chdir(rundir)