Skip to content

Commit 87bf26f

Browse files
committed
refactor: simplify multiple config files warning
Remove extra steps to check if config files are empty. Just warn about multiple files and show first file from the list.
1 parent ad49e81 commit 87bf26f

File tree

1 file changed

+4
-20
lines changed

1 file changed

+4
-20
lines changed

commitizen/config/__init__.py

Lines changed: 4 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -55,26 +55,10 @@ def _check_and_warn_multiple_configs(filepath: str | None = None) -> None:
5555

5656
# If more than one config file exists, warn the user
5757
if len(existing_files) > 1:
58-
# Find which one will be used (first non-empty one in the priority order)
59-
used_config = None
60-
for filename in defaults.CONFIG_FILES:
61-
config_path = path / filename
62-
if config_path.exists():
63-
try:
64-
with open(config_path, "rb") as f:
65-
data = f.read()
66-
conf = create_config(data=data, path=config_path)
67-
if not conf.is_empty_config:
68-
used_config = filename
69-
break
70-
except Exception:
71-
continue
72-
73-
if used_config:
74-
out.warn(
75-
f"Multiple config files detected: {', '.join(existing_files)}. "
76-
f"Using {used_config}."
77-
)
58+
out.warn(
59+
f"Multiple config files detected: {', '.join(existing_files)}. "
60+
f"Using {existing_files[0]}."
61+
)
7862
break
7963

8064

0 commit comments

Comments
 (0)