@@ -348,14 +348,6 @@ def list_source_files(ext_list: list, ignored_paths: list, not_ignored: list) ->
348
348
[`main()`][cpp_linter.run.main]) when no files to be checked.
349
349
"""
350
350
start_log_group ("Get list of specified source files" )
351
- if os .path .exists (".gitmodules" ):
352
- submodules = configparser .ConfigParser ()
353
- submodules .read (".gitmodules" )
354
- for module in submodules .sections ():
355
- logger .info (
356
- "Appending submodule to ignored paths: %s" , submodules [module ]["path" ]
357
- )
358
- ignored_paths .append (submodules [module ]["path" ])
359
351
360
352
root_path = os .getcwd ()
361
353
for dirpath , _ , filenames in os .walk (root_path ):
@@ -755,16 +747,29 @@ def parse_ignore_option(paths: str) -> tuple:
755
747
- index 1 is the `not_ignored` list
756
748
"""
757
749
ignored , not_ignored = ([], [])
750
+
758
751
for path in paths .split ("|" ):
759
752
is_included = path .startswith ("!" )
760
753
if path .startswith ("!./" if is_included else "./" ):
761
754
path = path .replace ("./" , "" , 1 ) # relative dir is assumed
762
755
path = path .strip () # strip leading/trailing spaces
763
756
if is_included :
764
- not_ignored .append (path [1 :])
757
+ not_ignored .append (path [1 :]) # strip leading `!`
765
758
else :
766
759
ignored .append (path )
767
760
761
+ # auto detect submodules
762
+ if os .path .exists (".gitmodules" ):
763
+ submodules = configparser .ConfigParser ()
764
+ submodules .read (".gitmodules" )
765
+ for module in submodules .sections ():
766
+ logger .info (
767
+ "Appending submodule to ignored paths: %s" , submodules [module ]["path" ]
768
+ )
769
+ path = submodules [module ]["path" ].replace ()
770
+ if path not in not_ignored :
771
+ ignored .append (path )
772
+
768
773
if ignored :
769
774
logger .info (
770
775
"Ignoring the following paths/files:\n \t ./%s" ,
0 commit comments