hatch-regex-commit

raw JSON →
0.0.4 verified Fri May 01 auth: no python maintenance

A Hatch plugin that automatically creates a Git commit and tag when bumping the project version using the `hatch version` command. It uses a regex to determine the version string. Version 0.0.4, last released in December 2021; the project appears to be in maintenance mode with no recent updates.

pip install hatch-regex-commit
error TypeError: 'NoneType' object is not subscriptable
cause The regex pattern did not have a named group `version` or the file path is incorrect.
fix
Check that the pattern in pyproject.toml includes (?P<version>...) and that the path points to the correct file.
error ModuleNotFoundError: No module named 'hatch_regex_commit'
cause The plugin is not installed or not in the build-system requires.
fix
Run pip install hatch-regex-commit and add "hatch-regex-commit" to the requires list under [build-system] in pyproject.toml.
error Git command failed: 'git commit' returned 1
cause Git user name or email not configured, or there is nothing to commit.
fix
Set git config user.name and user.email, or ensure the version file has been modified.
breaking This plugin requires Hatch >=1.0.0. Older Hatch versions (pre-1.0) have a different plugin API and will not work.
fix Upgrade Hatch to >=1.0.0 with `pip install --upgrade hatch`.
gotcha The regex pattern MUST contain a named group `(?P<version>...)`; otherwise, the plugin will fail to extract the version.
fix Ensure your pattern includes `(?P<version>...)` exactly as shown in the quickstart.
gotcha The plugin automatically commits and tags. It does not ask for confirmation. Running `hatch version` in a dirty working tree will commit all staged and unstaged changes.
fix Always ensure your working tree is clean or use `git stash` before bumping.

Configure hatch-regex-commit in pyproject.toml and use `hatch version <bump>` to commit and tag automatically.

# pyproject.toml
[build-system]
requires = ["hatchling", "hatch-regex-commit"]
build-backend = "hatchling.build"

[tool.hatch.envs.default]

[tool.hatch.version]
source = "regex"
path = "src/my_package/__init__.py"
pattern = "__version__ = ['\"](?P<version>[^'\"]+)['\"]"

# Run: hatch version patch
# This will bump the version, commit, and tag.