Skip to content

Add ability to run arbitrary hooks pre/post version bump #292

Closed
@janw

Description

@janw

Description

To use the currently available hook facilities, it is necessary to create a custom cz_ adapter class to use hooks during the version bump / changelog generation. I'd like to be able to run arbitrary hooks (i.e. a shell script or other external executable) from a simple configuration file section. In my specific use-case I'd like for the hooks to be run after the changelog generation and before the version bump in case of cz bump --changelog (see also #290), but I can imaging the following hook locations to be useful:

  1. before changelog
  2. after changelog and before commit and tag
  3. after tag

Possible Solution

Implement hook facilities at the aforementioned locations. They should be configurable via the configuration file for example as follows, allowing for multiple commands to be run at a given location

[[tool.commitizen.hook_begin]]
command = "./update-something.sh"

[[tool.commitizen.hook_begin]]
command = "./do-another-thing.sh"

[[tool.commitizen.hook_before_commit]]
command = "./build-something-based-on-changelog.sh"

[tool.commitizen.hook_end]
command = "./push-artifacts.py"

Given commands should run with useful execution context, such as current and future version as arguments and/or environment variables.


I'd be happy to implement this as well. Cheers.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions