@@ -70,7 +70,7 @@ class CoCom(Graal):
70
70
:raises RepositoryError: raised when there was an error cloning or
71
71
updating the repository.
72
72
"""
73
- version = '0.2.4 '
73
+ version = '0.2.5 '
74
74
75
75
CATEGORIES = [CATEGORY_COCOM ]
76
76
@@ -80,9 +80,12 @@ def __init__(self, uri, git_path, worktreepath=DEFAULT_WORKTREE_PATH,
80
80
super ().__init__ (uri , git_path , worktreepath ,
81
81
entrypoint = entrypoint , in_paths = in_paths , out_paths = out_paths , details = details ,
82
82
tag = tag , archive = archive )
83
+
84
+ self .history = dict ()
85
+ self .repository_level = None
83
86
self .file_analyzer = FileAnalyzer (details )
84
87
85
- def fetch (self , category = CATEGORY_COCOM , paths = None ,
88
+ def fetch (self , category = CATEGORY_COCOM , paths = None , repository_level = False ,
86
89
from_date = DEFAULT_DATETIME , to_date = DEFAULT_LAST_DATETIME ,
87
90
branches = None , latest_items = False ):
88
91
"""Fetch commits and add code complexity information."""
@@ -91,6 +94,7 @@ def fetch(self, category=CATEGORY_COCOM, paths=None,
91
94
from_date = from_date , to_date = to_date ,
92
95
branches = branches , latest_items = latest_items )
93
96
97
+ self .repository_level = repository_level
94
98
return items
95
99
96
100
@staticmethod
@@ -155,8 +159,10 @@ def _analyze(self, commit):
155
159
if committed_file .get ("newfile" , None ):
156
160
file_path = committed_file ["newfile" ]
157
161
local_path = self .worktreepath + '/' + file_path
162
+ self .history .pop (file_path , None )
158
163
analysis .append (file_info )
159
164
elif committed_file .get ("action" , None ) == "D" :
165
+ self .history .pop (file_path , None )
160
166
analysis .append (file_info )
161
167
continue
162
168
else :
@@ -165,8 +171,28 @@ def _analyze(self, commit):
165
171
file_info = self .file_analyzer .analyze (local_path )
166
172
file_info .update ({'file_path' : file_path })
167
173
analysis .append (file_info )
168
-
169
- return analysis
174
+ self .history [file_path ] = file_info
175
+
176
+ if self .repository_level :
177
+ repository_level_analysis = {
178
+ 'blanks' : 0 ,
179
+ 'comments' : 0 ,
180
+ 'loc' : 0 ,
181
+ 'ccn' : 0 ,
182
+ 'num_funs' : 0 ,
183
+ 'tokens' : 0 ,
184
+ }
185
+ for file_path in self .history :
186
+ repository_level_analysis ['blanks' ] += self .history [file_path ].get ('blanks' , 0 )
187
+ repository_level_analysis ['comments' ] += self .history [file_path ].get ('comments' , 0 )
188
+ repository_level_analysis ['loc' ] += self .history [file_path ].get ('loc' , 0 )
189
+ repository_level_analysis ['ccn' ] += self .history [file_path ].get ('ccn' , 0 )
190
+ repository_level_analysis ['num_funs' ] += self .history [file_path ].get ('num_funs' , 0 )
191
+ repository_level_analysis ['tokens' ] += self .history [file_path ].get ('tokens' , 0 )
192
+
193
+ return repository_level_analysis
194
+ else :
195
+ return analysis
170
196
171
197
def _post (self , commit ):
172
198
"""Remove attributes of the Graal item obtained
0 commit comments