@@ -167,23 +167,27 @@ def __scan(self):
167
167
path_filters = self .__get_path_filters (task_params )
168
168
print ("- * - * - * - * - * - * - * - * - * - * - * - * -* -* -* -* -* -* -" )
169
169
170
+ # ------------------------------------------------------------------ #
171
+ # 获取需要扫描的文件列表
172
+ # 此处获取到的文件列表,已经根据项目配置的过滤路径过滤
173
+ # 增量扫描时,从SCAN_FILES获取到的文件列表与从DIFF_FILES获取到的相同
174
+ # ------------------------------------------------------------------ #
175
+ scan_files_env = os .getenv ("SCAN_FILES" )
176
+ if scan_files_env and os .path .exists (scan_files_env ):
177
+ with open (scan_files_env , "r" ) as rf :
178
+ scan_files = json .load (rf )
179
+ print ("[debug] files to scan: %s" % len (scan_files ))
180
+
170
181
# ------------------------------------------------------------------ #
171
182
# 增量扫描时,可以通过环境变量获取到diff文件列表,只扫描diff文件,减少耗时
172
183
# 此处获取到的diff文件列表,已经根据项目配置的过滤路径过滤
173
184
# ------------------------------------------------------------------ #
174
- # 需要扫描的文件后缀名
175
- want_suffix = (".h" , ".m" , ".mm" )
176
185
# 从 DIFF_FILES 环境变量中获取增量文件列表存放的文件(全量扫描时没有这个环境变量)
177
- diff_file_json = os .environ .get ("DIFF_FILES" )
178
- if diff_file_json : # 如果存在 DIFF_FILES, 说明是增量扫描, 直接获取增量文件列表
179
- print ("get diff file: %s" % diff_file_json )
180
- with open (diff_file_json , "r" ) as rf :
186
+ diff_file_env = os .environ .get ("DIFF_FILES" )
187
+ if diff_file_env and os .path .exists (diff_file_env ): # 如果存在 DIFF_FILES, 说明是增量扫描, 直接获取增量文件列表
188
+ with open (diff_file_env , "r" ) as rf :
181
189
diff_files = json .load (rf )
182
- scan_files = [path for path in diff_files if path .lower ().endswith (want_suffix )]
183
- else : # 未获取到环境变量,即全量扫描,遍历source_dir获取需要扫描的文件列表
184
- scan_files = self .__get_dir_files (source_dir , want_suffix )
185
-
186
- print ("files to scan: %s" % len (scan_files ))
190
+ print ("[debug] get diff files: %s" % diff_files )
187
191
188
192
# todo: 此处需要自行实现工具逻辑,输出结果,存放到result列表中
189
193
# todo: 这里是demo结果,仅供展示,需要替换为实际结果
0 commit comments