|
5 | 5 | import questionary
|
6 | 6 | from packaging.version import InvalidVersion, Version
|
7 | 7 |
|
8 |
| -from commitizen import bump, cmd, defaults, factory, git, out |
| 8 | +from commitizen import bump, cmd, defaults, factory, git, hooks, out |
9 | 9 | from commitizen.commands.changelog import Changelog
|
10 | 10 | from commitizen.config import BaseConfig
|
11 | 11 | from commitizen.exceptions import (
|
@@ -58,6 +58,8 @@ def __init__(self, config: BaseConfig, arguments: dict):
|
58 | 58 | self.no_verify = arguments["no_verify"]
|
59 | 59 | self.check_consistency = arguments["check_consistency"]
|
60 | 60 | self.retry = arguments["retry"]
|
| 61 | + self.pre_bump_hooks = self.config.settings["pre_bump_hooks"] |
| 62 | + self.post_bump_hooks = self.config.settings["post_bump_hooks"] |
61 | 63 |
|
62 | 64 | def is_initial_tag(self, current_tag_version: str, is_yes: bool = False) -> bool:
|
63 | 65 | """Check if reading the whole git tree up to HEAD is needed."""
|
@@ -272,6 +274,20 @@ def __call__(self): # noqa: C901
|
272 | 274 |
|
273 | 275 | self.config.set_key("version", str(new_version))
|
274 | 276 |
|
| 277 | + if self.pre_bump_hooks: |
| 278 | + hooks.run( |
| 279 | + self.pre_bump_hooks, |
| 280 | + _env_prefix="CZ_PRE_", |
| 281 | + is_initial=is_initial, |
| 282 | + current_version=current_version, |
| 283 | + current_tag_version=current_tag_version, |
| 284 | + new_version=new_version.public, |
| 285 | + new_tag_version=new_tag_version, |
| 286 | + message=message, |
| 287 | + increment=increment, |
| 288 | + changelog_file_name=changelog_cmd.file_name if self.changelog else None, |
| 289 | + ) |
| 290 | + |
275 | 291 | if is_files_only:
|
276 | 292 | raise ExpectedExit()
|
277 | 293 |
|
@@ -300,6 +316,20 @@ def __call__(self): # noqa: C901
|
300 | 316 | if c.return_code != 0:
|
301 | 317 | raise BumpTagFailedError(c.err)
|
302 | 318 |
|
| 319 | + if self.post_bump_hooks: |
| 320 | + hooks.run( |
| 321 | + self.post_bump_hooks, |
| 322 | + _env_prefix="CZ_POST_", |
| 323 | + was_initial=is_initial, |
| 324 | + previous_version=current_version, |
| 325 | + previous_tag_version=current_tag_version, |
| 326 | + current_version=new_version.public, |
| 327 | + current_tag_version=new_tag_version, |
| 328 | + message=message, |
| 329 | + increment=increment, |
| 330 | + changelog_file_name=changelog_cmd.file_name if self.changelog else None, |
| 331 | + ) |
| 332 | + |
303 | 333 | # TODO: For v3 output this only as diagnostic and remove this if
|
304 | 334 | if self.changelog_to_stdout:
|
305 | 335 | out.diagnostic("Done!")
|
|
0 commit comments