@@ -213,9 +213,10 @@ def __prepare_cpplint_args(self, source_dir, rules, linelength, project_name):
213213 if file_extensions :
214214 cmd_args .append ("--extensions=" + file_extensions )
215215 logger .info ("扫描文件为 %s" % file_extensions )
216- if project_name .find (".git" ) != - 1 :
217- project_name = project_name .replace (".git" , "" )
218- cmd_args .append ("--root=%s" % project_name )
216+ if project_name :
217+ if project_name .find (".git" ) != - 1 :
218+ project_name = project_name .replace (".git" , "" )
219+ cmd_args .append ("--root=%s" % project_name )
219220 if rules :
220221 filter_arg = "--filter=-,+" + ",+" .join (rules )
221222 cmd_args .append (filter_arg )
@@ -288,13 +289,15 @@ def analyze(self, params):
288289 reg_client = re .compile (r"^(.+?):(\d+):\s+(.+?)\s+\[([\S]+)\]\s+\[(\d+)\]$" )
289290 max_linelength = self .__get_linelength_param (params )
290291 # 获取项目名称
291- if "git" == params .get ("scm_type" ): # git仓库
292+ project_name = None
293+ scm_type = params .get ("scm_type" )
294+ if "git" == scm_type : # git仓库
292295 project_name = params .get ("scm_url" )
293296 if project_name .find ("#" ) != - 1 :
294297 project_name = project_name .split ("#" )[0 ]
295298 project_name = project_name .split ("/" )[- 1 ]
296299 project_name = project_name .replace (".git" , "" )
297- else : # svn项目
300+ elif "svn" == scm_type : # svn项目
298301 project_name = params .get ("scm_url" ).split ("/" )[- 1 ].split ("_proj" )[0 ]
299302 cmd_args = self .__prepare_cpplint_args (source_dir , rules , max_linelength , project_name )
300303
0 commit comments