Skip to main content

Commitizen plugin that prefixes commit messages with the common path or prefix of staged files.

Project description

cz-path

Python versions PyPI - Version GitHub tag (with filter) License GitHub commits since latest release (by SemVer including pre-releases) CodeQL QA Tests Coverage Status Dependabot Documentation Status mypy uv pytest Ruff Downloads Stargazers pre-commit Prettier

@Tatsh Buy Me A Coffee Libera.Chat Mastodon Follow Patreon

Commitizen plugin that prefixes commit messages with the common path or prefix of staged files.

Installation

pip install cz-path

The package depends on Commitizen, so you get the cz command when you install cz-path.

Usage

Configure Commitizen

Point Commitizen at this plugin by setting name to cz_path in your configuration file (see below). To use this plugin for a single run without changing the config file, pass -n cz_path or --name cz_path to cz.

Create a commit

  1. Use a Git repository. Run cz from the repository root. The plugin opens the Git index in the current directory, so running it elsewhere will not see your project.

  2. Stage your changes with git add. The plugin looks at the staged diff against HEAD to suggest a path prefix. If nothing is staged, Commitizen fails with a message that no staged files were found.

  3. Start Commitizen to write the message and create the commit:

    cz commit
    

    Short form: cz c.

  4. Answer the prompts:

    • Prefix — pick the suggested path prefix (if shown), or project, or (empty) for no prefix.
    • Commit title — the rest of the subject line. The full message is <prefix>: <title>.

Message format

Commits follow <prefix>: <title>, for example module/component: short description of the change. The pattern is a prefix (which may be empty), then a colon and space, then the title.

By default, src/ is stripped from the computed prefix. Set remove_path_prefixes to [] to turn that off, or add other path segments (such as a top-level package name) to strip. You do not need to include a trailing / in each entry.

pyproject.toml

[tool.commitizen]
name = "cz_path"
remove_path_prefixes = ["src", "module_name"]

.cz.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.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

cz_path-0.0.7.tar.gz (8.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

cz_path-0.0.7-py3-none-any.whl (6.2 kB view details)

Uploaded Python 3

File details

Details for the file cz_path-0.0.7.tar.gz.

File metadata

  • Download URL: cz_path-0.0.7.tar.gz
  • Upload date:
  • Size: 8.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for cz_path-0.0.7.tar.gz
Algorithm Hash digest
SHA256 0929af7ecab5cd4af65e8656ad031d61259ac2fc027421d1aaffacbcca358464
MD5 d63009288533dce3b6caa4cd31bf7fa4
BLAKE2b-256 c24f628329c118c4248b9b45988aa79aef8e41b290b790c546e52ac7e5358d12

See more details on using hashes here.

Provenance

The following attestation bundles were made for cz_path-0.0.7.tar.gz:

Publisher: publish.yml on Tatsh/cz-path

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file cz_path-0.0.7-py3-none-any.whl.

File metadata

  • Download URL: cz_path-0.0.7-py3-none-any.whl
  • Upload date:
  • Size: 6.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for cz_path-0.0.7-py3-none-any.whl
Algorithm Hash digest
SHA256 8267528ec7249d9d773b1e0c45c39716635aa7fd34aef892dccbdeff80f7519d
MD5 3c4c4ff182f747b125b4dbda99c01a1a
BLAKE2b-256 1c5db3b96ecc99f397ff1d3721cb87de101650cf25dd195103f6d33024e6a220

See more details on using hashes here.

Provenance

The following attestation bundles were made for cz_path-0.0.7-py3-none-any.whl:

Publisher: publish.yml on Tatsh/cz-path

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page