MCPcopy Index your code
hub / github.com/commitizen-tools/commitizen / read_cfg

Function read_cfg

commitizen/config/__init__.py:34–51  ·  view source on GitHub ↗
(filepath: str | None = None)

Source from the content-addressed store, hash-verified

32
33
34def read_cfg(filepath: str | None = None) -> BaseConfig:
35 if filepath is not None:
36 conf_path = Path(filepath)
37 if not conf_path.is_file():
38 raise ConfigFileNotFound()
39 conf = _create_config_from_path(conf_path)
40 if not conf.contains_commitizen_section():
41 raise ConfigFileIsEmpty()
42 return conf
43
44 config_candidates = _resolve_config_candidates()
45 if len(config_candidates) > 1:
46 out.warn(
47 f"Multiple config files detected: {', '.join(str(conf.path) for conf in config_candidates)}. "
48 f"Using config file: '{config_candidates[0].path}'."
49 )
50
51 return config_candidates[0] if config_candidates else BaseConfig()

Callers

nothing calls this directly

Calls 6

ConfigFileNotFoundClass · 0.90
ConfigFileIsEmptyClass · 0.90
_create_config_from_pathFunction · 0.85
BaseConfigClass · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…