@@ -52,20 +52,19 @@ def exclude_gitignore_files(current_path, path):
5252 global DEFAULT_EXCLUDE_EXTENSION_FILES
5353 try :
5454 root_path = VCSStrategyGit .find_root (current_path )
55- if os .path .isfile (os .path .join (root_path , '.gitignore' )):
56- cmd_result = subprocess .check_output (['git' ,
57- 'ls-files' ,
58- '-ci' ,
59- '--exclude-from=.gitignore' ],
60- universal_newlines = True )
61- cmd_result = cmd_result .split ('\n ' )
62- cmd_result .remove ('' )
63- if not path .endswith (f"{ os .sep } " ):
64- path += f"{ os .sep } "
65- cmd_result = [file .replace (path , '' , 1 ) for file in cmd_result ]
66- DEFAULT_EXCLUDE_EXTENSION_FILES .extend (cmd_result )
67- else :
68- return
55+ if root_path :
56+ if os .path .isfile (os .path .join (root_path , '.gitignore' )):
57+ cmd_result = subprocess .check_output (['git' ,
58+ 'ls-files' ,
59+ '-ci' ,
60+ '--exclude-from=.gitignore' ],
61+ universal_newlines = True )
62+ cmd_result = cmd_result .split ('\n ' )
63+ cmd_result .remove ('' )
64+ if not path .endswith (f"{ os .sep } " ):
65+ path += f"{ os .sep } "
66+ cmd_result = [file .replace (path , '' , 1 ) for file in cmd_result ]
67+ DEFAULT_EXCLUDE_EXTENSION_FILES .extend (cmd_result )
6968 except Exception as ex :
7069 logger .warning (f"Error to get git ignored files : { ex } " )
7170
0 commit comments