commitizen 4.13.0__tar.gz → 4.13.2__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (73) hide show
  1. {commitizen-4.13.0 → commitizen-4.13.2}/PKG-INFO +1 -1
  2. commitizen-4.13.2/commitizen/__version__.py +1 -0
  3. {commitizen-4.13.0 → commitizen-4.13.2}/commitizen/changelog_formats/base.py +7 -9
  4. {commitizen-4.13.0 → commitizen-4.13.2}/commitizen/commands/changelog.py +5 -6
  5. {commitizen-4.13.0 → commitizen-4.13.2}/commitizen/commands/commit.py +1 -3
  6. {commitizen-4.13.0 → commitizen-4.13.2}/commitizen/commands/init.py +4 -3
  7. {commitizen-4.13.0 → commitizen-4.13.2}/commitizen/config/__init__.py +10 -18
  8. {commitizen-4.13.0 → commitizen-4.13.2}/commitizen/config/base_config.py +7 -1
  9. {commitizen-4.13.0 → commitizen-4.13.2}/commitizen/config/json_config.py +7 -2
  10. {commitizen-4.13.0 → commitizen-4.13.2}/commitizen/config/toml_config.py +11 -7
  11. {commitizen-4.13.0 → commitizen-4.13.2}/commitizen/config/yaml_config.py +7 -4
  12. {commitizen-4.13.0 → commitizen-4.13.2}/commitizen/cz/conventional_commits/conventional_commits.py +3 -4
  13. {commitizen-4.13.0 → commitizen-4.13.2}/commitizen/cz/jira/jira.py +3 -4
  14. {commitizen-4.13.0 → commitizen-4.13.2}/commitizen/providers/cargo_provider.py +1 -1
  15. {commitizen-4.13.0 → commitizen-4.13.2}/commitizen/providers/npm_provider.py +2 -2
  16. {commitizen-4.13.0 → commitizen-4.13.2}/commitizen/tags.py +22 -25
  17. {commitizen-4.13.0 → commitizen-4.13.2}/pyproject.toml +1 -1
  18. commitizen-4.13.0/commitizen/__version__.py +0 -1
  19. {commitizen-4.13.0 → commitizen-4.13.2}/LICENSE +0 -0
  20. {commitizen-4.13.0 → commitizen-4.13.2}/commitizen/__init__.py +0 -0
  21. {commitizen-4.13.0 → commitizen-4.13.2}/commitizen/__main__.py +0 -0
  22. {commitizen-4.13.0 → commitizen-4.13.2}/commitizen/bump.py +0 -0
  23. {commitizen-4.13.0 → commitizen-4.13.2}/commitizen/changelog.py +0 -0
  24. {commitizen-4.13.0 → commitizen-4.13.2}/commitizen/changelog_formats/__init__.py +0 -0
  25. {commitizen-4.13.0 → commitizen-4.13.2}/commitizen/changelog_formats/asciidoc.py +0 -0
  26. {commitizen-4.13.0 → commitizen-4.13.2}/commitizen/changelog_formats/markdown.py +0 -0
  27. {commitizen-4.13.0 → commitizen-4.13.2}/commitizen/changelog_formats/restructuredtext.py +0 -0
  28. {commitizen-4.13.0 → commitizen-4.13.2}/commitizen/changelog_formats/textile.py +0 -0
  29. {commitizen-4.13.0 → commitizen-4.13.2}/commitizen/cli.py +0 -0
  30. {commitizen-4.13.0 → commitizen-4.13.2}/commitizen/cmd.py +0 -0
  31. {commitizen-4.13.0 → commitizen-4.13.2}/commitizen/commands/__init__.py +0 -0
  32. {commitizen-4.13.0 → commitizen-4.13.2}/commitizen/commands/bump.py +0 -0
  33. {commitizen-4.13.0 → commitizen-4.13.2}/commitizen/commands/check.py +0 -0
  34. {commitizen-4.13.0 → commitizen-4.13.2}/commitizen/commands/example.py +0 -0
  35. {commitizen-4.13.0 → commitizen-4.13.2}/commitizen/commands/info.py +0 -0
  36. {commitizen-4.13.0 → commitizen-4.13.2}/commitizen/commands/list_cz.py +0 -0
  37. {commitizen-4.13.0 → commitizen-4.13.2}/commitizen/commands/schema.py +0 -0
  38. {commitizen-4.13.0 → commitizen-4.13.2}/commitizen/commands/version.py +0 -0
  39. {commitizen-4.13.0 → commitizen-4.13.2}/commitizen/config/factory.py +0 -0
  40. {commitizen-4.13.0 → commitizen-4.13.2}/commitizen/cz/__init__.py +0 -0
  41. {commitizen-4.13.0 → commitizen-4.13.2}/commitizen/cz/base.py +0 -0
  42. {commitizen-4.13.0 → commitizen-4.13.2}/commitizen/cz/conventional_commits/__init__.py +0 -0
  43. {commitizen-4.13.0 → commitizen-4.13.2}/commitizen/cz/conventional_commits/conventional_commits_info.txt +0 -0
  44. {commitizen-4.13.0 → commitizen-4.13.2}/commitizen/cz/customize/__init__.py +0 -0
  45. {commitizen-4.13.0 → commitizen-4.13.2}/commitizen/cz/customize/customize.py +0 -0
  46. {commitizen-4.13.0 → commitizen-4.13.2}/commitizen/cz/customize/customize_info.txt +0 -0
  47. {commitizen-4.13.0 → commitizen-4.13.2}/commitizen/cz/exceptions.py +0 -0
  48. {commitizen-4.13.0 → commitizen-4.13.2}/commitizen/cz/jira/__init__.py +0 -0
  49. {commitizen-4.13.0 → commitizen-4.13.2}/commitizen/cz/jira/jira_info.txt +0 -0
  50. {commitizen-4.13.0 → commitizen-4.13.2}/commitizen/cz/utils.py +0 -0
  51. {commitizen-4.13.0 → commitizen-4.13.2}/commitizen/defaults.py +0 -0
  52. {commitizen-4.13.0 → commitizen-4.13.2}/commitizen/exceptions.py +0 -0
  53. {commitizen-4.13.0 → commitizen-4.13.2}/commitizen/factory.py +0 -0
  54. {commitizen-4.13.0 → commitizen-4.13.2}/commitizen/git.py +0 -0
  55. {commitizen-4.13.0 → commitizen-4.13.2}/commitizen/hooks.py +0 -0
  56. {commitizen-4.13.0 → commitizen-4.13.2}/commitizen/out.py +0 -0
  57. {commitizen-4.13.0 → commitizen-4.13.2}/commitizen/project_info.py +0 -0
  58. {commitizen-4.13.0 → commitizen-4.13.2}/commitizen/providers/__init__.py +0 -0
  59. {commitizen-4.13.0 → commitizen-4.13.2}/commitizen/providers/base_provider.py +0 -0
  60. {commitizen-4.13.0 → commitizen-4.13.2}/commitizen/providers/commitizen_provider.py +0 -0
  61. {commitizen-4.13.0 → commitizen-4.13.2}/commitizen/providers/composer_provider.py +0 -0
  62. {commitizen-4.13.0 → commitizen-4.13.2}/commitizen/providers/pep621_provider.py +0 -0
  63. {commitizen-4.13.0 → commitizen-4.13.2}/commitizen/providers/poetry_provider.py +0 -0
  64. {commitizen-4.13.0 → commitizen-4.13.2}/commitizen/providers/scm_provider.py +0 -0
  65. {commitizen-4.13.0 → commitizen-4.13.2}/commitizen/providers/uv_provider.py +0 -0
  66. {commitizen-4.13.0 → commitizen-4.13.2}/commitizen/py.typed +0 -0
  67. {commitizen-4.13.0 → commitizen-4.13.2}/commitizen/question.py +0 -0
  68. {commitizen-4.13.0 → commitizen-4.13.2}/commitizen/templates/CHANGELOG.adoc.j2 +0 -0
  69. {commitizen-4.13.0 → commitizen-4.13.2}/commitizen/templates/CHANGELOG.md.j2 +0 -0
  70. {commitizen-4.13.0 → commitizen-4.13.2}/commitizen/templates/CHANGELOG.rst.j2 +0 -0
  71. {commitizen-4.13.0 → commitizen-4.13.2}/commitizen/templates/CHANGELOG.textile.j2 +0 -0
  72. {commitizen-4.13.0 → commitizen-4.13.2}/commitizen/version_schemes.py +0 -0
  73. {commitizen-4.13.0 → commitizen-4.13.2}/docs/README.md +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: commitizen
