https://github.com/tatsh/cz-path
Commitizen plugin that prefixes commit messages with the common path or prefix of staged files.
https://github.com/tatsh/cz-path
commit-messages commitizen git version-control
Last synced: 4 days ago
JSON representation
Commitizen plugin that prefixes commit messages with the common path or prefix of staged files.
- Host: GitHub
- URL: https://github.com/tatsh/cz-path
- Owner: Tatsh
- License: mit
- Created: 2025-07-14T01:52:54.000Z (9 months ago)
- Default Branch: master
- Last Pushed: 2025-09-22T23:28:54.000Z (6 months ago)
- Last Synced: 2025-09-23T01:14:18.596Z (6 months ago)
- Topics: commit-messages, commitizen, git, version-control
- Language: Python
- Homepage: https://tatsh.github.io/cz-path/
- Size: 2.31 MB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Contributing: CONTRIBUTING.md
- Funding: .github/FUNDING.yml
- License: LICENSE.txt
- Citation: CITATION.cff
- Codeowners: CODEOWNERS
- Security: SECURITY.md
Awesome Lists containing this project
README
# cz-path
[](https://www.python.org/)
[](https://pypi.org/project/cz-path/)
[](https://github.com/Tatsh/cz-path/tags)
[](https://github.com/Tatsh/cz-path/blob/master/LICENSE.txt)
[](https://github.com/Tatsh/cz-path/compare/v0.0.6...master)
[](https://github.com/Tatsh/cz-path/actions/workflows/codeql.yml)
[](https://github.com/Tatsh/cz-path/actions/workflows/qa.yml)
[](https://github.com/Tatsh/cz-path/actions/workflows/tests.yml)
[](https://coveralls.io/github/Tatsh/cz-path?branch=master)
[](https://github.com/dependabot)
[](https://cz-path.readthedocs.org/?badge=latest)
[](https://mypy-lang.org/)
[](https://docs.astral.sh/uv/)
[](https://www.pydocstyle.org/)
[](https://docs.pytest.org)
[](https://github.com/astral-sh/ruff)
[](https://pepy.tech/project/cz-path)
[](https://github.com/Tatsh/cz-path/stargazers)
[](https://pre-commit.com/)
[](https://prettier.io/)
[](https://bsky.app/profile/Tatsh.bsky.social)
[](https://buymeacoffee.com/Tatsh)
[](irc://irc.libera.chat/Tatsh)
[](https://hostux.social/@Tatsh)
[](https://www.patreon.com/Tatsh2)
Commitizen plugin that prefixes commit messages with the common path or prefix of staged files.
## Installation
```shell
pip install cz-path
```
## Usage
Pass `-n cz_path` to `cz` or add it to your configuration file.
By default, `src/` will be removed from any determined prefix. This can be customised by setting
`remove_path_prefixes` to `[]`. You also may want to add other locations such as a module name.
Adding `/` is not required.
### `pyproject.toml`
```toml
[tool.commitizen]
name = "cz_path"
remove_path_prefixes = ["src", "module_name"]
```
### `.cz.json`
```json
{
"commitizen": {
"name": "cz_path",
"remove_path_prefixes": ["src", "module_name"]
}
}
```
### Scenarios
| Staged files | Path prefix | String prefix |
| ---------------------- | ----------- | ------------- |
| `src/a.c`, `src/b.c` | `src` | `src/` |
| `src/a1.c`, `src/a2.c` | `src` | `src/a` |
| `a.c`, `b.c` | (no option) | (no option) |
If no prefix is found amongst the staged files, only the choices `project` and empty will be given.