Skip to content

Commit cb3a7df

Browse files
committed
resolve #76
1 parent 4656598 commit cb3a7df

File tree

1 file changed

+14
-9
lines changed

1 file changed

+14
-9
lines changed

cpp_linter/run.py

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -348,14 +348,6 @@ def list_source_files(ext_list: list, ignored_paths: list, not_ignored: list) ->
348348
[`main()`][cpp_linter.run.main]) when no files to be checked.
349349
"""
350350
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"])
359351

360352
root_path = os.getcwd()
361353
for dirpath, _, filenames in os.walk(root_path):
@@ -755,16 +747,29 @@ def parse_ignore_option(paths: str) -> tuple:
755747
- index 1 is the `not_ignored` list
756748
"""
757749
ignored, not_ignored = ([], [])
750+
758751
for path in paths.split("|"):
759752
is_included = path.startswith("!")
760753
if path.startswith("!./" if is_included else "./"):
761754
path = path.replace("./", "", 1) # relative dir is assumed
762755
path = path.strip() # strip leading/trailing spaces
763756
if is_included:
764-
not_ignored.append(path[1:])
757+
not_ignored.append(path[1:]) # strip leading `!`
765758
else:
766759
ignored.append(path)
767760

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+
768773
if ignored:
769774
logger.info(
770775
"Ignoring the following paths/files:\n\t./%s",

0 commit comments

Comments
 (0)