3
- Version: 4.13.0
3
+ Version: 4.13.2
4
4
  Summary: Python commitizen client tool
5
5
  Keywords: commitizen,conventional,commits,git
6
6
  Author: Santiago Fraire
@@ -0,0 +1 @@
1
+ __version__ = "4.13.2"
@@ -1,7 +1,7 @@
1
1
  from __future__ import annotations
2
2
 
3
- import os
4
3
  from abc import ABCMeta
4
+ from pathlib import Path
5
5
  from typing import IO, TYPE_CHECKING, Any, ClassVar
6
6
 
7
7
  from commitizen.changelog import IncrementalMergeInfo, Metadata
@@ -36,12 +36,11 @@ class BaseFormat(ChangelogFormat, metaclass=ABCMeta):
36
36
  )
37
37
 
38
38
  def get_metadata(self, filepath: str) -> Metadata:
39
- if not os.path.isfile(filepath):
39
+ file = Path(filepath)
40
+ if not file.is_file():
40
41
  return Metadata()
41
42
 
42
- with open(
43
- filepath, encoding=self.config.settings["encoding"]
44
- ) as changelog_file:
43
+ with file.open(encoding=self.config.settings["encoding"]) as changelog_file:
45
44
  return self.get_metadata_from_file(changelog_file)
