We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
2 parents 85f0cb9 + 4671258 commit 3a4d13fCopy full SHA for 3a4d13f
commitizen/config/__init__.py
@@ -28,8 +28,8 @@ def read_cfg() -> BaseConfig:
28
29
_conf: Union[TomlConfig, JsonConfig, YAMLConfig]
30
31
- with open(filename, "r") as f:
32
- data: str = f.read()
+ with open(filename, "rb") as f:
+ data: bytes = f.read()
33
34
if "toml" in filename.suffix:
35
_conf = TomlConfig(data=data, path=filename)
commitizen/config/base_config.py
@@ -31,5 +31,5 @@ def update(self, data: dict):
def add_path(self, path: Union[str, Path]):
self._path = Path(path)
- def _parse_setting(self, data: str) -> dict:
+ def _parse_setting(self, data: Union[bytes, str]) -> dict:
raise NotImplementedError()
commitizen/config/json_config.py
@@ -6,7 +6,7 @@
6
7
8
class JsonConfig(BaseConfig):
9
- def __init__(self, *, data: str, path: Union[Path, str]):
+ def __init__(self, *, data: Union[bytes, str], path: Union[Path, str]):
10
super(JsonConfig, self).__init__()
11
self.is_empty_config = False
12
self._parse_setting(data)
@@ -22,15 +22,15 @@ def set_key(self, key, value):
22
For now only strings are supported.
23
We use to update the version number.
24
"""
25
- with open(self.path, "r") as f:
+ with open(self.path, "rb") as f:
26
parser = json.load(f)
27
parser["commitizen"][key] = value
with open(self.path, "w") as f:
json.dump(parser, f)
return self
- def _parse_setting(self, data: str):
+ def _parse_setting(self, data: Union[bytes, str]):
"""We expect to have a section in .cz.json looking like
36
```
commitizen/config/toml_config.py
@@ -7,7 +7,7 @@
class TomlConfig(BaseConfig):
super(TomlConfig, self).__init__()
13
@@ -23,15 +23,15 @@ def set_key(self, key, value):
parser = parse(f.read())
parser["tool"]["commitizen"][key] = value
f.write(parser.as_string())
"""We expect to have a section in pyproject looking like
37
commitizen/config/yaml_config.py
class YAMLConfig(BaseConfig):
super(YAMLConfig, self).__init__()
@@ -17,7 +17,7 @@ def init_empty_config_content(self):
17
with open(self.path, "a") as json_file:
18
yaml.dump({"commitizen": {}}, json_file)
19
20
21
"""We expect to have a section in cz.yaml looking like
@@ -37,7 +37,7 @@ def set_key(self, key, value):
38
39
40
- with open(self.path, "r") as yaml_file:
+ with open(self.path, "rb") as yaml_file:
41
parser = yaml.load(yaml_file, Loader=yaml.FullLoader)
42
43
0 commit comments