46
45
 
47
46
  def get_metadata_from_file(self, file: IO[Any]) -> Metadata:
@@ -74,12 +73,11 @@ class BaseFormat(ChangelogFormat, metaclass=ABCMeta):
74
73
  return meta
75
74
 
76
75
  def get_latest_full_release(self, filepath: str) -> IncrementalMergeInfo:
77
- if not os.path.isfile(filepath):
76
+ file = Path(filepath)
77
+ if not file.is_file():
78
78
  return IncrementalMergeInfo()
79
79
 
80
- with open(
81
- filepath, encoding=self.config.settings["encoding"]
82
- ) as changelog_file:
80
+ with file.open(encoding=self.config.settings["encoding"]) as changelog_file:
83
81
  return self.get_latest_full_release_from_file(changelog_file)
84
82
 
85
83
  def get_latest_full_release_from_file(self, file: IO[Any]) -> IncrementalMergeInfo:
@@ -1,7 +1,5 @@
1
1
  from __future__ import annotations
2
2
 
3
- import os
4
- import os.path
5
3
  from difflib import SequenceMatcher
6
4
  from operator import itemgetter
7
5
  from pathlib import Path
@@ -66,7 +64,7 @@ class Changelog:
66
64
  f"or the setting `changelog_file` in {self.config.path}"
67
65
  )
68
66
  self.file_name = (
69
- os.path.join(str(self.config.path.parent), changelog_file_name)
67
+ Path(self.config.path.parent, changelog_file_name).as_posix()
70
68
  if self.config.path is not None
71
69
  else changelog_file_name
72
70
  )
@@ -282,9 +280,10 @@ class Changelog:
282
280
  raise DryRunExit()
283
281
 
284
282
  lines = []
285
- if self.incremental and os.path.isfile(self.file_name):
286
- with open(
287
- self.file_name, encoding=self.config.settings["encoding"]
283
+ changelog_path = Path(self.file_name)
284
+ if self.incremental and changelog_path.is_file():
285
+ with changelog_path.open(
286
+ encoding=self.config.settings["encoding"]
288
287
  ) as changelog_file:
289
288
  lines = changelog_file.readlines()
290
289
 
@@ -61,9 +61,7 @@ class Commit:
61
61
  return None
62
62
 
63
63
  # Read commit message from backup
64
- with open(
65
- self.backup_file_path, encoding=self.config.settings["encoding"]
66
- ) as f:
64
+ with self.backup_file_path.open(encoding=self.config.settings["encoding"]) as f:
67
65
  return f.read().strip()
68
66
 
69
67
  def _get_message_by_prompt_commit_questions(self) -> str:
@@ -288,11 +288,12 @@ class Init:
288
288
  ],
289
289
  }
290
290
 
291
- if not Path(".pre-commit-config.yaml").is_file():
291
+ pre_commit_config_path = Path(self._PRE_COMMIT_CONFIG_PATH)
292
+ if not pre_commit_config_path.is_file():
292
293
  return {"repos": [CZ_HOOK_CONFIG]}
293
294
 
294
- with open(
295
- self._PRE_COMMIT_CONFIG_PATH, encoding=self.config.settings["encoding"]
295
+ with pre_commit_config_path.open(
296
+ encoding=self.config.settings["encoding"]
296
297
  ) as config_file:
297
298
  config_data: dict[str, Any] = yaml.safe_load(config_file) or {}
298
299
 
@@ -13,40 +13,32 @@ def _resolve_config_candidates() -> list[BaseConfig]:
13
13
  git_project_root = git.find_git_project_root()
14
14
  cfg_search_paths = [Path(".")]
15
15
 
16
- if git_project_root and not cfg_search_paths[0].samefile(git_project_root):
16
+ if git_project_root and cfg_search_paths[0].resolve() != git_project_root.resolve():
17
17
  cfg_search_paths.append(git_project_root)
18
18
 
19
- # The following algorithm is ugly, but we need to ensure that the order of the candidates are preserved before v5.
20
- # Also, the number of possible config files is limited, so the complexity is not a problem.
21
19
  candidates: list[BaseConfig] = []
22
20
  for dir in cfg_search_paths:
23
21
  for filename in defaults.CONFIG_FILES:
24
- out_path = dir / Path(filename)
25
- if (
26
- out_path.exists()
27
- and not any(
28
- out_path.samefile(candidate.path) for candidate in candidates
29
- )
30
- and not (conf := _create_config_from_path(out_path)).is_empty_config
31
- ):
32
- candidates.append(conf)
22
+ out_path = dir / filename
23
+ if out_path.is_file():
24
+ conf = _create_config_from_path(out_path)
25
+ if conf.contains_commitizen_section():
26
+ candidates.append(conf)
33
27
  return candidates
34
28
 
35
29
 
36
30
  def _create_config_from_path(path: Path) -> BaseConfig:
37
- with open(path, "rb") as f:
38
- data: bytes = f.read()
39
-
40
- return create_config(data=data, path=path)
31
+ with path.open("rb") as f:
32
+ return create_config(data=f.read(), path=path)
41
33
 
42
34
 
43
35
  def read_cfg(filepath: str | None = None) -> BaseConfig:
44
36
  if filepath is not None:
45
37
  conf_path = Path(filepath)
46
- if not conf_path.exists():
38
+ if not conf_path.is_file():
47
39
  raise ConfigFileNotFound()
48
40
  conf = _create_config_from_path(conf_path)
49
- if conf.is_empty_config:
41
+ if not conf.contains_commitizen_section():
50
42
  raise ConfigFileIsEmpty()
51
43
  return conf
52
44
 
@@ -17,10 +17,16 @@ if TYPE_CHECKING:
17
17
 
18
18
  class BaseConfig:
19
19
  def __init__(self) -> None:
20
- self.is_empty_config = False
21
20
  self._settings: Settings = DEFAULT_SETTINGS.copy()
22
21
  self._path: Path | None = None
23
22
 
23
+ def contains_commitizen_section(self) -> bool:
24
+ """Check if the config file contains a commitizen section.
25
+
26
+ The implementation is different for each config file type.
27
+ """
28
+ raise NotImplementedError()
29
+
24
30
  @property
25
31
  def settings(self) -> Settings:
26
32
  return self._settings
@@ -25,6 +25,11 @@ class JsonConfig(BaseConfig):
25
25
  self.path = path
26
26
  self._parse_setting(data)
27
27
 
28
+ def contains_commitizen_section(self) -> bool:
29
+ with self.path.open("rb") as json_file:
30
+ config_doc = json.load(json_file)
31
+ return config_doc.get("commitizen") is not None
32
+
28
33
  def init_empty_config_content(self) -> None:
29
34
  with smart_open(
30
35
  self.path, "a", encoding=self._settings["encoding"]
@@ -32,7 +37,7 @@ class JsonConfig(BaseConfig):
32
37
  json.dump({"commitizen": {}}, json_file)
33
38
 
34
39
  def set_key(self, key: str, value: object) -> Self:
35
- with open(self.path, "rb") as f:
40
+ with self.path.open("rb") as f:
36
41
  config_doc = json.load(f)
37
42
 
38
43
  config_doc["commitizen"][key] = value
@@ -59,4 +64,4 @@ class JsonConfig(BaseConfig):
59
64
  try:
60
65
  self.settings.update(doc["commitizen"])
61
66
  except KeyError:
62
- self.is_empty_config = True
67
+ pass
@@ -1,6 +1,5 @@
1
1
  from __future__ import annotations
2
2
 
3
- import os
4
3
  from typing import TYPE_CHECKING
5
4
 
6
5
  from tomlkit import TOMLDocument, exceptions, parse, table
@@ -26,27 +25,32 @@ class TomlConfig(BaseConfig):
26
25
  self.path = path
27
26
  self._parse_setting(data)
28
27
 
28
+ def contains_commitizen_section(self) -> bool:
29
+ with self.path.open("rb") as f:
30
+ config_doc = parse(f.read())
31
+ return config_doc.get("tool", {}).get("commitizen") is not None
32
+
29
33
  def init_empty_config_content(self) -> None:
30
34
  config_doc = TOMLDocument()
31
- if os.path.isfile(self.path):
32
- with open(self.path, "rb") as input_toml_file:
35
+ if self.path.is_file():
36
+ with self.path.open("rb") as input_toml_file:
33
37
  config_doc = parse(input_toml_file.read())
34
38
 
35
39
  if config_doc.get("tool") is None:
36
40
  config_doc["tool"] = table()
37
41
  config_doc["tool"]["commitizen"] = table() # type: ignore[index]
38
42
 
39
- with open(self.path, "wb") as output_toml_file:
43
+ with self.path.open("wb") as output_toml_file:
40
44
  output_toml_file.write(
41
45
  config_doc.as_string().encode(self._settings["encoding"])
42
46
  )
43
47
 
44
48
  def set_key(self, key: str, value: object) -> Self:
45
- with open(self.path, "rb") as f:
49
+ with self.path.open("rb") as f:
46
50
  config_doc = parse(f.read())
47
51
 
48
52
  config_doc["tool"]["commitizen"][key] = value # type: ignore[index]
49
- with open(self.path, "wb") as f:
53
+ with self.path.open("wb") as f:
50
54
  f.write(config_doc.as_string().encode(self._settings["encoding"]))
51
55
 
52
56
  return self
@@ -67,4 +71,4 @@ class TomlConfig(BaseConfig):
67
71
  try:
68
72
  self.settings.update(doc["tool"]["commitizen"]) # type: ignore[index,typeddict-item] # TODO: fix this
69
73
  except exceptions.NonExistentKey:
70
- self.is_empty_config = True
74
+ pass
@@ -32,6 +32,11 @@ class YAMLConfig(BaseConfig):
32
32
  ) as json_file:
33
33
  yaml.dump({"commitizen": {}}, json_file, explicit_start=True)
34
34
 
35
+ def contains_commitizen_section(self) -> bool:
36
+ with self.path.open("rb") as yaml_file:
37
+ config_doc = yaml.load(yaml_file, Loader=yaml.FullLoader)
38
+ return config_doc.get("commitizen") is not None
39
+
35
40
  def _parse_setting(self, data: bytes | str) -> None:
36
41
  """We expect to have a section in cz.yaml looking like
37
42
 
@@ -40,8 +45,6 @@ class YAMLConfig(BaseConfig):
40
45
  name: cz_conventional_commits
41
46
  ```
42
47
  """
43
- import yaml.scanner
44
-
45
48
  try:
46
49
  doc = yaml.safe_load(data)
47
50
  except yaml.YAMLError as e:
@@ -50,10 +53,10 @@ class YAMLConfig(BaseConfig):
50
53
  try:
51
54
  self.settings.update(doc["commitizen"])
52
55
  except (KeyError, TypeError):
53
- self.is_empty_config = True
56
+ pass
54
57
 
55
58
  def set_key(self, key: str, value: object) -> Self:
56
- with open(self.path, "rb") as yaml_file:
59
+ with self.path.open("rb") as yaml_file:
57
60
  config_doc = yaml.load(yaml_file, Loader=yaml.FullLoader)
58
61
 
59
62
  config_doc["commitizen"][key] = value
@@ -1,6 +1,6 @@
1
1
  from __future__ import annotations
2
2
 
3
- import os
3
+ from pathlib import Path
4
4
  from typing import TYPE_CHECKING, TypedDict
5
5
 
6
6
  from commitizen import defaults
@@ -214,7 +214,6 @@ class ConventionalCommitsCz(BaseCommitizen):
214
214
  )
215
215
 
216
216
  def info(self) -> str:
217
- dir_path = os.path.dirname(os.path.realpath(__file__))
218
- filepath = os.path.join(dir_path, "conventional_commits_info.txt")
219
- with open(filepath, encoding=self.config.settings["encoding"]) as f:
217
+ filepath = Path(__file__).parent / "conventional_commits_info.txt"
218
+ with filepath.open(encoding=self.config.settings["encoding"]) as f:
220
219
  return f.read()
@@ -1,6 +1,6 @@
1
1
  from __future__ import annotations
2
2
 
3
- import os
3
+ from pathlib import Path
4
4
  from typing import TYPE_CHECKING
5
5
 
6
6
  from commitizen.cz.base import BaseCommitizen
@@ -73,7 +73,6 @@ class JiraSmartCz(BaseCommitizen):
73
73
  return r".*[A-Z]{2,}\-[0-9]+( #| .* #).+( #.+)*"
74
74
 
75
75
  def info(self) -> str:
76
- dir_path = os.path.dirname(os.path.realpath(__file__))
77
- filepath = os.path.join(dir_path, "jira_info.txt")
78
- with open(filepath, encoding=self.config.settings["encoding"]) as f:
76
+ filepath = Path(__file__).parent / "jira_info.txt"
77
+ with filepath.open(encoding=self.config.settings["encoding"]) as f:
79
78
  return f.read()
@@ -39,7 +39,7 @@ class CargoProvider(TomlProvider):
39
39
 
40
40
  def set_version(self, version: str) -> None:
41
41
  super().set_version(version)
42
- if self.lock_file.exists():
42
+ if self.lock_file.is_file():
43
43
  self.set_lock_version(version)
44
44
 
45
45
  def set_lock_version(self, version: str) -> None:
@@ -46,14 +46,14 @@ class NpmProvider(VersionProvider):
46
46
  self.package_file.write_text(
47
47
  json.dumps(package_document, indent=self.indent) + "\n"
48
48
  )
49
- if self.lock_file.exists():
49
+ if self.lock_file.is_file():
50
50
  lock_document = self.set_lock_version(
51
51
  json.loads(self.lock_file.read_text()), version
52
52
  )
53
53
  self.lock_file.write_text(
54
54
  json.dumps(lock_document, indent=self.indent) + "\n"
55
55
  )
56
- if self.shrinkwrap_file.exists():
56
+ if self.shrinkwrap_file.is_file():
57
57
  shrinkwrap_document = self.set_shrinkwrap_version(
58
58
  json.loads(self.shrinkwrap_file.read_text()), version
59
59
  )
@@ -154,24 +154,13 @@ class TagRules:
154
154
  candidates = (
155
155
  m for regex in self.version_regexes if (m := regex.fullmatch(tag.name))
156
156
  )
157
- if not (m := next(candidates, None)):
157
+ if not (match := next(candidates, None)):
158
158
  raise InvalidVersion(self._version_tag_error(tag.name))
159
- if "version" in m.groupdict():
160
- return self.scheme(m.group("version"))
161
159
 
162
- parts = m.groupdict()
163
- version = parts["major"]
160
+ if version := match.groupdict().get("version"):
161
+ return self.scheme(version)
164
162
 
165
- if minor := parts.get("minor"):
166
- version = f"{version}.{minor}"
167
- if patch := parts.get("patch"):
168
- version = f"{version}.{patch}"
169
-
170
- if parts.get("prerelease"):
171
- version = f"{version}-{parts['prerelease']}"
172
- if parts.get("devrelease"):
173
- version = f"{version}{parts['devrelease']}"
174
- return self.scheme(version)
163
+ return self.scheme(self._extract_version(match))
175
164
 
176
165
  def include_in_changelog(self, tag: GitTag) -> bool:
177
166
  """Check if a tag should be included in the changelog"""
@@ -195,19 +184,14 @@ class TagRules:
195
184
 
196
185
  match = matches[-1 if last else 0]
197
186
 
198
- if "version" in match.groupdict():
199
- return VersionTag(match.group("version"), match.group(0))
187
+ groups = match.groupdict()
188
+ if version := groups.get("version"):
189
+ return VersionTag(version, match.group(0))
200
190
 
201
- parts = match.groupdict()
202
- try:
203
- version = f"{parts['major']}.{parts['minor']}.{parts['patch']}"
204
- except KeyError:
191
+ if not all(value in groups for value in ["major", "minor", "patch"]):
205
192
  return None
206
193
 
207
- if parts.get("prerelease"):
208
- version = f"{version}-{parts['prerelease']}"
209
- if parts.get("devrelease"):
210
- version = f"{version}{parts['devrelease']}"
194
+ version = self._extract_version(match)
211
195
  return VersionTag(version, match.group(0))
212
196
 
213
197
  def normalize_tag(
@@ -284,3 +268,16 @@ class TagRules:
284
268
  ignored_tag_formats=settings["ignored_tag_formats"],
285
269
  merge_prereleases=settings["changelog_merge_prerelease"],
286
270
  )
271
+
272
+ def _extract_version(self, match: re.Match[str]) -> str:
273
+ groups = match.groupdict()
274
+ parts: list[str] = [groups["major"]]
275
+ if minor := groups.get("minor"):
276
+ parts.append(f".{minor}")
277
+ if patch := groups.get("patch"):
278
+ parts.append(f".{patch}")
279
+ if prerelease := groups.get("prerelease"):
280
+ parts.append(f"-{prerelease}")
281
+ if devrelease := groups.get("devrelease"):
282
+ parts.append(devrelease)
283
+ return "".join(parts)
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "commitizen"
3
- version = "4.13.0"
3
+ version = "4.13.2"
4
4
  description = "Python commitizen client tool"
5
5
  authors = [{ name = "Santiago Fraire", email = "santiwilly@gmail.com" }]
6
6
  maintainers = [
@@ -1 +0,0 @@
1
- __version__ = "4.13.0"
File without changes
File without changes