From 78d776955c9aa77e6ce98f26325413ff6ae7f287 Mon Sep 17 00:00:00 2001 From: Yu-Ting Hsiung Date: Mon, 19 Jan 2026 23:23:27 +0800 Subject: [PATCH 01/19] docs: add revision date plugin --- mkdocs.yml | 4 ++++ pyproject.toml | 6 ++++- uv.lock | 61 ++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 70 insertions(+), 1 deletion(-) diff --git a/mkdocs.yml b/mkdocs.yml index 328a601962..85205e2da0 100644 --- a/mkdocs.yml +++ b/mkdocs.yml @@ -103,3 +103,7 @@ markdown_extensions: - name: mermaid class: mermaid format: !!python/name:pymdownx.superfences.fence_code_format + +plugins: + - search + - git-revision-date-localized diff --git a/pyproject.toml b/pyproject.toml index a4a13d1377..855bfb6c72 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -121,7 +121,11 @@ linters = [ "prek>=0.2.28", ] -documentation = ["mkdocs>=1.4.2", "mkdocs-material>=9.1.6"] +documentation = [ + "mkdocs>=1.4.2", + "mkdocs-git-revision-date-localized-plugin>=1.5.0", + "mkdocs-material>=9.1.6", +] script = [ # for scripts/gen_cli_help_screenshots.py diff --git a/uv.lock b/uv.lock index 71951762ae..75732c7ac0 100644 --- a/uv.lock +++ b/uv.lock @@ -221,6 +221,7 @@ dev = [ { name = "ipython", version = "8.37.0", source = { registry = "https://pypi.org/simple" }, marker = "python_full_version < '3.11'" }, { name = "ipython", version = "9.8.0", source = { registry = "https://pypi.org/simple" }, marker = "python_full_version >= '3.11'" }, { name = "mkdocs" }, + { name = "mkdocs-git-revision-date-localized-plugin" }, { name = "mkdocs-material" }, { name = "mypy" }, { name = "poethepoet" }, @@ -245,6 +246,7 @@ dev = [ ] documentation = [ { name = "mkdocs" }, + { name = "mkdocs-git-revision-date-localized-plugin" }, { name = "mkdocs-material" }, ] linters = [ @@ -294,6 +296,7 @@ base = [{ name = "poethepoet", specifier = ">=0.34.0" }] dev = [ { name = "ipython", specifier = ">=8.0" }, { name = "mkdocs", specifier = ">=1.4.2" }, + { name = "mkdocs-git-revision-date-localized-plugin", specifier = ">=1.5.0" }, { name = "mkdocs-material", specifier = ">=9.1.6" }, { name = "mypy", specifier = ">=1.16.0" }, { name = "poethepoet", specifier = ">=0.34.0" }, @@ -318,6 +321,7 @@ dev = [ ] documentation = [ { name = "mkdocs", specifier = ">=1.4.2" }, + { name = "mkdocs-git-revision-date-localized-plugin", specifier = ">=1.5.0" }, { name = "mkdocs-material", specifier = ">=9.1.6" }, ] linters = [ @@ -548,6 +552,30 @@ wheels = [ { url = "https://files.pythonhosted.org/packages/f7/ec/67fbef5d497f86283db54c22eec6f6140243aae73265799baaaa19cd17fb/ghp_import-2.1.0-py3-none-any.whl", hash = "sha256:8337dd7b50877f163d4c0289bc1f1c7f127550241988d568c1db512c4324a619", size = 11034, upload-time = "2022-05-02T15:47:14.552Z" }, ] +[[package]] +name = "gitdb" +version = "4.0.12" +source = { registry = "https://pypi.org/simple" } +dependencies = [ + { name = "smmap" }, +] +sdist = { url = "https://files.pythonhosted.org/packages/72/94/63b0fc47eb32792c7ba1fe1b694daec9a63620db1e313033d18140c2320a/gitdb-4.0.12.tar.gz", hash = "sha256:5ef71f855d191a3326fcfbc0d5da835f26b13fbcba60c32c21091c349ffdb571", size = 394684, upload-time = "2025-01-02T07:20:46.413Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/a0/61/5c78b91c3143ed5c14207f463aecfc8f9dbb5092fb2869baf37c273b2705/gitdb-4.0.12-py3-none-any.whl", hash = "sha256:67073e15955400952c6565cc3e707c554a4eea2e428946f7a4c162fab9bd9bcf", size = 62794, upload-time = "2025-01-02T07:20:43.624Z" }, +] + +[[package]] +name = "gitpython" +version = "3.1.46" +source = { registry = "https://pypi.org/simple" } +dependencies = [ + { name = "gitdb" }, +] +sdist = { url = "https://files.pythonhosted.org/packages/df/b5/59d16470a1f0dfe8c793f9ef56fd3826093fc52b3bd96d6b9d6c26c7e27b/gitpython-3.1.46.tar.gz", hash = "sha256:400124c7d0ef4ea03f7310ac2fbf7151e09ff97f2a3288d64a440c584a29c37f", size = 215371, upload-time = "2026-01-01T15:37:32.073Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/6a/09/e21df6aef1e1ffc0c816f0522ddc3f6dcded766c3261813131c78a704470/gitpython-3.1.46-py3-none-any.whl", hash = "sha256:79812ed143d9d25b6d176a10bb511de0f9c67b1fa641d82097b0ab90398a2058", size = 208620, upload-time = "2026-01-01T15:37:30.574Z" }, +] + [[package]] name = "identify" version = "2.6.16" @@ -908,6 +936,21 @@ wheels = [ { url = "https://files.pythonhosted.org/packages/9f/d4/029f984e8d3f3b6b726bd33cafc473b75e9e44c0f7e80a5b29abc466bdea/mkdocs_get_deps-0.2.0-py3-none-any.whl", hash = "sha256:2bf11d0b133e77a0dd036abeeb06dec8775e46efa526dc70667d8863eefc6134", size = 9521, upload-time = "2023-11-20T17:51:08.587Z" }, ] +[[package]] +name = "mkdocs-git-revision-date-localized-plugin" +version = "1.5.0" +source = { registry = "https://pypi.org/simple" } +dependencies = [ + { name = "babel" }, + { name = "gitpython" }, + { name = "mkdocs" }, + { name = "tzdata", marker = "sys_platform == 'win32'" }, +] +sdist = { url = "https://files.pythonhosted.org/packages/0f/c5/1d3c4e6ddae6230b89d09105cb79de711655e3ebd6745f7a92efea0f5160/mkdocs_git_revision_date_localized_plugin-1.5.0.tar.gz", hash = "sha256:17345ccfdf69a1905dc96fb1070dce82d03a1eb6b0d48f958081a7589ce3c248", size = 460697, upload-time = "2025-10-31T16:11:34.44Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/bc/51/fe0e3fdb16f6eed65c9459d12bae6a4e1f0bb4e2228cb037e7907b002678/mkdocs_git_revision_date_localized_plugin-1.5.0-py3-none-any.whl", hash = "sha256:933f9e35a8c135b113f21bb57610d82e9b7bcc71dd34fb06a029053c97e99656", size = 26153, upload-time = "2025-10-31T16:11:32.987Z" }, +] + [[package]] name = "mkdocs-material" version = "9.7.1" @@ -1468,6 +1511,15 @@ wheels = [ { url = "https://files.pythonhosted.org/packages/b7/ce/149a00dd41f10bc29e5921b496af8b574d8413afcd5e30dfa0ed46c2cc5e/six-1.17.0-py2.py3-none-any.whl", hash = "sha256:4721f391ed90541fddacab5acf947aa0d3dc7d27b2e1e8eda2be8970586c3274", size = 11050, upload-time = "2024-12-04T17:35:26.475Z" }, ] +[[package]] +name = "smmap" +version = "5.0.2" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/44/cd/a040c4b3119bbe532e5b0732286f805445375489fceaec1f48306068ee3b/smmap-5.0.2.tar.gz", hash = "sha256:26ea65a03958fa0c8a1c7e8c7a58fdc77221b8910f6be2131affade476898ad5", size = 22329, upload-time = "2025-01-02T07:14:40.909Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/04/be/d09147ad1ec7934636ad912901c5fd7667e1c858e19d355237db0d0cd5e4/smmap-5.0.2-py3-none-any.whl", hash = "sha256:b30115f0def7d7531d22a0fb6502488d879e75b260a9db4d0819cfb25403af5e", size = 24303, upload-time = "2025-01-02T07:14:38.724Z" }, +] + [[package]] name = "stack-data" version = "0.6.3" @@ -1649,6 +1701,15 @@ wheels = [ { url = "https://files.pythonhosted.org/packages/18/67/36e9267722cc04a6b9f15c7f3441c2363321a3ea07da7ae0c0707beb2a9c/typing_extensions-4.15.0-py3-none-any.whl", hash = "sha256:f0fa19c6845758ab08074a0cfa8b7aecb71c999ca73d62883bc25cc018c4e548", size = 44614, upload-time = "2025-08-25T13:49:24.86Z" }, ] +[[package]] +name = "tzdata" +version = "2025.3" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/5e/a7/c202b344c5ca7daf398f3b8a477eeb205cf3b6f32e7ec3a6bac0629ca975/tzdata-2025.3.tar.gz", hash = "sha256:de39c2ca5dc7b0344f2eba86f49d614019d29f060fc4ebc8a417896a620b56a7", size = 196772, upload-time = "2025-12-13T17:45:35.667Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/c7/b0/003792df09decd6849a5e39c28b513c06e84436a54440380862b5aeff25d/tzdata-2025.3-py2.py3-none-any.whl", hash = "sha256:06a47e5700f3081aab02b2e513160914ff0694bce9947d6b76ebd6bf57cfc5d1", size = 348521, upload-time = "2025-12-13T17:45:33.889Z" }, +] + [[package]] name = "urllib3" version = "2.6.2" From 94d66dedb9f501ecc081485e231e85cfee0a296c Mon Sep 17 00:00:00 2001 From: YU HAN-CHENG Date: Sat, 31 Jan 2026 12:01:14 +0800 Subject: [PATCH 02/19] docs(READMD.md): add star history to README (#1824) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: 余翰承 --- docs/README.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/docs/README.md b/docs/README.md index 97cd2880d7..313d5494d2 100644 --- a/docs/README.md +++ b/docs/README.md @@ -303,6 +303,11 @@ After installation, you can verify the completion is working by: For more detailed information about argcomplete configuration and troubleshooting, visit the [argcomplete documentation](https://kislyuk.github.io/argcomplete/). +## Star History + +[![Star History Chart](https://api.star-history.com/svg?repos=commitizen-tools/commitizen)](https://star-history.com/#commitizen-tools/commitizen) + + ## Sponsors These are our cool sponsors! From 1eb8ffff6bc790e37a5f5dd96ef2a62f2d4ae88b Mon Sep 17 00:00:00 2001 From: Tim Hsiung Date: Sat, 31 Jan 2026 12:05:17 +0800 Subject: [PATCH 03/19] docs(github_actions): improve github action tutorial page (#1782) --- docs/tutorials/github_actions.md | 169 +++++++++++++++++++++---------- 1 file changed, 117 insertions(+), 52 deletions(-) diff --git a/docs/tutorials/github_actions.md b/docs/tutorials/github_actions.md index f15b62fbaa..c3b06336a9 100644 --- a/docs/tutorials/github_actions.md +++ b/docs/tutorials/github_actions.md @@ -1,26 +1,49 @@ ## Create a new release with GitHub Actions -### Automatic bumping of version +This guide shows you how to automatically bump versions, create changelogs, and publish releases using Commitizen in GitHub Actions. -To execute `cz bump` in your CI, and push the new commit and -the new tag, back to your master branch, we have to: +### Prerequisites -1. Create a personal access token. [Follow the instructions here](https://help.github.com/en/github/authenticating-to-github/creating-a-personal-access-token-for-the-command-line#creating-a-token). And copy the generated key -2. Create a secret called `PERSONAL_ACCESS_TOKEN`, with the copied key, by going to your - project repository and then `Settings > Secrets > Add new secret`. -3. In your repository create a new file `.github/workflows/bumpversion.yml` - with the following content. +Before setting up the workflow, you'll need: -!!! warning - If you use `GITHUB_TOKEN` instead of `PERSONAL_ACCESS_TOKEN`, the job won't trigger another workflow. It's like using `[skip ci]` in other CI's. +1. A personal access token with repository write permissions +2. Commitizen configured in your project (see [configuration documentation](../config/configuration_file.md)) -```yaml +### Automatic version bumping + +To automatically execute `cz bump` in your CI and push the new commit and tag back to your repository, follow these steps: + +#### Step 1: Create a personal access token + +1. Go to [GitHub Settings > Developer settings > Personal access tokens](https://github.com/settings/tokens) +2. Click "Generate new token (classic)" +3. Give it a descriptive name (e.g., "Commitizen CI") +4. Select the `repo` scope to grant full repository access +5. Click "Generate token" and **copy the token immediately** (you won't be able to see it again) + +!!! warning "Important: Use Personal Access Token, not GITHUB_TOKEN" + If you use `GITHUB_TOKEN` instead of `PERSONAL_ACCESS_TOKEN`, the workflow won't trigger another workflow run. This is a GitHub security feature to prevent infinite loops. The `GITHUB_TOKEN` is treated like using `[skip ci]` in other CI systems. + +#### Step 2: Add the token as a repository secret + +1. Go to your repository on GitHub +2. Navigate to `Settings > Secrets and variables > Actions` +3. Click "New repository secret" +4. Name it `PERSONAL_ACCESS_TOKEN` +5. Paste the token you copied in Step 1 +6. Click "Add secret" + +#### Step 3: Create the workflow file + +Create a new file `.github/workflows/bumpversion.yml` in your repository with the following content: + +```yaml title=".github/workflows/bumpversion.yml" name: Bump version on: push: branches: - - master + - master # or 'main' if that's your default branch jobs: bump-version: @@ -29,7 +52,7 @@ jobs: name: "Bump version and create changelog with commitizen" steps: - name: Check out - uses: actions/checkout@v3 + uses: actions/checkout@v6 with: token: "${{ secrets.PERSONAL_ACCESS_TOKEN }}" fetch-depth: 0 @@ -39,62 +62,106 @@ jobs: github_token: ${{ secrets.PERSONAL_ACCESS_TOKEN }} ``` -Push to master and that's it. +#### How it works + +- **Trigger**: The workflow runs on every push to the `master` branch (or `main` if you change it) +- **Conditional check**: The `if` condition prevents infinite loops by skipping the job if the commit message starts with `bump:` +- **Checkout**: Uses your personal access token to check out the repository with full history (`fetch-depth: 0`) +- **Bump**: The `commitizen-action` automatically: + - Determines the version increment based on your commit messages + - Updates version files (as configured in your `pyproject.toml` or other config) + - Creates a new git tag + - Generates/updates the changelog + - Pushes the commit and tag back to the repository + +Once you push this workflow file to your repository, it will automatically run on the next push to your default branch. + +Check out [commitizen-action](https://github.com/commitizen-tools/commitizen-action) for more details. ### Creating a GitHub release -You can modify the previous action. - -Add the variable `changelog_increment_filename` in the `commitizen-action`, specifying -where to output the content of the changelog for the newly created version. - -And then add a step using a GitHub action to create the release: `softprops/action-gh-release` - -Commitizen action creates an env variable called `REVISION`, containing the -newly created version. - -```yaml -- name: Create bump and changelog - uses: commitizen-tools/commitizen-action@master - with: - github_token: ${{ secrets.PERSONAL_ACCESS_TOKEN }} - changelog_increment_filename: body.md -- name: Release - uses: softprops/action-gh-release@v1 - with: - body_path: "body.md" - tag_name: ${{ env.REVISION }} - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} +To automatically create a GitHub release when a new version is bumped, you can extend the workflow above. + +The `commitizen-action` creates an environment variable called `REVISION` containing the newly created version. You can use this to create a release with the changelog content. + +```yaml title=".github/workflows/bumpversion.yml" +name: Bump version + +on: + push: + branches: + - master # or 'main' if that's your default branch + +jobs: + bump-version: + if: "!startsWith(github.event.head_commit.message, 'bump:')" + runs-on: ubuntu-latest + name: "Bump version and create changelog with commitizen" + steps: + - name: Check out + uses: actions/checkout@v6 + with: + token: "${{ secrets.PERSONAL_ACCESS_TOKEN }}" + fetch-depth: 0 + - name: Create bump and changelog + uses: commitizen-tools/commitizen-action@master + with: + github_token: ${{ secrets.PERSONAL_ACCESS_TOKEN }} + changelog_increment_filename: body.md + - name: Release + uses: ncipollo/release-action@v1 + with: + tag: v${{ env.REVISION }} + bodyFile: "body.md" + skipIfReleaseExists: true + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} ``` -### Publishing a python package +You can find the complete workflow in our repository at [bumpversion.yml](https://github.com/commitizen-tools/commitizen/blob/master/.github/workflows/bumpversion.yml). -Once the new tag is created, triggering an automatic publish command would be desired. +### Publishing a Python package -In order to do so, the credential needs to be added with the information of our PyPI account. +After a new version tag is created by the bump workflow, you can automatically publish your package to PyPI. -Instead of using username and password, we suggest using [api token](https://pypi.org/help/#apitoken) generated from PyPI. +#### Step 1: Create a PyPI API token -After generate api token, use the token as the PyPI password and `__token__` as the username. +1. Go to [PyPI Account Settings](https://pypi.org/manage/account/) +2. Scroll to the "API tokens" section +3. Click "Add API token" +4. Give it a name (e.g., "GitHub Actions") +5. Set the scope (project-specific or account-wide) +6. Click "Add token" and **copy the token immediately** -Go to `Settings > Secrets > Add new secret` and add the secret: `PYPI_PASSWORD`. +!!! tip "Using trusted publishing (recommended)" + Instead of API tokens, consider using [PyPI trusted publishing](https://docs.pypi.org/trusted-publishers/) with OpenID Connect (OIDC). This is more secure as it doesn't require storing secrets. The `pypa/gh-action-pypi-publish` action supports trusted publishing when you configure it in your PyPI project settings. -Create a file in `.github/workflows/pythonpublish.yaml` with the following content: +#### Step 2: Add the token as a repository secret -```yaml +1. Go to your repository on GitHub +2. Navigate to `Settings > Secrets and variables > Actions` +3. Click "New repository secret" +4. Name it `PYPI_PASSWORD` +5. Paste the PyPI token +6. Click "Add secret" + +#### Step 3: Create the publish workflow + +Create a new file `.github/workflows/pythonpublish.yml` that triggers on tag pushes: + +```yaml title=".github/workflows/pythonpublish.yml" name: Upload Python Package on: push: tags: - - "*" # Will trigger for every tag, alternative: 'v*' + - "*" # Will trigger for every tag, alternative: 'v*' jobs: deploy: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v6 with: fetch-depth: 0 - name: Set up Python @@ -118,9 +185,7 @@ jobs: run: poetry publish --build ``` -Notice that we are using poetry to publish the package. - - -You can also use [pypa/gh-action-pypi-publish](https://github.com/pypa/gh-action-pypi-publish) to publish your package. +This workflow uses Poetry to build and publish the package. You can find the complete workflow in our repository at [pythonpublish.yml](https://github.com/commitizen-tools/commitizen/blob/master/.github/workflows/pythonpublish.yml). -Push the changes and that's it. +!!! note "Alternative publishing methods" + You can also use [pypa/gh-action-pypi-publish](https://github.com/pypa/gh-action-pypi-publish) or other build tools like `setuptools`, `flit`, or `hatchling` to publish your package. From 5b02acfc1652bd516ae8901ba2cc858047aa1a9b Mon Sep 17 00:00:00 2001 From: Tim Hsiung Date: Sat, 31 Jan 2026 12:05:41 +0800 Subject: [PATCH 04/19] docs(changelog): fix minor mistakes in changelog documentation, improve fluency (#1792) --- docs/commands/changelog.md | 75 +++++++++++++++++++------------------- 1 file changed, 37 insertions(+), 38 deletions(-) diff --git a/docs/commands/changelog.md b/docs/commands/changelog.md index 3f2425a51f..da40eb6fbe 100644 --- a/docs/commands/changelog.md +++ b/docs/commands/changelog.md @@ -1,6 +1,6 @@ ## About -This command will generate a changelog following the committing rules established. +Generates a changelog following the committing rules established. !!! tip To create the changelog automatically on bump, add the setting [update_changelog_on_bump](../config/bump.md#update_changelog_on_bump) @@ -20,7 +20,7 @@ This command will generate a changelog following the committing rules establishe # Generate full changelog cz changelog -# or use the alias +# Or use the alias cz ch # Get the changelog for the given version @@ -30,7 +30,7 @@ cz changelog 0.3.0 --dry-run cz changelog 0.3.0..0.4.0 --dry-run ``` -## Constrains +## Constraints Changelog generation is constrained only to **markdown** files. @@ -46,30 +46,30 @@ These are the variables used by the changelog generator. - ****: ``` -It will create a full block like above per version found in the tags. -And it will create a list of the commits found. -The `change_type` and the `scope` are optional, they don't need to be provided, -but if your regex does, they will be rendered. +Creates a full block like above per version found in the tags, and a list of the commits found. +The `change_type` and `scope` are optional and don't need to be provided, +but if your regex parses them, they will be rendered. -The format followed by the changelog is the one from [keep a changelog][keepachangelog] +The format followed by the changelog is from [keep a changelog][keepachangelog] and the following variables are expected: | Variable | Description | Source | | ------------- | ---------------------------------------------------------------------------------------------- | -------------- | | `version` | Version number which should follow [semver][semver] | `tags` | -| `date` | Date in which the tag was created | `tags` | +| `date` | Date when the tag was created | `tags` | | `change_type` | The group where the commit belongs to, this is optional. Example: fix | `commit regex` | -| `message`\* | Information extracted from the commit message | `commit regex` | +| `message` | Information extracted from the commit message | `commit regex` | | `scope` | Contextual information. Should be parsed using the regex from the message, it will be **bold** | `commit regex` | -| `breaking` | Whether is a breaking change or not | `commit regex` | +| `breaking` | Whether it is a breaking change or not | `commit regex` | -- **required**: is the only one required to be parsed by the regex +!!! note + `message` is the only variable required to be parsed by the regex. ## Command line options ### `--extras` -Provides your own changelog extra variables by using the `extras` settings or the `--extra/-e` parameter. +Provide your own changelog extra variables by using the `extras` settings or the `--extra/-e` parameter. ```bash cz changelog --extra key=value -e short="quoted value" @@ -77,9 +77,9 @@ cz changelog --extra key=value -e short="quoted value" ### `--file-name` -This value can be updated in the configuration file with the key `changelog_file` under `tools.commitizen` +This value can be updated in the configuration file with the key `changelog_file` under `tool.commitizen`. -Specify the name of the output file, remember that changelog only works with Markdown. +Specify the name of the output file. Note that changelog generation only works with Markdown files. ```bash cz changelog --file-name="CHANGES.md" @@ -87,27 +87,27 @@ cz changelog --file-name="CHANGES.md" ### `--incremental` -This flag can be set in the configuration file with the key `changelog_incremental` under `tools.commitizen` +This flag can be set in the configuration file with the key `changelog_incremental` under `tool.commitizen` Benefits: -- Build from the latest version found in changelog, this is useful if you have a different changelog and want to use commitizen +- Build from the latest version found in changelog. This is useful if you have an existing changelog and want to use commitizen to extend it. - Update unreleased area -- Allows users to manually touch the changelog without being rewritten. +- Allows users to manually edit the changelog without it being completely rewritten. ```bash cz changelog --incremental ``` ```toml -[tools.commitizen] +[tool.commitizen] # ... changelog_incremental = true ``` ### `--start-rev` -This value can be set in the configuration file with the key `changelog_start_rev` under `tools.commitizen` +This value can be set in the configuration file with the key `changelog_start_rev` under `tool.commitizen` Start from a given git rev to generate the changelog. Commits before that rev will not be considered. This is especially useful for long-running projects adopting conventional commits, where old commit messages might fail to be parsed for changelog generation. @@ -116,43 +116,43 @@ cz changelog --start-rev="v0.2.0" ``` ```toml -[tools.commitizen] +[tool.commitizen] # ... changelog_start_rev = "v0.2.0" ``` ### `--merge-prerelease` -This flag can be set in the configuration file with the key `changelog_merge_prerelease` under `tools.commitizen` +This flag can be set in the configuration file with the key `changelog_merge_prerelease` under `tool.commitizen` -Collects changes from prereleases into the next non-prerelease. This means that if you have a prerelease version, and then a normal release, the changelog will show the prerelease changes as part of the changes of the normal release. If not set, it will include prereleases in the changelog. +Collects changes from prereleases into the next non-prerelease version. If you have a prerelease version followed by a normal release, the changelog will show the prerelease changes as part of the normal release. If not set, prereleases will be included as separate entries in the changelog. ```bash cz changelog --merge-prerelease ``` ```toml -[tools.commitizen] +[tool.commitizen] # ... changelog_merge_prerelease = true ``` ### `--template` -Provides your own changelog jinja template by using the `template` settings or the `--template` parameter. +Provide your own changelog Jinja template by using the `template` settings or the `--template` parameter. + +```bash +cz changelog --template="path/to/template.j2" +``` ### `--unreleased-version` -There is usually a chicken and egg situation when automatically -bumping the version and creating the changelog. -If you bump the version first, you have no changelog, you have to -create it later, and it won't be included in -the release of the created version. +There is usually a chicken-and-egg situation when automatically bumping the version and creating the changelog: -If you create the changelog before bumping the version, then you -usually don't have the latest tag, and the _Unreleased_ title appears. +- If you bump the version first, you have no changelog yet, and it won't be included in the release of the created version. +- If you create the changelog before bumping the version, you usually don't have the latest tag, and the _Unreleased_ title appears. -By introducing `--unreleased-version` you can prevent this situation. +By using `--unreleased-version`, you can prevent this situation. Before bumping you can run: @@ -160,12 +160,11 @@ Before bumping you can run: cz changelog --unreleased-version="v1.0.0" ``` -Remember to use the tag instead of the raw version number +Remember to use the tag format instead of the raw version number. -For example if the format of your tag includes a `v` (`v1.0.0`), then you should use that, -if your tag is the same as the raw version, then ignore this. +For example, if your tag format includes a `v` prefix (e.g., `v1.0.0`), use that format. If your tag is the same as the raw version (e.g., `1.0.0`), use the raw version. -Alternatively you can directly bump the version and create the changelog by doing +Alternatively, you can directly bump the version and create the changelog by running: ```bash cz bump --changelog @@ -175,7 +174,7 @@ cz bump --changelog Supported hook methods: -- Per parsed message: Useful to add links +- Per parsed message: Useful to add links to commits or issues - End of changelog generation: Useful to send Slack or chat messages, or notify another department Read more about hooks in the [customization page][customization] From 0497ef20b8cbfb2f2bce865753f5861ad09333e4 Mon Sep 17 00:00:00 2001 From: Tim Hsiung Date: Sat, 31 Jan 2026 12:07:30 +0800 Subject: [PATCH 05/19] docs(contributing): add pull request guideline and add notes about AI assisted contributions (#1778) --- .github/pull_request_template.md | 36 +++++++--- docs/{ => contributing}/contributing.md | 4 +- docs/{ => contributing}/contributing_tldr.md | 2 + docs/contributing/pull_request.md | 71 ++++++++++++++++++++ mkdocs.yml | 6 +- 5 files changed, 106 insertions(+), 13 deletions(-) rename docs/{ => contributing}/contributing.md (96%) rename docs/{ => contributing}/contributing_tldr.md (97%) create mode 100644 docs/contributing/pull_request.md diff --git a/.github/pull_request_template.md b/.github/pull_request_template.md index 061dce44cb..87189d131c 100644 --- a/.github/pull_request_template.md +++ b/.github/pull_request_template.md @@ -9,7 +9,19 @@ Please fill in the following content to let us know better about this change. ## Checklist -- [ ] I have read the [contributing guidelines](https://commitizen-tools.github.io/commitizen/contributing/) +- [ ] I have read the [contributing guidelines](https://commitizen-tools.github.io/commitizen/contributing/contributing) + +### Was generative AI tooling used to co-author this PR? + + + +- [ ] Yes (please specify the tool below) + + ### Code Changes @@ -23,25 +35,31 @@ Please fill in the following content to let us know better about this change. - [ ] Update the documentation for the changes ### Documentation Changes + + - [ ] Run `uv run poe doc` locally to ensure the documentation pages renders correctly -- [ ] Check and fix any broken links (internal or external) in the documentation +- [ ] Check and fix any broken links (internal or external) -> When running `uv run poe doc`, any broken internal documentation links will be reported in the console output like this: -> -> ```text -> INFO - Doc file 'config.md' contains a link 'commands/bump.md#-post_bump_hooks', but the doc 'commands/bump.md' does not contain an anchor '#-post_bump_hooks'. -> ``` + ## Expected Behavior ## Steps to Test This Pull Request - +3. ... +--> ## Additional Context diff --git a/docs/contributing.md b/docs/contributing/contributing.md similarity index 96% rename from docs/contributing.md rename to docs/contributing/contributing.md index 827dfc7ac2..446410533c 100644 --- a/docs/contributing.md +++ b/docs/contributing/contributing.md @@ -1,10 +1,10 @@ -## Contributing to Commitizen +# Contributing to Commitizen First, thank you for taking the time to contribute! 🎉 Your contributions help make Commitizen better for everyone. When contributing to Commitizen, we encourage you to: -1. First, check out the [issues](https://github.com/commitizen-tools/commitizen/issues) and [Features we won't add](features_wont_add.md) to see if there's already a discussion about the change you wish to make. +1. First, check out the [issues](https://github.com/commitizen-tools/commitizen/issues) and [Features we won't add](../features_wont_add.md) to see if there's already a discussion about the change you wish to make. 2. If there's no discussion, [create an issue](https://github.com/commitizen-tools/commitizen/issues/new) to discuss your proposed changes. 3. Follow our [development workflow](#development-workflow) and guidelines below. diff --git a/docs/contributing_tldr.md b/docs/contributing/contributing_tldr.md similarity index 97% rename from docs/contributing_tldr.md rename to docs/contributing/contributing_tldr.md index 91f49d1ca4..af350d2bb7 100644 --- a/docs/contributing_tldr.md +++ b/docs/contributing/contributing_tldr.md @@ -1,3 +1,5 @@ +# Contributing TL;DR + Feel free to send a PR to update this file if you find anything useful. 🙇 ## Environment diff --git a/docs/contributing/pull_request.md b/docs/contributing/pull_request.md new file mode 100644 index 0000000000..4682496b4c --- /dev/null +++ b/docs/contributing/pull_request.md @@ -0,0 +1,71 @@ +# Pull Request Guidelines + +This document outlines important guidelines to follow when creating a pull request. + +## Before Creating a Pull Request + +1. **Check Existing Issues**: Ensure there's a related issue or discussion for your changes. If not, create one first to discuss the proposed changes. +2. **Follow the Development Workflow**: Make sure you've followed all steps in the [contributing guidelines](contributing.md). + +## Making Changes + +When adding new code, match the existing coding style in the file you're modifying. Consistency within a file and throughout the project is crucial for maintainability. + +## Following PR Description Template Instructions + +The PR description template includes a checklist and specific requirements. Please: + +1. **Complete the Checklist**: Check off all applicable items before requesting review. +2. **Provide Clear Descriptions**: Clearly describe what the change does, expected behavior, and steps to test. +3. **Respond to Feedback**: Carefully read maintainer feedback and address all points raised. Ask for clarification if something is unclear. + +## AI-Assisted Contributions + +We welcome contributions that use AI tools for assistance, but we have strict quality standards to maintain code quality and avoid "AI spaghetti code." + +!!! note + Most of our new documentation changes are, of course, generated by AI, but we still need to review it and make sure it's correct. + +![when bro's code is filled with "🔥 🚀 💥 ❌ ✅"](https://images3.memedroid.com/images/UPLOADED78/69501f1c23cab.webp) + +### Guidelines for AI-Assisted PRs + +1. **Review and Refine**: Thoroughly review and understand all AI-generated code. Refactor to match our project's style and remove unnecessary complexity. +2. **Test Thoroughly**: Don't assume AI-generated code works—test it extensively with comprehensive test cases and manual testing when possible. +3. **Understand the Code**: You should be able to explain every line. If you don't understand something, learn about it or rewrite it. Maintainers may ask you to explain your code. +4. **Avoid Common Pitfalls**: + - Over-engineering (simplify when possible) + - Inconsistent style (ensure consistency with our standards) + - Unnecessary dependencies + - Copy-paste without adaptation + - Verbose or obvious comments +5. **Code Quality Still Matters**: AI assistance doesn't excuse poor code quality. All code must pass linting, type checking, and follow best practices. +6. **Be Transparent**: **Mention AI assistance in the PR description**. Code quality standards remain the same regardless of how the code was written. + +!!! warning "Consequences of Poor AI-Assisted Contributions" + Maintainers who identify low-quality AI-generated code or copy-pasted responses will have no choice but to close the related PRs. This adds unnecessary burden on maintainers and doesn't help the project. Additionally, the contributor's reputation is impacted as maintainers may lose confidence and might restrict the user from making further contributions. + +### What We Consider "AI Spaghetti" + +Red flags that may result in PR rejection or requests for significant refactoring: + +- Overly complex solutions when simpler ones exist +- Unnecessary abstractions or design patterns +- Code that's difficult to understand or maintain +- Missing or inadequate tests +- Copy-pasted code blocks that don't fit the project structure +- Excessive comments explaining obvious things + +**Remember**: If you use AI tools, you're still responsible for the quality of the final code. Use AI as a starting point, not a final solution. + +## Commenting on the PR + +When commenting on the PR: + +- Address the feedback points raised by maintainers +- Ask questions if something is unclear +- **Do not** just copy-paste AI-generated responses + - Maintainers want to see your thought process and understanding of the codebase + - Maintainers and other contributors can tell if you're just copying and pasting AI-generated responses + +Thank you for helping make Commitizen better! 🎉 diff --git a/mkdocs.yml b/mkdocs.yml index 85205e2da0..a38dcd276d 100644 --- a/mkdocs.yml +++ b/mkdocs.yml @@ -83,8 +83,10 @@ nav: - "third-party-plugins/cz-legacy.md" - "third-party-plugins/cz-path.md" - "third-party-plugins/github-jira-conventional.md" - - Contributing: "contributing.md" - - Contributing TL;DR: "contributing_tldr.md" + - Contributing: + - "contributing/contributing_tldr.md" + - "contributing/contributing.md" + - "contributing/pull_request.md" - "history.md" - Resources: "external_links.md" From 0c53ecd7fdeb6e1b62ed739218fc6964b97b63b8 Mon Sep 17 00:00:00 2001 From: Yu-Ting Hsiung Date: Sat, 31 Jan 2026 11:51:22 +0800 Subject: [PATCH 06/19] refactor(bump): fix unbounded variable type issue --- commitizen/commands/bump.py | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-) diff --git a/commitizen/commands/bump.py b/commitizen/commands/bump.py index f6637b5c74..affe2bd358 100644 --- a/commitizen/commands/bump.py +++ b/commitizen/commands/bump.py @@ -306,6 +306,7 @@ def __call__(self) -> None: ) updated_files: list[str] = [] + changelog_file_name = None dry_run = self.arguments["dry_run"] if self.changelog_flag: changelog_args = { @@ -318,12 +319,11 @@ def __call__(self) -> None: "during_version_bump": self.arguments["prerelease"] is None, } if self.changelog_to_stdout: - changelog_cmd = Changelog( - self.config, - {**changelog_args, "dry_run": True}, # type: ignore[typeddict-item] - ) try: - changelog_cmd() + Changelog( + self.config, + {**changelog_args, "dry_run": True}, # type: ignore[typeddict-item] + )() except DryRunExit: pass @@ -332,7 +332,8 @@ def __call__(self) -> None: {**changelog_args, "file_name": self.file_name}, # type: ignore[typeddict-item] ) changelog_cmd() - updated_files.append(changelog_cmd.file_name) + changelog_file_name = changelog_cmd.file_name + updated_files.append(changelog_file_name) # Do not perform operations over files or git. if dry_run: @@ -361,9 +362,7 @@ def __call__(self) -> None: new_tag_version=new_tag_version, message=message, increment=increment, - changelog_file_name=changelog_cmd.file_name - if self.changelog_flag - else None, + changelog_file_name=changelog_file_name, ) if self.arguments["files_only"]: @@ -419,9 +418,7 @@ def __call__(self) -> None: current_tag_version=new_tag_version, message=message, increment=increment, - changelog_file_name=changelog_cmd.file_name - if self.changelog_flag - else None, + changelog_file_name=changelog_file_name, ) # TODO: For v3 output this only as diagnostic and remove this if From e5de7e5027030e2701f1782a31fc348653833af7 Mon Sep 17 00:00:00 2001 From: Yu-Ting Hsiung Date: Tue, 6 Jan 2026 22:34:47 +0800 Subject: [PATCH 07/19] fix(cli): capitalize the first characters of help texts and fix minor grammar errors --- commitizen/cli.py | 203 +++++++++--------- ...ion_when_use_help_option_py_3_10_bump_.txt | 88 ++++---- ...hen_use_help_option_py_3_10_changelog_.txt | 40 ++-- ...on_when_use_help_option_py_3_10_check_.txt | 29 +-- ...n_when_use_help_option_py_3_10_commit_.txt | 29 +-- ..._when_use_help_option_py_3_10_example_.txt | 2 +- ...ion_when_use_help_option_py_3_10_info_.txt | 2 +- ...ion_when_use_help_option_py_3_10_init_.txt | 2 +- ...ption_when_use_help_option_py_3_10_ls_.txt | 2 +- ...n_when_use_help_option_py_3_10_schema_.txt | 2 +- ..._when_use_help_option_py_3_10_version_.txt | 16 +- ...ion_when_use_help_option_py_3_11_bump_.txt | 88 ++++---- ...hen_use_help_option_py_3_11_changelog_.txt | 40 ++-- ...on_when_use_help_option_py_3_11_check_.txt | 29 +-- ...n_when_use_help_option_py_3_11_commit_.txt | 29 +-- ..._when_use_help_option_py_3_11_example_.txt | 2 +- ...ion_when_use_help_option_py_3_11_info_.txt | 2 +- ...ion_when_use_help_option_py_3_11_init_.txt | 2 +- ...ption_when_use_help_option_py_3_11_ls_.txt | 2 +- ...n_when_use_help_option_py_3_11_schema_.txt | 2 +- ..._when_use_help_option_py_3_11_version_.txt | 16 +- ...ion_when_use_help_option_py_3_12_bump_.txt | 88 ++++---- ...hen_use_help_option_py_3_12_changelog_.txt | 40 ++-- ...on_when_use_help_option_py_3_12_check_.txt | 29 +-- ...n_when_use_help_option_py_3_12_commit_.txt | 29 +-- ..._when_use_help_option_py_3_12_example_.txt | 2 +- ...ion_when_use_help_option_py_3_12_info_.txt | 2 +- ...ion_when_use_help_option_py_3_12_init_.txt | 2 +- ...ption_when_use_help_option_py_3_12_ls_.txt | 2 +- ...n_when_use_help_option_py_3_12_schema_.txt | 2 +- ..._when_use_help_option_py_3_12_version_.txt | 16 +- ...ion_when_use_help_option_py_3_13_bump_.txt | 88 ++++---- ...hen_use_help_option_py_3_13_changelog_.txt | 40 ++-- ...on_when_use_help_option_py_3_13_check_.txt | 29 +-- ...n_when_use_help_option_py_3_13_commit_.txt | 29 +-- ..._when_use_help_option_py_3_13_example_.txt | 2 +- ...ion_when_use_help_option_py_3_13_info_.txt | 2 +- ...ion_when_use_help_option_py_3_13_init_.txt | 2 +- ...ption_when_use_help_option_py_3_13_ls_.txt | 2 +- ...n_when_use_help_option_py_3_13_schema_.txt | 2 +- ..._when_use_help_option_py_3_13_version_.txt | 16 +- ...ion_when_use_help_option_py_3_14_bump_.txt | 88 ++++---- ...hen_use_help_option_py_3_14_changelog_.txt | 40 ++-- ...on_when_use_help_option_py_3_14_check_.txt | 29 +-- ...n_when_use_help_option_py_3_14_commit_.txt | 29 +-- ..._when_use_help_option_py_3_14_example_.txt | 2 +- ...ion_when_use_help_option_py_3_14_info_.txt | 2 +- ...ion_when_use_help_option_py_3_14_init_.txt | 2 +- ...ption_when_use_help_option_py_3_14_ls_.txt | 2 +- ...n_when_use_help_option_py_3_14_schema_.txt | 2 +- ..._when_use_help_option_py_3_14_version_.txt | 16 +- 51 files changed, 643 insertions(+), 620 deletions(-) diff --git a/commitizen/cli.py b/commitizen/cli.py index 364bc93f85..99c36f8e4c 100644 --- a/commitizen/cli.py +++ b/commitizen/cli.py @@ -67,7 +67,7 @@ def __call__( { "name": ["--template", "-t"], "help": ( - "changelog template file name (relative to the current working directory)" + "Changelog template file name (relative to the current working directory)." ), }, { @@ -75,7 +75,7 @@ def __call__( "action": ParseKwargs, "dest": "extras", "metavar": "EXTRA", - "help": "a changelog extra variable (in the form 'key=value')", + "help": "Changelog extra variables (in the form 'key=value').", }, ) @@ -89,18 +89,18 @@ def __call__( "arguments": [ { "name": "--config", - "help": "the path of configuration file", + "help": "The path to the configuration file.", }, - {"name": "--debug", "action": "store_true", "help": "use debug mode"}, + {"name": "--debug", "action": "store_true", "help": "Use debug mode."}, { "name": ["-n", "--name"], - "help": "use the given commitizen (default: cz_conventional_commits)", + "help": "Use the given commitizen (default: cz_conventional_commits).", }, { "name": ["-nr", "--no-raise"], "type": str, "required": False, - "help": "comma separated error codes that won't raise error, e.g: cz -nr 1,2,3 bump. See codes at https://commitizen-tools.github.io/commitizen/exit_codes/", + "help": "Comma-separated error codes that won't raise error, e.g., cz -nr 1,2,3 bump. See codes at https://commitizen-tools.github.io/commitizen/exit_codes/", }, ], "subcommands": { @@ -109,157 +109,157 @@ def __call__( "commands": [ { "name": ["init"], - "description": "init commitizen configuration", - "help": "init commitizen configuration", + "description": "Initialize commitizen configuration", + "help": "Initialize commitizen configuration.", "func": commands.Init, }, { "name": ["commit", "c"], - "description": "create new commit", - "help": "create new commit", + "description": "Create new commit", + "help": "Create new commit.", "func": commands.Commit, "arguments": [ { "name": ["--retry"], "action": "store_true", - "help": "retry last commit", + "help": "Retry the last commit.", }, { "name": ["--no-retry"], "action": "store_true", "default": False, - "help": "skip retry if retry_after_failure is set to true", + "help": "Skip retry if --retry or `retry_after_failure` is set to true.", }, { "name": "--dry-run", "action": "store_true", - "help": "show output to stdout, no commit, no modified files", + "help": "Perform a dry run, without committing or modifying files.", }, { "name": "--write-message-to-file", "type": Path, "metavar": "FILE_PATH", - "help": "write message to file before committing (can be combined with --dry-run)", + "help": "Write message to FILE_PATH before committing (can be used with --dry-run).", }, { "name": ["-s", "--signoff"], "action": "store_true", - "help": "Deprecated, use 'cz commit -- -s' instead", + "help": "Deprecated, use `cz commit -- -s` instead.", }, { "name": ["-a", "--all"], "action": "store_true", - "help": "Tell the command to automatically stage files that have been modified and deleted, but new files you have not told Git about are not affected.", + # The help text aligns with the description of git commit --all + "help": "Automatically stage files that have been modified and deleted, but new files you have not told Git about are not affected.", }, { "name": ["-e", "--edit"], "action": "store_true", "default": False, - "help": "edit the commit message before committing", + "help": "Edit the commit message before committing.", }, { "name": ["-l", "--message-length-limit"], "type": int, - "help": "length limit of the commit message; 0 for no limit", + "help": "Set the length limit of the commit message; 0 for no limit.", }, { "name": ["--"], "action": "store_true", "dest": "double_dash", - "help": "Positional arguments separator (recommended)", + "help": "Positional arguments separator (recommended).", }, ], }, { "name": "ls", - "description": "show available commitizens", - "help": "show available commitizens", + "description": "Show available Commitizens", + "help": "Show available Commitizens.", "func": commands.ListCz, }, { "name": "example", - "description": "show commit example", - "help": "show commit example", + "description": "Show commit example", + "help": "Show commit example.", "func": commands.Example, }, { "name": "info", - "description": "show information about the cz", - "help": "show information about the cz", + "description": "Show information about the cz", + "help": "Show information about the cz.", "func": commands.Info, }, { "name": "schema", - "description": "show commit schema", - "help": "show commit schema", + "description": "Show commit schema", + "help": "Show commit schema.", "func": commands.Schema, }, { "name": "bump", - "description": "bump semantic version based on the git log", - "help": "bump semantic version based on the git log", + "description": "Bump semantic version based on the git log", + "help": "Bump semantic version based on the git log.", "func": commands.Bump, "arguments": [ { "name": "--dry-run", "action": "store_true", - "help": "show output to stdout, no commit, no modified files", + "help": "Perform a dry run, without committing or modifying files.", }, { - "name": "--files-only", + "name": "--files-only", # TODO: rename to --version-files-only "action": "store_true", - "help": "bump version in the files from the config", + "help": "Bump version in the `version_files` specified in the configuration file only.", }, { "name": "--local-version", "action": "store_true", - "help": "bump only the local version portion", + "help": "Bump version only the local version portion (ignoring the public version).", }, { "name": ["--changelog", "-ch"], "action": "store_true", "default": False, - "help": "generate the changelog for the newest version", + "help": "Generate the changelog for the latest version.", }, { "name": ["--no-verify"], "action": "store_true", "default": False, - "help": "this option bypasses the pre-commit and commit-msg hooks", + # The help text aligns with the description of git commit --no-verify + "help": "Bypass the pre-commit and commit-msg hooks.", }, { "name": "--yes", "action": "store_true", - "help": "accept automatically questions done", + "help": "Accept automatically answered questions.", }, { "name": "--tag-format", "help": ( - "the format used to tag the commit and read it, " - "use it in existing projects, " - "wrap around simple quotes" + "The format used to tag the commit and read it. " + "Use it in existing projects, and wrap around simple quotes." ), }, { "name": "--bump-message", "help": ( - "template used to create the release commit, " - "useful when working with CI" + "Template used to create the release commit, useful when working with CI." ), }, { "name": ["--prerelease", "-pr"], - "help": "choose type of prerelease", + "help": "Type of prerelease.", "choices": ["alpha", "beta", "rc"], }, { "name": ["--devrelease", "-d"], - "help": "specify non-negative integer for dev. release", + "help": "Specify non-negative integer for dev release.", "type": int, }, { "name": ["--increment"], - "help": "manually specify the desired increment", + "help": "Specify the desired increment.", "choices": ["MAJOR", "MINOR", "PATCH"], "type": str.upper, }, @@ -268,35 +268,34 @@ def __call__( "choices": ["linear", "exact"], "default": "linear", "help": ( - "set the method by which the new version is chosen. " - "'linear' (default) guesses the next version based on typical linear version progression, " - "such that bumping of a pre-release with lower precedence than the current pre-release " + "Set the method by which the new version is chosen. " + "'linear' (default) resolves the next version based on typical linear version progression, " + "where bumping of a pre-release with lower precedence than the current pre-release " "phase maintains the current phase of higher precedence. " "'exact' applies the changes that have been specified (or determined from the commit log) " - "without interpretation, such that the increment and pre-release are always honored" + "without interpretation, ensuring the increment and pre-release are always honored." ), }, { "name": ["--check-consistency", "-cc"], "help": ( - "check consistency among versions defined in " - "commitizen configuration and version_files" + "Check consistency among versions defined in Commitizen configuration file and `version_files`." ), "action": "store_true", }, { "name": ["--annotated-tag", "-at"], - "help": "create annotated tag instead of lightweight one", + "help": "Create annotated tag instead of lightweight one.", "action": "store_true", }, { "name": ["--annotated-tag-message", "-atm"], - "help": "create annotated tag message", + "help": "Create annotated tag message.", "type": str, }, { "name": ["--gpg-sign", "-s"], - "help": "sign tag instead of lightweight one", + "help": "Sign tag instead of lightweight one.", "default": False, "action": "store_true", }, @@ -304,46 +303,46 @@ def __call__( "name": ["--changelog-to-stdout"], "action": "store_true", "default": False, - "help": "Output changelog to the stdout", + "help": "Output changelog to stdout.", }, { "name": ["--git-output-to-stderr"], "action": "store_true", "default": False, - "help": "Redirect git output to stderr", + "help": "Redirect git output to stderr.", }, { "name": ["--retry"], "action": "store_true", "default": False, - "help": "retry commit if it fails the 1st time", + "help": "Retry commit if it fails for the first time.", }, { "name": ["--major-version-zero"], "action": "store_true", "default": None, - "help": "keep major version at zero, even for breaking changes", + "help": "Keep major version at zero, even for breaking changes.", }, *deepcopy(tpl_arguments), { "name": "--file-name", - "help": "file name of changelog (default: 'CHANGELOG.md')", + "help": "File name of changelog (default: 'CHANGELOG.md').", }, { "name": ["--prerelease-offset"], "type": int, "default": None, - "help": "start pre-releases with this offset", + "help": "Start pre-releases with this offset.", }, { "name": ["--version-scheme"], - "help": "choose version scheme", + "help": "Choose version scheme.", "default": None, "choices": version_schemes.KNOWN_SCHEMES, }, { "name": ["--version-type"], - "help": "Deprecated, use --version-scheme instead", + "help": "Deprecated, use `--version-scheme` instead.", "default": None, "choices": version_schemes.KNOWN_SCHEMES, }, @@ -351,24 +350,24 @@ def __call__( "name": "manual_version", "type": str, "nargs": "?", - "help": "bump to the given version (e.g: 1.5.3)", + "help": "Bump to the given version (e.g., 1.5.3).", "metavar": "MANUAL_VERSION", }, { "name": ["--build-metadata"], - "help": "Add additional build-metadata to the version-number", + "help": "Add additional build-metadata to the version-number.", "default": None, }, { "name": ["--get-next"], "action": "store_true", - "help": "Determine the next version and write to stdout", + "help": "Determine the next version and write to stdout.", "default": False, }, { "name": ["--allow-no-commit"], "default": False, - "help": "bump version without eligible commits", + "help": "Bump version without eligible commits.", "action": "store_true", }, ], @@ -376,10 +375,10 @@ def __call__( { "name": ["changelog", "ch"], "description": ( - "generate changelog (note that it will overwrite existing file)" + "Generate changelog (note that it will overwrite existing files)" ), "help": ( - "generate changelog (note that it will overwrite existing file)" + "Generate changelog (note that it will overwrite existing files)." ), "func": commands.Changelog, "arguments": [ @@ -387,17 +386,17 @@ def __call__( "name": "--dry-run", "action": "store_true", "default": False, - "help": "show changelog to stdout", + "help": "Show changelog to stdout.", }, { "name": "--file-name", - "help": "file name of changelog (default: 'CHANGELOG.md')", + "help": "File name of changelog (default: 'CHANGELOG.md').", }, { "name": "--unreleased-version", "help": ( - "set the value for the new version (use the tag value), " - "instead of using unreleased" + "Set the value for the new version (use the tag value), " + "instead of using unreleased versions." ), }, { @@ -405,22 +404,22 @@ def __call__( "action": "store_true", "default": False, "help": ( - "generates changelog from last created version, " - "useful if the changelog has been manually modified" + "Generate changelog from the last created version, " + "useful if the changelog has been manually modified." ), }, { "name": "rev_range", "type": str, "nargs": "?", - "help": "generates changelog for the given version (e.g: 1.5.3) or version range (e.g: 1.5.3..1.7.9)", + "help": "Generate changelog for the given version (e.g., 1.5.3) or version range (e.g., 1.5.3..1.7.9).", }, { "name": "--start-rev", "default": None, "help": ( - "start rev of the changelog. " - "If not set, it will generate changelog from the start" + "Start rev of the changelog. " + "If not set, it will generate changelog from the beginning." ), }, { @@ -428,128 +427,122 @@ def __call__( "action": "store_true", "default": False, "help": ( - "collect all changes from prereleases into next non-prerelease. " - "If not set, it will include prereleases in the changelog" + "Collect all changes from prereleases into the next non-prerelease. " + "If not set, it will include prereleases in the changelog." ), }, { "name": ["--version-scheme"], - "help": "choose version scheme", + "help": "Choose version scheme.", "default": None, "choices": version_schemes.KNOWN_SCHEMES, }, { "name": "--export-template", "default": None, - "help": "Export the changelog template into this file instead of rendering it", + "help": "Export the changelog template into this file instead of rendering it.", }, *deepcopy(tpl_arguments), { "name": "--tag-format", - "help": "The format of the tag, wrap around simple quotes", + "help": "The format of the tag, wrap around simple quotes.", }, ], }, { "name": ["check"], - "description": "validates that a commit message matches the commitizen schema", - "help": "validates that a commit message matches the commitizen schema", + "description": "Validate that a commit message matches the commitizen schema", + "help": "Validate that a commit message matches the commitizen schema.", "func": commands.Check, "arguments": [ { "name": "--commit-msg-file", "help": ( - "ask for the name of the temporal file that contains " - "the commit message. " - "Using it in a git hook script: MSG_FILE=$1" + "Ask for the name of the temporary file that contains the commit message. " + "Use it in a git hook script: MSG_FILE=$1." ), "exclusive_group": "group1", }, { "name": "--rev-range", - "help": "a range of git rev to check. e.g, master..HEAD", + "help": "Validate the commits in the given range of git rev, e.g., master..HEAD.", "exclusive_group": "group1", }, { "name": ["-d", "--use-default-range"], "action": "store_true", "default": False, - "help": "check from the default branch to HEAD. e.g, refs/remotes/origin/master..HEAD", + "help": "Validate the commits from the default branch to HEAD, e.g., refs/remotes/origin/master..HEAD.", "exclusive_group": "group1", }, { "name": ["-m", "--message"], - "help": "commit message that needs to be checked", + "help": "Validate the given commit message.", "exclusive_group": "group1", }, { "name": ["--allow-abort"], "action": "store_true", "default": False, - "help": "allow empty commit messages, which typically abort a commit", + "help": "Allow empty commit messages, which typically abort a commit.", }, { "name": ["--allowed-prefixes"], "nargs": "*", - "help": "allowed commit message prefixes. " - "If the message starts by one of these prefixes, " - "the message won't be checked against the regex", + "help": "Skip validation for commit messages that start with the specified prefixes.", }, { "name": ["-l", "--message-length-limit"], "type": int, - "help": "length limit of the commit message; 0 for no limit", + "help": "Restrict the length of the **first line** of the commit message; 0 for no limit.", }, ], }, { "name": ["version"], "description": ( - "get the version of the installed commitizen or the current project" - " (default: installed commitizen)" + "Get the version of the installed commitizen or the current project (default: installed commitizen)" ), "help": ( - "get the version of the installed commitizen or the current project" - " (default: installed commitizen)" + "Get the version of the installed commitizen or the current project (default: installed commitizen)." ), "func": commands.Version, "arguments": [ { "name": ["-r", "--report"], - "help": "get system information for reporting bugs", + "help": "Output the system information for reporting bugs.", "action": "store_true", "exclusive_group": "group1", }, { "name": ["-p", "--project"], - "help": "get the version of the current project", + "help": "Output the version of the current project.", "action": "store_true", "exclusive_group": "group1", }, { "name": ["-c", "--commitizen"], - "help": "get the version of the installed commitizen", + "help": "Output the version of the installed commitizen.", "action": "store_true", "exclusive_group": "group1", }, { "name": ["-v", "--verbose"], "help": ( - "get the version of both the installed commitizen " - "and the current project" + "Output the version of both the installed commitizen and the current project." ), "action": "store_true", "exclusive_group": "group1", }, { "name": ["--major"], - "help": "get just the major version. Need to be used with --project or --verbose.", + "help": "Output just the major version. Must be used with --project or --verbose.", "action": "store_true", "exclusive_group": "group2", }, { "name": ["--minor"], - "help": "get just the minor version. Need to be used with --project or --verbose.", + "help": "Output just the minor version. Must be used with --project or --verbose.", "action": "store_true", "exclusive_group": "group2", }, diff --git a/tests/commands/test_common_command/test_command_shows_description_when_use_help_option_py_3_10_bump_.txt b/tests/commands/test_common_command/test_command_shows_description_when_use_help_option_py_3_10_bump_.txt index ad0a693278..d56e739277 100644 --- a/tests/commands/test_common_command/test_command_shows_description_when_use_help_option_py_3_10_bump_.txt +++ b/tests/commands/test_common_command/test_command_shows_description_when_use_help_option_py_3_10_bump_.txt @@ -14,69 +14,71 @@ usage: cz bump [-h] [--dry-run] [--files-only] [--local-version] [--changelog] [--allow-no-commit] [MANUAL_VERSION] -bump semantic version based on the git log +Bump semantic version based on the git log positional arguments: - MANUAL_VERSION bump to the given version (e.g: 1.5.3) + MANUAL_VERSION Bump to the given version (e.g., 1.5.3). options: -h, --help show this help message and exit - --dry-run show output to stdout, no commit, no modified files - --files-only bump version in the files from the config - --local-version bump only the local version portion - --changelog, -ch generate the changelog for the newest version - --no-verify this option bypasses the pre-commit and commit-msg - hooks - --yes accept automatically questions done + --dry-run Perform a dry run, without committing or modifying + files. + --files-only Bump version in the `version_files` specified in the + configuration file only. + --local-version Bump version only the local version portion (ignoring + the public version). + --changelog, -ch Generate the changelog for the latest version. + --no-verify Bypass the pre-commit and commit-msg hooks. + --yes Accept automatically answered questions. --tag-format TAG_FORMAT - the format used to tag the commit and read it, use it - in existing projects, wrap around simple quotes + The format used to tag the commit and read it. Use it + in existing projects, and wrap around simple quotes. --bump-message BUMP_MESSAGE - template used to create the release commit, useful - when working with CI + Template used to create the release commit, useful + when working with CI. --prerelease {alpha,beta,rc}, -pr {alpha,beta,rc} - choose type of prerelease + Type of prerelease. --devrelease DEVRELEASE, -d DEVRELEASE - specify non-negative integer for dev. release + Specify non-negative integer for dev release. --increment {MAJOR,MINOR,PATCH} - manually specify the desired increment + Specify the desired increment. --increment-mode {linear,exact} - set the method by which the new version is chosen. - 'linear' (default) guesses the next version based on - typical linear version progression, such that bumping - of a pre-release with lower precedence than the - current pre-release phase maintains the current phase - of higher precedence. 'exact' applies the changes that + Set the method by which the new version is chosen. + 'linear' (default) resolves the next version based on + typical linear version progression, where bumping of a + pre-release with lower precedence than the current + pre-release phase maintains the current phase of + higher precedence. 'exact' applies the changes that have been specified (or determined from the commit - log) without interpretation, such that the increment - and pre-release are always honored + log) without interpretation, ensuring the increment + and pre-release are always honored. --check-consistency, -cc - check consistency among versions defined in commitizen - configuration and version_files - --annotated-tag, -at create annotated tag instead of lightweight one + Check consistency among versions defined in Commitizen + configuration file and `version_files`. + --annotated-tag, -at Create annotated tag instead of lightweight one. --annotated-tag-message ANNOTATED_TAG_MESSAGE, -atm ANNOTATED_TAG_MESSAGE - create annotated tag message - --gpg-sign, -s sign tag instead of lightweight one + Create annotated tag message. + --gpg-sign, -s Sign tag instead of lightweight one. --changelog-to-stdout - Output changelog to the stdout + Output changelog to stdout. --git-output-to-stderr - Redirect git output to stderr - --retry retry commit if it fails the 1st time - --major-version-zero keep major version at zero, even for breaking changes + Redirect git output to stderr. + --retry Retry commit if it fails for the first time. + --major-version-zero Keep major version at zero, even for breaking changes. --template TEMPLATE, -t TEMPLATE - changelog template file name (relative to the current - working directory) + Changelog template file name (relative to the current + working directory). --extra EXTRA, -e EXTRA - a changelog extra variable (in the form 'key=value') + Changelog extra variables (in the form 'key=value'). --file-name FILE_NAME - file name of changelog (default: 'CHANGELOG.md') + File name of changelog (default: 'CHANGELOG.md'). --prerelease-offset PRERELEASE_OFFSET - start pre-releases with this offset + Start pre-releases with this offset. --version-scheme {pep440,semver,semver2} - choose version scheme + Choose version scheme. --version-type {pep440,semver,semver2} - Deprecated, use --version-scheme instead + Deprecated, use `--version-scheme` instead. --build-metadata BUILD_METADATA - Add additional build-metadata to the version-number - --get-next Determine the next version and write to stdout - --allow-no-commit bump version without eligible commits + Add additional build-metadata to the version-number. + --get-next Determine the next version and write to stdout. + --allow-no-commit Bump version without eligible commits. diff --git a/tests/commands/test_common_command/test_command_shows_description_when_use_help_option_py_3_10_changelog_.txt b/tests/commands/test_common_command/test_command_shows_description_when_use_help_option_py_3_10_changelog_.txt index f4aa1ca2a6..2d1135af74 100644 --- a/tests/commands/test_common_command/test_command_shows_description_when_use_help_option_py_3_10_changelog_.txt +++ b/tests/commands/test_common_command/test_command_shows_description_when_use_help_option_py_3_10_changelog_.txt @@ -6,37 +6,37 @@ usage: cz changelog [-h] [--dry-run] [--file-name FILE_NAME] [--extra EXTRA] [--tag-format TAG_FORMAT] [rev_range] -generate changelog (note that it will overwrite existing file) +Generate changelog (note that it will overwrite existing files) positional arguments: - rev_range generates changelog for the given version (e.g: 1.5.3) - or version range (e.g: 1.5.3..1.7.9) + rev_range Generate changelog for the given version (e.g., 1.5.3) + or version range (e.g., 1.5.3..1.7.9). options: -h, --help show this help message and exit - --dry-run show changelog to stdout + --dry-run Show changelog to stdout. --file-name FILE_NAME - file name of changelog (default: 'CHANGELOG.md') + File name of changelog (default: 'CHANGELOG.md'). --unreleased-version UNRELEASED_VERSION - set the value for the new version (use the tag value), - instead of using unreleased - --incremental generates changelog from last created version, useful - if the changelog has been manually modified + Set the value for the new version (use the tag value), + instead of using unreleased versions. + --incremental Generate changelog from the last created version, + useful if the changelog has been manually modified. --start-rev START_REV - start rev of the changelog. If not set, it will - generate changelog from the start - --merge-prerelease collect all changes from prereleases into next non- - prerelease. If not set, it will include prereleases in - the changelog + Start rev of the changelog. If not set, it will + generate changelog from the beginning. + --merge-prerelease Collect all changes from prereleases into the next + non-prerelease. If not set, it will include + prereleases in the changelog. --version-scheme {pep440,semver,semver2} - choose version scheme + Choose version scheme. --export-template EXPORT_TEMPLATE Export the changelog template into this file instead - of rendering it + of rendering it. --template TEMPLATE, -t TEMPLATE - changelog template file name (relative to the current - working directory) + Changelog template file name (relative to the current + working directory). --extra EXTRA, -e EXTRA - a changelog extra variable (in the form 'key=value') + Changelog extra variables (in the form 'key=value'). --tag-format TAG_FORMAT - The format of the tag, wrap around simple quotes + The format of the tag, wrap around simple quotes. diff --git a/tests/commands/test_common_command/test_command_shows_description_when_use_help_option_py_3_10_check_.txt b/tests/commands/test_common_command/test_command_shows_description_when_use_help_option_py_3_10_check_.txt index 53c4e7ed10..144e91b61a 100644 --- a/tests/commands/test_common_command/test_command_shows_description_when_use_help_option_py_3_10_check_.txt +++ b/tests/commands/test_common_command/test_command_shows_description_when_use_help_option_py_3_10_check_.txt @@ -3,26 +3,27 @@ usage: cz check [-h] [--allow-abort] [--allowed-prefixes [ALLOWED_PREFIXES ...]] [-l MESSAGE_LENGTH_LIMIT] -validates that a commit message matches the commitizen schema +Validate that a commit message matches the commitizen schema options: -h, --help show this help message and exit --commit-msg-file COMMIT_MSG_FILE - ask for the name of the temporal file that contains - the commit message. Using it in a git hook script: - MSG_FILE=$1 + Ask for the name of the temporary file that contains + the commit message. Use it in a git hook script: + MSG_FILE=$1. --rev-range REV_RANGE - a range of git rev to check. e.g, master..HEAD + Validate the commits in the given range of git rev, + e.g., master..HEAD. -d, --use-default-range - check from the default branch to HEAD. e.g, - refs/remotes/origin/master..HEAD + Validate the commits from the default branch to HEAD, + e.g., refs/remotes/origin/master..HEAD. -m MESSAGE, --message MESSAGE - commit message that needs to be checked - --allow-abort allow empty commit messages, which typically abort a - commit + Validate the given commit message. + --allow-abort Allow empty commit messages, which typically abort a + commit. --allowed-prefixes [ALLOWED_PREFIXES ...] - allowed commit message prefixes. If the message starts - by one of these prefixes, the message won't be checked - against the regex + Skip validation for commit messages that start with + the specified prefixes. -l MESSAGE_LENGTH_LIMIT, --message-length-limit MESSAGE_LENGTH_LIMIT - length limit of the commit message; 0 for no limit + Restrict the length of the **first line** of the + commit message; 0 for no limit. diff --git a/tests/commands/test_common_command/test_command_shows_description_when_use_help_option_py_3_10_commit_.txt b/tests/commands/test_common_command/test_command_shows_description_when_use_help_option_py_3_10_commit_.txt index c842433427..bd256ccf8c 100644 --- a/tests/commands/test_common_command/test_command_shows_description_when_use_help_option_py_3_10_commit_.txt +++ b/tests/commands/test_common_command/test_command_shows_description_when_use_help_option_py_3_10_commit_.txt @@ -2,21 +2,24 @@ usage: cz commit [-h] [--retry] [--no-retry] [--dry-run] [--write-message-to-file FILE_PATH] [-s] [-a] [-e] [-l MESSAGE_LENGTH_LIMIT] [--] -create new commit +Create new commit options: -h, --help show this help message and exit - --retry retry last commit - --no-retry skip retry if retry_after_failure is set to true - --dry-run show output to stdout, no commit, no modified files + --retry Retry the last commit. + --no-retry Skip retry if --retry or `retry_after_failure` is set + to true. + --dry-run Perform a dry run, without committing or modifying + files. --write-message-to-file FILE_PATH - write message to file before committing (can be - combined with --dry-run) - -s, --signoff Deprecated, use 'cz commit -- -s' instead - -a, --all Tell the command to automatically stage files that - have been modified and deleted, but new files you have - not told Git about are not affected. - -e, --edit edit the commit message before committing + Write message to FILE_PATH before committing (can be + used with --dry-run). + -s, --signoff Deprecated, use `cz commit -- -s` instead. + -a, --all Automatically stage files that have been modified and + deleted, but new files you have not told Git about are + not affected. + -e, --edit Edit the commit message before committing. -l MESSAGE_LENGTH_LIMIT, --message-length-limit MESSAGE_LENGTH_LIMIT - length limit of the commit message; 0 for no limit - -- Positional arguments separator (recommended) + Set the length limit of the commit message; 0 for no + limit. + -- Positional arguments separator (recommended). diff --git a/tests/commands/test_common_command/test_command_shows_description_when_use_help_option_py_3_10_example_.txt b/tests/commands/test_common_command/test_command_shows_description_when_use_help_option_py_3_10_example_.txt index b9bf7f84fc..8a0f1c9d94 100644 --- a/tests/commands/test_common_command/test_command_shows_description_when_use_help_option_py_3_10_example_.txt +++ b/tests/commands/test_common_command/test_command_shows_description_when_use_help_option_py_3_10_example_.txt @@ -1,6 +1,6 @@ usage: cz example [-h] -show commit example +Show commit example options: -h, --help show this help message and exit diff --git a/tests/commands/test_common_command/test_command_shows_description_when_use_help_option_py_3_10_info_.txt b/tests/commands/test_common_command/test_command_shows_description_when_use_help_option_py_3_10_info_.txt index 99b1ba8a4a..ed5ae2522e 100644 --- a/tests/commands/test_common_command/test_command_shows_description_when_use_help_option_py_3_10_info_.txt +++ b/tests/commands/test_common_command/test_command_shows_description_when_use_help_option_py_3_10_info_.txt @@ -1,6 +1,6 @@ usage: cz info [-h] -show information about the cz +Show information about the cz options: -h, --help show this help message and exit diff --git a/tests/commands/test_common_command/test_command_shows_description_when_use_help_option_py_3_10_init_.txt b/tests/commands/test_common_command/test_command_shows_description_when_use_help_option_py_3_10_init_.txt index 0f72042f88..546ab51cb3 100644 --- a/tests/commands/test_common_command/test_command_shows_description_when_use_help_option_py_3_10_init_.txt +++ b/tests/commands/test_common_command/test_command_shows_description_when_use_help_option_py_3_10_init_.txt @@ -1,6 +1,6 @@ usage: cz init [-h] -init commitizen configuration +Initialize commitizen configuration options: -h, --help show this help message and exit diff --git a/tests/commands/test_common_command/test_command_shows_description_when_use_help_option_py_3_10_ls_.txt b/tests/commands/test_common_command/test_command_shows_description_when_use_help_option_py_3_10_ls_.txt index 5fa8fe1f79..253da1722c 100644 --- a/tests/commands/test_common_command/test_command_shows_description_when_use_help_option_py_3_10_ls_.txt +++ b/tests/commands/test_common_command/test_command_shows_description_when_use_help_option_py_3_10_ls_.txt @@ -1,6 +1,6 @@ usage: cz ls [-h] -show available commitizens +Show available Commitizens options: -h, --help show this help message and exit diff --git a/tests/commands/test_common_command/test_command_shows_description_when_use_help_option_py_3_10_schema_.txt b/tests/commands/test_common_command/test_command_shows_description_when_use_help_option_py_3_10_schema_.txt index 6666db4d41..dd05ead81b 100644 --- a/tests/commands/test_common_command/test_command_shows_description_when_use_help_option_py_3_10_schema_.txt +++ b/tests/commands/test_common_command/test_command_shows_description_when_use_help_option_py_3_10_schema_.txt @@ -1,6 +1,6 @@ usage: cz schema [-h] -show commit schema +Show commit schema options: -h, --help show this help message and exit diff --git a/tests/commands/test_common_command/test_command_shows_description_when_use_help_option_py_3_10_version_.txt b/tests/commands/test_common_command/test_command_shows_description_when_use_help_option_py_3_10_version_.txt index a194615a98..0061a97514 100644 --- a/tests/commands/test_common_command/test_command_shows_description_when_use_help_option_py_3_10_version_.txt +++ b/tests/commands/test_common_command/test_command_shows_description_when_use_help_option_py_3_10_version_.txt @@ -1,16 +1,16 @@ usage: cz version [-h] [-r | -p | -c | -v] [--major | --minor] -get the version of the installed commitizen or the current project (default: +Get the version of the installed commitizen or the current project (default: installed commitizen) options: -h, --help show this help message and exit - -r, --report get system information for reporting bugs - -p, --project get the version of the current project - -c, --commitizen get the version of the installed commitizen - -v, --verbose get the version of both the installed commitizen and the - current project - --major get just the major version. Need to be used with --project + -r, --report Output the system information for reporting bugs. + -p, --project Output the version of the current project. + -c, --commitizen Output the version of the installed commitizen. + -v, --verbose Output the version of both the installed commitizen and + the current project. + --major Output just the major version. Must be used with --project or --verbose. - --minor get just the minor version. Need to be used with --project + --minor Output just the minor version. Must be used with --project or --verbose. diff --git a/tests/commands/test_common_command/test_command_shows_description_when_use_help_option_py_3_11_bump_.txt b/tests/commands/test_common_command/test_command_shows_description_when_use_help_option_py_3_11_bump_.txt index ad0a693278..d56e739277 100644 --- a/tests/commands/test_common_command/test_command_shows_description_when_use_help_option_py_3_11_bump_.txt +++ b/tests/commands/test_common_command/test_command_shows_description_when_use_help_option_py_3_11_bump_.txt @@ -14,69 +14,71 @@ usage: cz bump [-h] [--dry-run] [--files-only] [--local-version] [--changelog] [--allow-no-commit] [MANUAL_VERSION] -bump semantic version based on the git log +Bump semantic version based on the git log positional arguments: - MANUAL_VERSION bump to the given version (e.g: 1.5.3) + MANUAL_VERSION Bump to the given version (e.g., 1.5.3). options: -h, --help show this help message and exit - --dry-run show output to stdout, no commit, no modified files - --files-only bump version in the files from the config - --local-version bump only the local version portion - --changelog, -ch generate the changelog for the newest version - --no-verify this option bypasses the pre-commit and commit-msg - hooks - --yes accept automatically questions done + --dry-run Perform a dry run, without committing or modifying + files. + --files-only Bump version in the `version_files` specified in the + configuration file only. + --local-version Bump version only the local version portion (ignoring + the public version). + --changelog, -ch Generate the changelog for the latest version. + --no-verify Bypass the pre-commit and commit-msg hooks. + --yes Accept automatically answered questions. --tag-format TAG_FORMAT - the format used to tag the commit and read it, use it - in existing projects, wrap around simple quotes + The format used to tag the commit and read it. Use it + in existing projects, and wrap around simple quotes. --bump-message BUMP_MESSAGE - template used to create the release commit, useful - when working with CI + Template used to create the release commit, useful + when working with CI. --prerelease {alpha,beta,rc}, -pr {alpha,beta,rc} - choose type of prerelease + Type of prerelease. --devrelease DEVRELEASE, -d DEVRELEASE - specify non-negative integer for dev. release + Specify non-negative integer for dev release. --increment {MAJOR,MINOR,PATCH} - manually specify the desired increment + Specify the desired increment. --increment-mode {linear,exact} - set the method by which the new version is chosen. - 'linear' (default) guesses the next version based on - typical linear version progression, such that bumping - of a pre-release with lower precedence than the - current pre-release phase maintains the current phase - of higher precedence. 'exact' applies the changes that + Set the method by which the new version is chosen. + 'linear' (default) resolves the next version based on + typical linear version progression, where bumping of a + pre-release with lower precedence than the current + pre-release phase maintains the current phase of + higher precedence. 'exact' applies the changes that have been specified (or determined from the commit - log) without interpretation, such that the increment - and pre-release are always honored + log) without interpretation, ensuring the increment + and pre-release are always honored. --check-consistency, -cc - check consistency among versions defined in commitizen - configuration and version_files - --annotated-tag, -at create annotated tag instead of lightweight one + Check consistency among versions defined in Commitizen + configuration file and `version_files`. + --annotated-tag, -at Create annotated tag instead of lightweight one. --annotated-tag-message ANNOTATED_TAG_MESSAGE, -atm ANNOTATED_TAG_MESSAGE - create annotated tag message - --gpg-sign, -s sign tag instead of lightweight one + Create annotated tag message. + --gpg-sign, -s Sign tag instead of lightweight one. --changelog-to-stdout - Output changelog to the stdout + Output changelog to stdout. --git-output-to-stderr - Redirect git output to stderr - --retry retry commit if it fails the 1st time - --major-version-zero keep major version at zero, even for breaking changes + Redirect git output to stderr. + --retry Retry commit if it fails for the first time. + --major-version-zero Keep major version at zero, even for breaking changes. --template TEMPLATE, -t TEMPLATE - changelog template file name (relative to the current - working directory) + Changelog template file name (relative to the current + working directory). --extra EXTRA, -e EXTRA - a changelog extra variable (in the form 'key=value') + Changelog extra variables (in the form 'key=value'). --file-name FILE_NAME - file name of changelog (default: 'CHANGELOG.md') + File name of changelog (default: 'CHANGELOG.md'). --prerelease-offset PRERELEASE_OFFSET - start pre-releases with this offset + Start pre-releases with this offset. --version-scheme {pep440,semver,semver2} - choose version scheme + Choose version scheme. --version-type {pep440,semver,semver2} - Deprecated, use --version-scheme instead + Deprecated, use `--version-scheme` instead. --build-metadata BUILD_METADATA - Add additional build-metadata to the version-number - --get-next Determine the next version and write to stdout - --allow-no-commit bump version without eligible commits + Add additional build-metadata to the version-number. + --get-next Determine the next version and write to stdout. + --allow-no-commit Bump version without eligible commits. diff --git a/tests/commands/test_common_command/test_command_shows_description_when_use_help_option_py_3_11_changelog_.txt b/tests/commands/test_common_command/test_command_shows_description_when_use_help_option_py_3_11_changelog_.txt index f4aa1ca2a6..2d1135af74 100644 --- a/tests/commands/test_common_command/test_command_shows_description_when_use_help_option_py_3_11_changelog_.txt +++ b/tests/commands/test_common_command/test_command_shows_description_when_use_help_option_py_3_11_changelog_.txt @@ -6,37 +6,37 @@ usage: cz changelog [-h] [--dry-run] [--file-name FILE_NAME] [--extra EXTRA] [--tag-format TAG_FORMAT] [rev_range] -generate changelog (note that it will overwrite existing file) +Generate changelog (note that it will overwrite existing files) positional arguments: - rev_range generates changelog for the given version (e.g: 1.5.3) - or version range (e.g: 1.5.3..1.7.9) + rev_range Generate changelog for the given version (e.g., 1.5.3) + or version range (e.g., 1.5.3..1.7.9). options: -h, --help show this help message and exit - --dry-run show changelog to stdout + --dry-run Show changelog to stdout. --file-name FILE_NAME - file name of changelog (default: 'CHANGELOG.md') + File name of changelog (default: 'CHANGELOG.md'). --unreleased-version UNRELEASED_VERSION - set the value for the new version (use the tag value), - instead of using unreleased - --incremental generates changelog from last created version, useful - if the changelog has been manually modified + Set the value for the new version (use the tag value), + instead of using unreleased versions. + --incremental Generate changelog from the last created version, + useful if the changelog has been manually modified. --start-rev START_REV - start rev of the changelog. If not set, it will - generate changelog from the start - --merge-prerelease collect all changes from prereleases into next non- - prerelease. If not set, it will include prereleases in - the changelog + Start rev of the changelog. If not set, it will + generate changelog from the beginning. + --merge-prerelease Collect all changes from prereleases into the next + non-prerelease. If not set, it will include + prereleases in the changelog. --version-scheme {pep440,semver,semver2} - choose version scheme + Choose version scheme. --export-template EXPORT_TEMPLATE Export the changelog template into this file instead - of rendering it + of rendering it. --template TEMPLATE, -t TEMPLATE - changelog template file name (relative to the current - working directory) + Changelog template file name (relative to the current + working directory). --extra EXTRA, -e EXTRA - a changelog extra variable (in the form 'key=value') + Changelog extra variables (in the form 'key=value'). --tag-format TAG_FORMAT - The format of the tag, wrap around simple quotes + The format of the tag, wrap around simple quotes. diff --git a/tests/commands/test_common_command/test_command_shows_description_when_use_help_option_py_3_11_check_.txt b/tests/commands/test_common_command/test_command_shows_description_when_use_help_option_py_3_11_check_.txt index 53c4e7ed10..144e91b61a 100644 --- a/tests/commands/test_common_command/test_command_shows_description_when_use_help_option_py_3_11_check_.txt +++ b/tests/commands/test_common_command/test_command_shows_description_when_use_help_option_py_3_11_check_.txt @@ -3,26 +3,27 @@ usage: cz check [-h] [--allow-abort] [--allowed-prefixes [ALLOWED_PREFIXES ...]] [-l MESSAGE_LENGTH_LIMIT] -validates that a commit message matches the commitizen schema +Validate that a commit message matches the commitizen schema options: -h, --help show this help message and exit --commit-msg-file COMMIT_MSG_FILE - ask for the name of the temporal file that contains - the commit message. Using it in a git hook script: - MSG_FILE=$1 + Ask for the name of the temporary file that contains + the commit message. Use it in a git hook script: + MSG_FILE=$1. --rev-range REV_RANGE - a range of git rev to check. e.g, master..HEAD + Validate the commits in the given range of git rev, + e.g., master..HEAD. -d, --use-default-range - check from the default branch to HEAD. e.g, - refs/remotes/origin/master..HEAD + Validate the commits from the default branch to HEAD, + e.g., refs/remotes/origin/master..HEAD. -m MESSAGE, --message MESSAGE - commit message that needs to be checked - --allow-abort allow empty commit messages, which typically abort a - commit + Validate the given commit message. + --allow-abort Allow empty commit messages, which typically abort a + commit. --allowed-prefixes [ALLOWED_PREFIXES ...] - allowed commit message prefixes. If the message starts - by one of these prefixes, the message won't be checked - against the regex + Skip validation for commit messages that start with + the specified prefixes. -l MESSAGE_LENGTH_LIMIT, --message-length-limit MESSAGE_LENGTH_LIMIT - length limit of the commit message; 0 for no limit + Restrict the length of the **first line** of the + commit message; 0 for no limit. diff --git a/tests/commands/test_common_command/test_command_shows_description_when_use_help_option_py_3_11_commit_.txt b/tests/commands/test_common_command/test_command_shows_description_when_use_help_option_py_3_11_commit_.txt index c842433427..bd256ccf8c 100644 --- a/tests/commands/test_common_command/test_command_shows_description_when_use_help_option_py_3_11_commit_.txt +++ b/tests/commands/test_common_command/test_command_shows_description_when_use_help_option_py_3_11_commit_.txt @@ -2,21 +2,24 @@ usage: cz commit [-h] [--retry] [--no-retry] [--dry-run] [--write-message-to-file FILE_PATH] [-s] [-a] [-e] [-l MESSAGE_LENGTH_LIMIT] [--] -create new commit +Create new commit options: -h, --help show this help message and exit - --retry retry last commit - --no-retry skip retry if retry_after_failure is set to true - --dry-run show output to stdout, no commit, no modified files + --retry Retry the last commit. + --no-retry Skip retry if --retry or `retry_after_failure` is set + to true. + --dry-run Perform a dry run, without committing or modifying + files. --write-message-to-file FILE_PATH - write message to file before committing (can be - combined with --dry-run) - -s, --signoff Deprecated, use 'cz commit -- -s' instead - -a, --all Tell the command to automatically stage files that - have been modified and deleted, but new files you have - not told Git about are not affected. - -e, --edit edit the commit message before committing + Write message to FILE_PATH before committing (can be + used with --dry-run). + -s, --signoff Deprecated, use `cz commit -- -s` instead. + -a, --all Automatically stage files that have been modified and + deleted, but new files you have not told Git about are + not affected. + -e, --edit Edit the commit message before committing. -l MESSAGE_LENGTH_LIMIT, --message-length-limit MESSAGE_LENGTH_LIMIT - length limit of the commit message; 0 for no limit - -- Positional arguments separator (recommended) + Set the length limit of the commit message; 0 for no + limit. + -- Positional arguments separator (recommended). diff --git a/tests/commands/test_common_command/test_command_shows_description_when_use_help_option_py_3_11_example_.txt b/tests/commands/test_common_command/test_command_shows_description_when_use_help_option_py_3_11_example_.txt index b9bf7f84fc..8a0f1c9d94 100644 --- a/tests/commands/test_common_command/test_command_shows_description_when_use_help_option_py_3_11_example_.txt +++ b/tests/commands/test_common_command/test_command_shows_description_when_use_help_option_py_3_11_example_.txt @@ -1,6 +1,6 @@ usage: cz example [-h] -show commit example +Show commit example options: -h, --help show this help message and exit diff --git a/tests/commands/test_common_command/test_command_shows_description_when_use_help_option_py_3_11_info_.txt b/tests/commands/test_common_command/test_command_shows_description_when_use_help_option_py_3_11_info_.txt index 99b1ba8a4a..ed5ae2522e 100644 --- a/tests/commands/test_common_command/test_command_shows_description_when_use_help_option_py_3_11_info_.txt +++ b/tests/commands/test_common_command/test_command_shows_description_when_use_help_option_py_3_11_info_.txt @@ -1,6 +1,6 @@ usage: cz info [-h] -show information about the cz +Show information about the cz options: -h, --help show this help message and exit diff --git a/tests/commands/test_common_command/test_command_shows_description_when_use_help_option_py_3_11_init_.txt b/tests/commands/test_common_command/test_command_shows_description_when_use_help_option_py_3_11_init_.txt index 0f72042f88..546ab51cb3 100644 --- a/tests/commands/test_common_command/test_command_shows_description_when_use_help_option_py_3_11_init_.txt +++ b/tests/commands/test_common_command/test_command_shows_description_when_use_help_option_py_3_11_init_.txt @@ -1,6 +1,6 @@ usage: cz init [-h] -init commitizen configuration +Initialize commitizen configuration options: -h, --help show this help message and exit diff --git a/tests/commands/test_common_command/test_command_shows_description_when_use_help_option_py_3_11_ls_.txt b/tests/commands/test_common_command/test_command_shows_description_when_use_help_option_py_3_11_ls_.txt index 5fa8fe1f79..253da1722c 100644 --- a/tests/commands/test_common_command/test_command_shows_description_when_use_help_option_py_3_11_ls_.txt +++ b/tests/commands/test_common_command/test_command_shows_description_when_use_help_option_py_3_11_ls_.txt @@ -1,6 +1,6 @@ usage: cz ls [-h] -show available commitizens +Show available Commitizens options: -h, --help show this help message and exit diff --git a/tests/commands/test_common_command/test_command_shows_description_when_use_help_option_py_3_11_schema_.txt b/tests/commands/test_common_command/test_command_shows_description_when_use_help_option_py_3_11_schema_.txt index 6666db4d41..dd05ead81b 100644 --- a/tests/commands/test_common_command/test_command_shows_description_when_use_help_option_py_3_11_schema_.txt +++ b/tests/commands/test_common_command/test_command_shows_description_when_use_help_option_py_3_11_schema_.txt @@ -1,6 +1,6 @@ usage: cz schema [-h] -show commit schema +Show commit schema options: -h, --help show this help message and exit diff --git a/tests/commands/test_common_command/test_command_shows_description_when_use_help_option_py_3_11_version_.txt b/tests/commands/test_common_command/test_command_shows_description_when_use_help_option_py_3_11_version_.txt index a194615a98..0061a97514 100644 --- a/tests/commands/test_common_command/test_command_shows_description_when_use_help_option_py_3_11_version_.txt +++ b/tests/commands/test_common_command/test_command_shows_description_when_use_help_option_py_3_11_version_.txt @@ -1,16 +1,16 @@ usage: cz version [-h] [-r | -p | -c | -v] [--major | --minor] -get the version of the installed commitizen or the current project (default: +Get the version of the installed commitizen or the current project (default: installed commitizen) options: -h, --help show this help message and exit - -r, --report get system information for reporting bugs - -p, --project get the version of the current project - -c, --commitizen get the version of the installed commitizen - -v, --verbose get the version of both the installed commitizen and the - current project - --major get just the major version. Need to be used with --project + -r, --report Output the system information for reporting bugs. + -p, --project Output the version of the current project. + -c, --commitizen Output the version of the installed commitizen. + -v, --verbose Output the version of both the installed commitizen and + the current project. + --major Output just the major version. Must be used with --project or --verbose. - --minor get just the minor version. Need to be used with --project + --minor Output just the minor version. Must be used with --project or --verbose. diff --git a/tests/commands/test_common_command/test_command_shows_description_when_use_help_option_py_3_12_bump_.txt b/tests/commands/test_common_command/test_command_shows_description_when_use_help_option_py_3_12_bump_.txt index ad0a693278..d56e739277 100644 --- a/tests/commands/test_common_command/test_command_shows_description_when_use_help_option_py_3_12_bump_.txt +++ b/tests/commands/test_common_command/test_command_shows_description_when_use_help_option_py_3_12_bump_.txt @@ -14,69 +14,71 @@ usage: cz bump [-h] [--dry-run] [--files-only] [--local-version] [--changelog] [--allow-no-commit] [MANUAL_VERSION] -bump semantic version based on the git log +Bump semantic version based on the git log positional arguments: - MANUAL_VERSION bump to the given version (e.g: 1.5.3) + MANUAL_VERSION Bump to the given version (e.g., 1.5.3). options: -h, --help show this help message and exit - --dry-run show output to stdout, no commit, no modified files - --files-only bump version in the files from the config - --local-version bump only the local version portion - --changelog, -ch generate the changelog for the newest version - --no-verify this option bypasses the pre-commit and commit-msg - hooks - --yes accept automatically questions done + --dry-run Perform a dry run, without committing or modifying + files. + --files-only Bump version in the `version_files` specified in the + configuration file only. + --local-version Bump version only the local version portion (ignoring + the public version). + --changelog, -ch Generate the changelog for the latest version. + --no-verify Bypass the pre-commit and commit-msg hooks. + --yes Accept automatically answered questions. --tag-format TAG_FORMAT - the format used to tag the commit and read it, use it - in existing projects, wrap around simple quotes + The format used to tag the commit and read it. Use it + in existing projects, and wrap around simple quotes. --bump-message BUMP_MESSAGE - template used to create the release commit, useful - when working with CI + Template used to create the release commit, useful + when working with CI. --prerelease {alpha,beta,rc}, -pr {alpha,beta,rc} - choose type of prerelease + Type of prerelease. --devrelease DEVRELEASE, -d DEVRELEASE - specify non-negative integer for dev. release + Specify non-negative integer for dev release. --increment {MAJOR,MINOR,PATCH} - manually specify the desired increment + Specify the desired increment. --increment-mode {linear,exact} - set the method by which the new version is chosen. - 'linear' (default) guesses the next version based on - typical linear version progression, such that bumping - of a pre-release with lower precedence than the - current pre-release phase maintains the current phase - of higher precedence. 'exact' applies the changes that + Set the method by which the new version is chosen. + 'linear' (default) resolves the next version based on + typical linear version progression, where bumping of a + pre-release with lower precedence than the current + pre-release phase maintains the current phase of + higher precedence. 'exact' applies the changes that have been specified (or determined from the commit - log) without interpretation, such that the increment - and pre-release are always honored + log) without interpretation, ensuring the increment + and pre-release are always honored. --check-consistency, -cc - check consistency among versions defined in commitizen - configuration and version_files - --annotated-tag, -at create annotated tag instead of lightweight one + Check consistency among versions defined in Commitizen + configuration file and `version_files`. + --annotated-tag, -at Create annotated tag instead of lightweight one. --annotated-tag-message ANNOTATED_TAG_MESSAGE, -atm ANNOTATED_TAG_MESSAGE - create annotated tag message - --gpg-sign, -s sign tag instead of lightweight one + Create annotated tag message. + --gpg-sign, -s Sign tag instead of lightweight one. --changelog-to-stdout - Output changelog to the stdout + Output changelog to stdout. --git-output-to-stderr - Redirect git output to stderr - --retry retry commit if it fails the 1st time - --major-version-zero keep major version at zero, even for breaking changes + Redirect git output to stderr. + --retry Retry commit if it fails for the first time. + --major-version-zero Keep major version at zero, even for breaking changes. --template TEMPLATE, -t TEMPLATE - changelog template file name (relative to the current - working directory) + Changelog template file name (relative to the current + working directory). --extra EXTRA, -e EXTRA - a changelog extra variable (in the form 'key=value') + Changelog extra variables (in the form 'key=value'). --file-name FILE_NAME - file name of changelog (default: 'CHANGELOG.md') + File name of changelog (default: 'CHANGELOG.md'). --prerelease-offset PRERELEASE_OFFSET - start pre-releases with this offset + Start pre-releases with this offset. --version-scheme {pep440,semver,semver2} - choose version scheme + Choose version scheme. --version-type {pep440,semver,semver2} - Deprecated, use --version-scheme instead + Deprecated, use `--version-scheme` instead. --build-metadata BUILD_METADATA - Add additional build-metadata to the version-number - --get-next Determine the next version and write to stdout - --allow-no-commit bump version without eligible commits + Add additional build-metadata to the version-number. + --get-next Determine the next version and write to stdout. + --allow-no-commit Bump version without eligible commits. diff --git a/tests/commands/test_common_command/test_command_shows_description_when_use_help_option_py_3_12_changelog_.txt b/tests/commands/test_common_command/test_command_shows_description_when_use_help_option_py_3_12_changelog_.txt index f4aa1ca2a6..2d1135af74 100644 --- a/tests/commands/test_common_command/test_command_shows_description_when_use_help_option_py_3_12_changelog_.txt +++ b/tests/commands/test_common_command/test_command_shows_description_when_use_help_option_py_3_12_changelog_.txt @@ -6,37 +6,37 @@ usage: cz changelog [-h] [--dry-run] [--file-name FILE_NAME] [--extra EXTRA] [--tag-format TAG_FORMAT] [rev_range] -generate changelog (note that it will overwrite existing file) +Generate changelog (note that it will overwrite existing files) positional arguments: - rev_range generates changelog for the given version (e.g: 1.5.3) - or version range (e.g: 1.5.3..1.7.9) + rev_range Generate changelog for the given version (e.g., 1.5.3) + or version range (e.g., 1.5.3..1.7.9). options: -h, --help show this help message and exit - --dry-run show changelog to stdout + --dry-run Show changelog to stdout. --file-name FILE_NAME - file name of changelog (default: 'CHANGELOG.md') + File name of changelog (default: 'CHANGELOG.md'). --unreleased-version UNRELEASED_VERSION - set the value for the new version (use the tag value), - instead of using unreleased - --incremental generates changelog from last created version, useful - if the changelog has been manually modified + Set the value for the new version (use the tag value), + instead of using unreleased versions. + --incremental Generate changelog from the last created version, + useful if the changelog has been manually modified. --start-rev START_REV - start rev of the changelog. If not set, it will - generate changelog from the start - --merge-prerelease collect all changes from prereleases into next non- - prerelease. If not set, it will include prereleases in - the changelog + Start rev of the changelog. If not set, it will + generate changelog from the beginning. + --merge-prerelease Collect all changes from prereleases into the next + non-prerelease. If not set, it will include + prereleases in the changelog. --version-scheme {pep440,semver,semver2} - choose version scheme + Choose version scheme. --export-template EXPORT_TEMPLATE Export the changelog template into this file instead - of rendering it + of rendering it. --template TEMPLATE, -t TEMPLATE - changelog template file name (relative to the current - working directory) + Changelog template file name (relative to the current + working directory). --extra EXTRA, -e EXTRA - a changelog extra variable (in the form 'key=value') + Changelog extra variables (in the form 'key=value'). --tag-format TAG_FORMAT - The format of the tag, wrap around simple quotes + The format of the tag, wrap around simple quotes. diff --git a/tests/commands/test_common_command/test_command_shows_description_when_use_help_option_py_3_12_check_.txt b/tests/commands/test_common_command/test_command_shows_description_when_use_help_option_py_3_12_check_.txt index 53c4e7ed10..144e91b61a 100644 --- a/tests/commands/test_common_command/test_command_shows_description_when_use_help_option_py_3_12_check_.txt +++ b/tests/commands/test_common_command/test_command_shows_description_when_use_help_option_py_3_12_check_.txt @@ -3,26 +3,27 @@ usage: cz check [-h] [--allow-abort] [--allowed-prefixes [ALLOWED_PREFIXES ...]] [-l MESSAGE_LENGTH_LIMIT] -validates that a commit message matches the commitizen schema +Validate that a commit message matches the commitizen schema options: -h, --help show this help message and exit --commit-msg-file COMMIT_MSG_FILE - ask for the name of the temporal file that contains - the commit message. Using it in a git hook script: - MSG_FILE=$1 + Ask for the name of the temporary file that contains + the commit message. Use it in a git hook script: + MSG_FILE=$1. --rev-range REV_RANGE - a range of git rev to check. e.g, master..HEAD + Validate the commits in the given range of git rev, + e.g., master..HEAD. -d, --use-default-range - check from the default branch to HEAD. e.g, - refs/remotes/origin/master..HEAD + Validate the commits from the default branch to HEAD, + e.g., refs/remotes/origin/master..HEAD. -m MESSAGE, --message MESSAGE - commit message that needs to be checked - --allow-abort allow empty commit messages, which typically abort a - commit + Validate the given commit message. + --allow-abort Allow empty commit messages, which typically abort a + commit. --allowed-prefixes [ALLOWED_PREFIXES ...] - allowed commit message prefixes. If the message starts - by one of these prefixes, the message won't be checked - against the regex + Skip validation for commit messages that start with + the specified prefixes. -l MESSAGE_LENGTH_LIMIT, --message-length-limit MESSAGE_LENGTH_LIMIT - length limit of the commit message; 0 for no limit + Restrict the length of the **first line** of the + commit message; 0 for no limit. diff --git a/tests/commands/test_common_command/test_command_shows_description_when_use_help_option_py_3_12_commit_.txt b/tests/commands/test_common_command/test_command_shows_description_when_use_help_option_py_3_12_commit_.txt index c842433427..bd256ccf8c 100644 --- a/tests/commands/test_common_command/test_command_shows_description_when_use_help_option_py_3_12_commit_.txt +++ b/tests/commands/test_common_command/test_command_shows_description_when_use_help_option_py_3_12_commit_.txt @@ -2,21 +2,24 @@ usage: cz commit [-h] [--retry] [--no-retry] [--dry-run] [--write-message-to-file FILE_PATH] [-s] [-a] [-e] [-l MESSAGE_LENGTH_LIMIT] [--] -create new commit +Create new commit options: -h, --help show this help message and exit - --retry retry last commit - --no-retry skip retry if retry_after_failure is set to true - --dry-run show output to stdout, no commit, no modified files + --retry Retry the last commit. + --no-retry Skip retry if --retry or `retry_after_failure` is set + to true. + --dry-run Perform a dry run, without committing or modifying + files. --write-message-to-file FILE_PATH - write message to file before committing (can be - combined with --dry-run) - -s, --signoff Deprecated, use 'cz commit -- -s' instead - -a, --all Tell the command to automatically stage files that - have been modified and deleted, but new files you have - not told Git about are not affected. - -e, --edit edit the commit message before committing + Write message to FILE_PATH before committing (can be + used with --dry-run). + -s, --signoff Deprecated, use `cz commit -- -s` instead. + -a, --all Automatically stage files that have been modified and + deleted, but new files you have not told Git about are + not affected. + -e, --edit Edit the commit message before committing. -l MESSAGE_LENGTH_LIMIT, --message-length-limit MESSAGE_LENGTH_LIMIT - length limit of the commit message; 0 for no limit - -- Positional arguments separator (recommended) + Set the length limit of the commit message; 0 for no + limit. + -- Positional arguments separator (recommended). diff --git a/tests/commands/test_common_command/test_command_shows_description_when_use_help_option_py_3_12_example_.txt b/tests/commands/test_common_command/test_command_shows_description_when_use_help_option_py_3_12_example_.txt index b9bf7f84fc..8a0f1c9d94 100644 --- a/tests/commands/test_common_command/test_command_shows_description_when_use_help_option_py_3_12_example_.txt +++ b/tests/commands/test_common_command/test_command_shows_description_when_use_help_option_py_3_12_example_.txt @@ -1,6 +1,6 @@ usage: cz example [-h] -show commit example +Show commit example options: -h, --help show this help message and exit diff --git a/tests/commands/test_common_command/test_command_shows_description_when_use_help_option_py_3_12_info_.txt b/tests/commands/test_common_command/test_command_shows_description_when_use_help_option_py_3_12_info_.txt index 99b1ba8a4a..ed5ae2522e 100644 --- a/tests/commands/test_common_command/test_command_shows_description_when_use_help_option_py_3_12_info_.txt +++ b/tests/commands/test_common_command/test_command_shows_description_when_use_help_option_py_3_12_info_.txt @@ -1,6 +1,6 @@ usage: cz info [-h] -show information about the cz +Show information about the cz options: -h, --help show this help message and exit diff --git a/tests/commands/test_common_command/test_command_shows_description_when_use_help_option_py_3_12_init_.txt b/tests/commands/test_common_command/test_command_shows_description_when_use_help_option_py_3_12_init_.txt index 0f72042f88..546ab51cb3 100644 --- a/tests/commands/test_common_command/test_command_shows_description_when_use_help_option_py_3_12_init_.txt +++ b/tests/commands/test_common_command/test_command_shows_description_when_use_help_option_py_3_12_init_.txt @@ -1,6 +1,6 @@ usage: cz init [-h] -init commitizen configuration +Initialize commitizen configuration options: -h, --help show this help message and exit diff --git a/tests/commands/test_common_command/test_command_shows_description_when_use_help_option_py_3_12_ls_.txt b/tests/commands/test_common_command/test_command_shows_description_when_use_help_option_py_3_12_ls_.txt index 5fa8fe1f79..253da1722c 100644 --- a/tests/commands/test_common_command/test_command_shows_description_when_use_help_option_py_3_12_ls_.txt +++ b/tests/commands/test_common_command/test_command_shows_description_when_use_help_option_py_3_12_ls_.txt @@ -1,6 +1,6 @@ usage: cz ls [-h] -show available commitizens +Show available Commitizens options: -h, --help show this help message and exit diff --git a/tests/commands/test_common_command/test_command_shows_description_when_use_help_option_py_3_12_schema_.txt b/tests/commands/test_common_command/test_command_shows_description_when_use_help_option_py_3_12_schema_.txt index 6666db4d41..dd05ead81b 100644 --- a/tests/commands/test_common_command/test_command_shows_description_when_use_help_option_py_3_12_schema_.txt +++ b/tests/commands/test_common_command/test_command_shows_description_when_use_help_option_py_3_12_schema_.txt @@ -1,6 +1,6 @@ usage: cz schema [-h] -show commit schema +Show commit schema options: -h, --help show this help message and exit diff --git a/tests/commands/test_common_command/test_command_shows_description_when_use_help_option_py_3_12_version_.txt b/tests/commands/test_common_command/test_command_shows_description_when_use_help_option_py_3_12_version_.txt index a194615a98..0061a97514 100644 --- a/tests/commands/test_common_command/test_command_shows_description_when_use_help_option_py_3_12_version_.txt +++ b/tests/commands/test_common_command/test_command_shows_description_when_use_help_option_py_3_12_version_.txt @@ -1,16 +1,16 @@ usage: cz version [-h] [-r | -p | -c | -v] [--major | --minor] -get the version of the installed commitizen or the current project (default: +Get the version of the installed commitizen or the current project (default: installed commitizen) options: -h, --help show this help message and exit - -r, --report get system information for reporting bugs - -p, --project get the version of the current project - -c, --commitizen get the version of the installed commitizen - -v, --verbose get the version of both the installed commitizen and the - current project - --major get just the major version. Need to be used with --project + -r, --report Output the system information for reporting bugs. + -p, --project Output the version of the current project. + -c, --commitizen Output the version of the installed commitizen. + -v, --verbose Output the version of both the installed commitizen and + the current project. + --major Output just the major version. Must be used with --project or --verbose. - --minor get just the minor version. Need to be used with --project + --minor Output just the minor version. Must be used with --project or --verbose. diff --git a/tests/commands/test_common_command/test_command_shows_description_when_use_help_option_py_3_13_bump_.txt b/tests/commands/test_common_command/test_command_shows_description_when_use_help_option_py_3_13_bump_.txt index 4cf8e6c91b..c472a040e9 100644 --- a/tests/commands/test_common_command/test_command_shows_description_when_use_help_option_py_3_13_bump_.txt +++ b/tests/commands/test_common_command/test_command_shows_description_when_use_help_option_py_3_13_bump_.txt @@ -14,68 +14,70 @@ usage: cz bump [-h] [--dry-run] [--files-only] [--local-version] [--changelog] [--allow-no-commit] [MANUAL_VERSION] -bump semantic version based on the git log +Bump semantic version based on the git log positional arguments: - MANUAL_VERSION bump to the given version (e.g: 1.5.3) + MANUAL_VERSION Bump to the given version (e.g., 1.5.3). options: -h, --help show this help message and exit - --dry-run show output to stdout, no commit, no modified files - --files-only bump version in the files from the config - --local-version bump only the local version portion - --changelog, -ch generate the changelog for the newest version - --no-verify this option bypasses the pre-commit and commit-msg - hooks - --yes accept automatically questions done + --dry-run Perform a dry run, without committing or modifying + files. + --files-only Bump version in the `version_files` specified in the + configuration file only. + --local-version Bump version only the local version portion (ignoring + the public version). + --changelog, -ch Generate the changelog for the latest version. + --no-verify Bypass the pre-commit and commit-msg hooks. + --yes Accept automatically answered questions. --tag-format TAG_FORMAT - the format used to tag the commit and read it, use it - in existing projects, wrap around simple quotes + The format used to tag the commit and read it. Use it + in existing projects, and wrap around simple quotes. --bump-message BUMP_MESSAGE - template used to create the release commit, useful - when working with CI + Template used to create the release commit, useful + when working with CI. --prerelease, -pr {alpha,beta,rc} - choose type of prerelease + Type of prerelease. --devrelease, -d DEVRELEASE - specify non-negative integer for dev. release + Specify non-negative integer for dev release. --increment {MAJOR,MINOR,PATCH} - manually specify the desired increment + Specify the desired increment. --increment-mode {linear,exact} - set the method by which the new version is chosen. - 'linear' (default) guesses the next version based on - typical linear version progression, such that bumping - of a pre-release with lower precedence than the - current pre-release phase maintains the current phase - of higher precedence. 'exact' applies the changes that + Set the method by which the new version is chosen. + 'linear' (default) resolves the next version based on + typical linear version progression, where bumping of a + pre-release with lower precedence than the current + pre-release phase maintains the current phase of + higher precedence. 'exact' applies the changes that have been specified (or determined from the commit - log) without interpretation, such that the increment - and pre-release are always honored + log) without interpretation, ensuring the increment + and pre-release are always honored. --check-consistency, -cc - check consistency among versions defined in commitizen - configuration and version_files - --annotated-tag, -at create annotated tag instead of lightweight one + Check consistency among versions defined in Commitizen + configuration file and `version_files`. + --annotated-tag, -at Create annotated tag instead of lightweight one. --annotated-tag-message, -atm ANNOTATED_TAG_MESSAGE - create annotated tag message - --gpg-sign, -s sign tag instead of lightweight one + Create annotated tag message. + --gpg-sign, -s Sign tag instead of lightweight one. --changelog-to-stdout - Output changelog to the stdout + Output changelog to stdout. --git-output-to-stderr - Redirect git output to stderr - --retry retry commit if it fails the 1st time - --major-version-zero keep major version at zero, even for breaking changes + Redirect git output to stderr. + --retry Retry commit if it fails for the first time. + --major-version-zero Keep major version at zero, even for breaking changes. --template, -t TEMPLATE - changelog template file name (relative to the current - working directory) - --extra, -e EXTRA a changelog extra variable (in the form 'key=value') + Changelog template file name (relative to the current + working directory). + --extra, -e EXTRA Changelog extra variables (in the form 'key=value'). --file-name FILE_NAME - file name of changelog (default: 'CHANGELOG.md') + File name of changelog (default: 'CHANGELOG.md'). --prerelease-offset PRERELEASE_OFFSET - start pre-releases with this offset + Start pre-releases with this offset. --version-scheme {pep440,semver,semver2} - choose version scheme + Choose version scheme. --version-type {pep440,semver,semver2} - Deprecated, use --version-scheme instead + Deprecated, use `--version-scheme` instead. --build-metadata BUILD_METADATA - Add additional build-metadata to the version-number - --get-next Determine the next version and write to stdout - --allow-no-commit bump version without eligible commits + Add additional build-metadata to the version-number. + --get-next Determine the next version and write to stdout. + --allow-no-commit Bump version without eligible commits. diff --git a/tests/commands/test_common_command/test_command_shows_description_when_use_help_option_py_3_13_changelog_.txt b/tests/commands/test_common_command/test_command_shows_description_when_use_help_option_py_3_13_changelog_.txt index 91b7f389b5..50ab468d64 100644 --- a/tests/commands/test_common_command/test_command_shows_description_when_use_help_option_py_3_13_changelog_.txt +++ b/tests/commands/test_common_command/test_command_shows_description_when_use_help_option_py_3_13_changelog_.txt @@ -6,36 +6,36 @@ usage: cz changelog [-h] [--dry-run] [--file-name FILE_NAME] [--extra EXTRA] [--tag-format TAG_FORMAT] [rev_range] -generate changelog (note that it will overwrite existing file) +Generate changelog (note that it will overwrite existing files) positional arguments: - rev_range generates changelog for the given version (e.g: 1.5.3) - or version range (e.g: 1.5.3..1.7.9) + rev_range Generate changelog for the given version (e.g., 1.5.3) + or version range (e.g., 1.5.3..1.7.9). options: -h, --help show this help message and exit - --dry-run show changelog to stdout + --dry-run Show changelog to stdout. --file-name FILE_NAME - file name of changelog (default: 'CHANGELOG.md') + File name of changelog (default: 'CHANGELOG.md'). --unreleased-version UNRELEASED_VERSION - set the value for the new version (use the tag value), - instead of using unreleased - --incremental generates changelog from last created version, useful - if the changelog has been manually modified + Set the value for the new version (use the tag value), + instead of using unreleased versions. + --incremental Generate changelog from the last created version, + useful if the changelog has been manually modified. --start-rev START_REV - start rev of the changelog. If not set, it will - generate changelog from the start - --merge-prerelease collect all changes from prereleases into next non- - prerelease. If not set, it will include prereleases in - the changelog + Start rev of the changelog. If not set, it will + generate changelog from the beginning. + --merge-prerelease Collect all changes from prereleases into the next + non-prerelease. If not set, it will include + prereleases in the changelog. --version-scheme {pep440,semver,semver2} - choose version scheme + Choose version scheme. --export-template EXPORT_TEMPLATE Export the changelog template into this file instead - of rendering it + of rendering it. --template, -t TEMPLATE - changelog template file name (relative to the current - working directory) - --extra, -e EXTRA a changelog extra variable (in the form 'key=value') + Changelog template file name (relative to the current + working directory). + --extra, -e EXTRA Changelog extra variables (in the form 'key=value'). --tag-format TAG_FORMAT - The format of the tag, wrap around simple quotes + The format of the tag, wrap around simple quotes. diff --git a/tests/commands/test_common_command/test_command_shows_description_when_use_help_option_py_3_13_check_.txt b/tests/commands/test_common_command/test_command_shows_description_when_use_help_option_py_3_13_check_.txt index 4066748557..6f8297e1ee 100644 --- a/tests/commands/test_common_command/test_command_shows_description_when_use_help_option_py_3_13_check_.txt +++ b/tests/commands/test_common_command/test_command_shows_description_when_use_help_option_py_3_13_check_.txt @@ -3,26 +3,27 @@ usage: cz check [-h] [--commit-msg-file COMMIT_MSG_FILE | [--allowed-prefixes [ALLOWED_PREFIXES ...]] [-l MESSAGE_LENGTH_LIMIT] -validates that a commit message matches the commitizen schema +Validate that a commit message matches the commitizen schema options: -h, --help show this help message and exit --commit-msg-file COMMIT_MSG_FILE - ask for the name of the temporal file that contains - the commit message. Using it in a git hook script: - MSG_FILE=$1 + Ask for the name of the temporary file that contains + the commit message. Use it in a git hook script: + MSG_FILE=$1. --rev-range REV_RANGE - a range of git rev to check. e.g, master..HEAD + Validate the commits in the given range of git rev, + e.g., master..HEAD. -d, --use-default-range - check from the default branch to HEAD. e.g, - refs/remotes/origin/master..HEAD + Validate the commits from the default branch to HEAD, + e.g., refs/remotes/origin/master..HEAD. -m, --message MESSAGE - commit message that needs to be checked - --allow-abort allow empty commit messages, which typically abort a - commit + Validate the given commit message. + --allow-abort Allow empty commit messages, which typically abort a + commit. --allowed-prefixes [ALLOWED_PREFIXES ...] - allowed commit message prefixes. If the message starts - by one of these prefixes, the message won't be checked - against the regex + Skip validation for commit messages that start with + the specified prefixes. -l, --message-length-limit MESSAGE_LENGTH_LIMIT - length limit of the commit message; 0 for no limit + Restrict the length of the **first line** of the + commit message; 0 for no limit. diff --git a/tests/commands/test_common_command/test_command_shows_description_when_use_help_option_py_3_13_commit_.txt b/tests/commands/test_common_command/test_command_shows_description_when_use_help_option_py_3_13_commit_.txt index ba531042aa..cbd5780f6d 100644 --- a/tests/commands/test_common_command/test_command_shows_description_when_use_help_option_py_3_13_commit_.txt +++ b/tests/commands/test_common_command/test_command_shows_description_when_use_help_option_py_3_13_commit_.txt @@ -2,21 +2,24 @@ usage: cz commit [-h] [--retry] [--no-retry] [--dry-run] [--write-message-to-file FILE_PATH] [-s] [-a] [-e] [-l MESSAGE_LENGTH_LIMIT] [--] -create new commit +Create new commit options: -h, --help show this help message and exit - --retry retry last commit - --no-retry skip retry if retry_after_failure is set to true - --dry-run show output to stdout, no commit, no modified files + --retry Retry the last commit. + --no-retry Skip retry if --retry or `retry_after_failure` is set + to true. + --dry-run Perform a dry run, without committing or modifying + files. --write-message-to-file FILE_PATH - write message to file before committing (can be - combined with --dry-run) - -s, --signoff Deprecated, use 'cz commit -- -s' instead - -a, --all Tell the command to automatically stage files that - have been modified and deleted, but new files you have - not told Git about are not affected. - -e, --edit edit the commit message before committing + Write message to FILE_PATH before committing (can be + used with --dry-run). + -s, --signoff Deprecated, use `cz commit -- -s` instead. + -a, --all Automatically stage files that have been modified and + deleted, but new files you have not told Git about are + not affected. + -e, --edit Edit the commit message before committing. -l, --message-length-limit MESSAGE_LENGTH_LIMIT - length limit of the commit message; 0 for no limit - -- Positional arguments separator (recommended) + Set the length limit of the commit message; 0 for no + limit. + -- Positional arguments separator (recommended). diff --git a/tests/commands/test_common_command/test_command_shows_description_when_use_help_option_py_3_13_example_.txt b/tests/commands/test_common_command/test_command_shows_description_when_use_help_option_py_3_13_example_.txt index b9bf7f84fc..8a0f1c9d94 100644 --- a/tests/commands/test_common_command/test_command_shows_description_when_use_help_option_py_3_13_example_.txt +++ b/tests/commands/test_common_command/test_command_shows_description_when_use_help_option_py_3_13_example_.txt @@ -1,6 +1,6 @@ usage: cz example [-h] -show commit example +Show commit example options: -h, --help show this help message and exit diff --git a/tests/commands/test_common_command/test_command_shows_description_when_use_help_option_py_3_13_info_.txt b/tests/commands/test_common_command/test_command_shows_description_when_use_help_option_py_3_13_info_.txt index 99b1ba8a4a..ed5ae2522e 100644 --- a/tests/commands/test_common_command/test_command_shows_description_when_use_help_option_py_3_13_info_.txt +++ b/tests/commands/test_common_command/test_command_shows_description_when_use_help_option_py_3_13_info_.txt @@ -1,6 +1,6 @@ usage: cz info [-h] -show information about the cz +Show information about the cz options: -h, --help show this help message and exit diff --git a/tests/commands/test_common_command/test_command_shows_description_when_use_help_option_py_3_13_init_.txt b/tests/commands/test_common_command/test_command_shows_description_when_use_help_option_py_3_13_init_.txt index 0f72042f88..546ab51cb3 100644 --- a/tests/commands/test_common_command/test_command_shows_description_when_use_help_option_py_3_13_init_.txt +++ b/tests/commands/test_common_command/test_command_shows_description_when_use_help_option_py_3_13_init_.txt @@ -1,6 +1,6 @@ usage: cz init [-h] -init commitizen configuration +Initialize commitizen configuration options: -h, --help show this help message and exit diff --git a/tests/commands/test_common_command/test_command_shows_description_when_use_help_option_py_3_13_ls_.txt b/tests/commands/test_common_command/test_command_shows_description_when_use_help_option_py_3_13_ls_.txt index 5fa8fe1f79..253da1722c 100644 --- a/tests/commands/test_common_command/test_command_shows_description_when_use_help_option_py_3_13_ls_.txt +++ b/tests/commands/test_common_command/test_command_shows_description_when_use_help_option_py_3_13_ls_.txt @@ -1,6 +1,6 @@ usage: cz ls [-h] -show available commitizens +Show available Commitizens options: -h, --help show this help message and exit diff --git a/tests/commands/test_common_command/test_command_shows_description_when_use_help_option_py_3_13_schema_.txt b/tests/commands/test_common_command/test_command_shows_description_when_use_help_option_py_3_13_schema_.txt index 6666db4d41..dd05ead81b 100644 --- a/tests/commands/test_common_command/test_command_shows_description_when_use_help_option_py_3_13_schema_.txt +++ b/tests/commands/test_common_command/test_command_shows_description_when_use_help_option_py_3_13_schema_.txt @@ -1,6 +1,6 @@ usage: cz schema [-h] -show commit schema +Show commit schema options: -h, --help show this help message and exit diff --git a/tests/commands/test_common_command/test_command_shows_description_when_use_help_option_py_3_13_version_.txt b/tests/commands/test_common_command/test_command_shows_description_when_use_help_option_py_3_13_version_.txt index a194615a98..0061a97514 100644 --- a/tests/commands/test_common_command/test_command_shows_description_when_use_help_option_py_3_13_version_.txt +++ b/tests/commands/test_common_command/test_command_shows_description_when_use_help_option_py_3_13_version_.txt @@ -1,16 +1,16 @@ usage: cz version [-h] [-r | -p | -c | -v] [--major | --minor] -get the version of the installed commitizen or the current project (default: +Get the version of the installed commitizen or the current project (default: installed commitizen) options: -h, --help show this help message and exit - -r, --report get system information for reporting bugs - -p, --project get the version of the current project - -c, --commitizen get the version of the installed commitizen - -v, --verbose get the version of both the installed commitizen and the - current project - --major get just the major version. Need to be used with --project + -r, --report Output the system information for reporting bugs. + -p, --project Output the version of the current project. + -c, --commitizen Output the version of the installed commitizen. + -v, --verbose Output the version of both the installed commitizen and + the current project. + --major Output just the major version. Must be used with --project or --verbose. - --minor get just the minor version. Need to be used with --project + --minor Output just the minor version. Must be used with --project or --verbose. diff --git a/tests/commands/test_common_command/test_command_shows_description_when_use_help_option_py_3_14_bump_.txt b/tests/commands/test_common_command/test_command_shows_description_when_use_help_option_py_3_14_bump_.txt index 4cf8e6c91b..c472a040e9 100644 --- a/tests/commands/test_common_command/test_command_shows_description_when_use_help_option_py_3_14_bump_.txt +++ b/tests/commands/test_common_command/test_command_shows_description_when_use_help_option_py_3_14_bump_.txt @@ -14,68 +14,70 @@ usage: cz bump [-h] [--dry-run] [--files-only] [--local-version] [--changelog] [--allow-no-commit] [MANUAL_VERSION] -bump semantic version based on the git log +Bump semantic version based on the git log positional arguments: - MANUAL_VERSION bump to the given version (e.g: 1.5.3) + MANUAL_VERSION Bump to the given version (e.g., 1.5.3). options: -h, --help show this help message and exit - --dry-run show output to stdout, no commit, no modified files - --files-only bump version in the files from the config - --local-version bump only the local version portion - --changelog, -ch generate the changelog for the newest version - --no-verify this option bypasses the pre-commit and commit-msg - hooks - --yes accept automatically questions done + --dry-run Perform a dry run, without committing or modifying + files. + --files-only Bump version in the `version_files` specified in the + configuration file only. + --local-version Bump version only the local version portion (ignoring + the public version). + --changelog, -ch Generate the changelog for the latest version. + --no-verify Bypass the pre-commit and commit-msg hooks. + --yes Accept automatically answered questions. --tag-format TAG_FORMAT - the format used to tag the commit and read it, use it - in existing projects, wrap around simple quotes + The format used to tag the commit and read it. Use it + in existing projects, and wrap around simple quotes. --bump-message BUMP_MESSAGE - template used to create the release commit, useful - when working with CI + Template used to create the release commit, useful + when working with CI. --prerelease, -pr {alpha,beta,rc} - choose type of prerelease + Type of prerelease. --devrelease, -d DEVRELEASE - specify non-negative integer for dev. release + Specify non-negative integer for dev release. --increment {MAJOR,MINOR,PATCH} - manually specify the desired increment + Specify the desired increment. --increment-mode {linear,exact} - set the method by which the new version is chosen. - 'linear' (default) guesses the next version based on - typical linear version progression, such that bumping - of a pre-release with lower precedence than the - current pre-release phase maintains the current phase - of higher precedence. 'exact' applies the changes that + Set the method by which the new version is chosen. + 'linear' (default) resolves the next version based on + typical linear version progression, where bumping of a + pre-release with lower precedence than the current + pre-release phase maintains the current phase of + higher precedence. 'exact' applies the changes that have been specified (or determined from the commit - log) without interpretation, such that the increment - and pre-release are always honored + log) without interpretation, ensuring the increment + and pre-release are always honored. --check-consistency, -cc - check consistency among versions defined in commitizen - configuration and version_files - --annotated-tag, -at create annotated tag instead of lightweight one + Check consistency among versions defined in Commitizen + configuration file and `version_files`. + --annotated-tag, -at Create annotated tag instead of lightweight one. --annotated-tag-message, -atm ANNOTATED_TAG_MESSAGE - create annotated tag message - --gpg-sign, -s sign tag instead of lightweight one + Create annotated tag message. + --gpg-sign, -s Sign tag instead of lightweight one. --changelog-to-stdout - Output changelog to the stdout + Output changelog to stdout. --git-output-to-stderr - Redirect git output to stderr - --retry retry commit if it fails the 1st time - --major-version-zero keep major version at zero, even for breaking changes + Redirect git output to stderr. + --retry Retry commit if it fails for the first time. + --major-version-zero Keep major version at zero, even for breaking changes. --template, -t TEMPLATE - changelog template file name (relative to the current - working directory) - --extra, -e EXTRA a changelog extra variable (in the form 'key=value') + Changelog template file name (relative to the current + working directory). + --extra, -e EXTRA Changelog extra variables (in the form 'key=value'). --file-name FILE_NAME - file name of changelog (default: 'CHANGELOG.md') + File name of changelog (default: 'CHANGELOG.md'). --prerelease-offset PRERELEASE_OFFSET - start pre-releases with this offset + Start pre-releases with this offset. --version-scheme {pep440,semver,semver2} - choose version scheme + Choose version scheme. --version-type {pep440,semver,semver2} - Deprecated, use --version-scheme instead + Deprecated, use `--version-scheme` instead. --build-metadata BUILD_METADATA - Add additional build-metadata to the version-number - --get-next Determine the next version and write to stdout - --allow-no-commit bump version without eligible commits + Add additional build-metadata to the version-number. + --get-next Determine the next version and write to stdout. + --allow-no-commit Bump version without eligible commits. diff --git a/tests/commands/test_common_command/test_command_shows_description_when_use_help_option_py_3_14_changelog_.txt b/tests/commands/test_common_command/test_command_shows_description_when_use_help_option_py_3_14_changelog_.txt index 91b7f389b5..50ab468d64 100644 --- a/tests/commands/test_common_command/test_command_shows_description_when_use_help_option_py_3_14_changelog_.txt +++ b/tests/commands/test_common_command/test_command_shows_description_when_use_help_option_py_3_14_changelog_.txt @@ -6,36 +6,36 @@ usage: cz changelog [-h] [--dry-run] [--file-name FILE_NAME] [--extra EXTRA] [--tag-format TAG_FORMAT] [rev_range] -generate changelog (note that it will overwrite existing file) +Generate changelog (note that it will overwrite existing files) positional arguments: - rev_range generates changelog for the given version (e.g: 1.5.3) - or version range (e.g: 1.5.3..1.7.9) + rev_range Generate changelog for the given version (e.g., 1.5.3) + or version range (e.g., 1.5.3..1.7.9). options: -h, --help show this help message and exit - --dry-run show changelog to stdout + --dry-run Show changelog to stdout. --file-name FILE_NAME - file name of changelog (default: 'CHANGELOG.md') + File name of changelog (default: 'CHANGELOG.md'). --unreleased-version UNRELEASED_VERSION - set the value for the new version (use the tag value), - instead of using unreleased - --incremental generates changelog from last created version, useful - if the changelog has been manually modified + Set the value for the new version (use the tag value), + instead of using unreleased versions. + --incremental Generate changelog from the last created version, + useful if the changelog has been manually modified. --start-rev START_REV - start rev of the changelog. If not set, it will - generate changelog from the start - --merge-prerelease collect all changes from prereleases into next non- - prerelease. If not set, it will include prereleases in - the changelog + Start rev of the changelog. If not set, it will + generate changelog from the beginning. + --merge-prerelease Collect all changes from prereleases into the next + non-prerelease. If not set, it will include + prereleases in the changelog. --version-scheme {pep440,semver,semver2} - choose version scheme + Choose version scheme. --export-template EXPORT_TEMPLATE Export the changelog template into this file instead - of rendering it + of rendering it. --template, -t TEMPLATE - changelog template file name (relative to the current - working directory) - --extra, -e EXTRA a changelog extra variable (in the form 'key=value') + Changelog template file name (relative to the current + working directory). + --extra, -e EXTRA Changelog extra variables (in the form 'key=value'). --tag-format TAG_FORMAT - The format of the tag, wrap around simple quotes + The format of the tag, wrap around simple quotes. diff --git a/tests/commands/test_common_command/test_command_shows_description_when_use_help_option_py_3_14_check_.txt b/tests/commands/test_common_command/test_command_shows_description_when_use_help_option_py_3_14_check_.txt index 4066748557..6f8297e1ee 100644 --- a/tests/commands/test_common_command/test_command_shows_description_when_use_help_option_py_3_14_check_.txt +++ b/tests/commands/test_common_command/test_command_shows_description_when_use_help_option_py_3_14_check_.txt @@ -3,26 +3,27 @@ usage: cz check [-h] [--commit-msg-file COMMIT_MSG_FILE | [--allowed-prefixes [ALLOWED_PREFIXES ...]] [-l MESSAGE_LENGTH_LIMIT] -validates that a commit message matches the commitizen schema +Validate that a commit message matches the commitizen schema options: -h, --help show this help message and exit --commit-msg-file COMMIT_MSG_FILE - ask for the name of the temporal file that contains - the commit message. Using it in a git hook script: - MSG_FILE=$1 + Ask for the name of the temporary file that contains + the commit message. Use it in a git hook script: + MSG_FILE=$1. --rev-range REV_RANGE - a range of git rev to check. e.g, master..HEAD + Validate the commits in the given range of git rev, + e.g., master..HEAD. -d, --use-default-range - check from the default branch to HEAD. e.g, - refs/remotes/origin/master..HEAD + Validate the commits from the default branch to HEAD, + e.g., refs/remotes/origin/master..HEAD. -m, --message MESSAGE - commit message that needs to be checked - --allow-abort allow empty commit messages, which typically abort a - commit + Validate the given commit message. + --allow-abort Allow empty commit messages, which typically abort a + commit. --allowed-prefixes [ALLOWED_PREFIXES ...] - allowed commit message prefixes. If the message starts - by one of these prefixes, the message won't be checked - against the regex + Skip validation for commit messages that start with + the specified prefixes. -l, --message-length-limit MESSAGE_LENGTH_LIMIT - length limit of the commit message; 0 for no limit + Restrict the length of the **first line** of the + commit message; 0 for no limit. diff --git a/tests/commands/test_common_command/test_command_shows_description_when_use_help_option_py_3_14_commit_.txt b/tests/commands/test_common_command/test_command_shows_description_when_use_help_option_py_3_14_commit_.txt index ba531042aa..cbd5780f6d 100644 --- a/tests/commands/test_common_command/test_command_shows_description_when_use_help_option_py_3_14_commit_.txt +++ b/tests/commands/test_common_command/test_command_shows_description_when_use_help_option_py_3_14_commit_.txt @@ -2,21 +2,24 @@ usage: cz commit [-h] [--retry] [--no-retry] [--dry-run] [--write-message-to-file FILE_PATH] [-s] [-a] [-e] [-l MESSAGE_LENGTH_LIMIT] [--] -create new commit +Create new commit options: -h, --help show this help message and exit - --retry retry last commit - --no-retry skip retry if retry_after_failure is set to true - --dry-run show output to stdout, no commit, no modified files + --retry Retry the last commit. + --no-retry Skip retry if --retry or `retry_after_failure` is set + to true. + --dry-run Perform a dry run, without committing or modifying + files. --write-message-to-file FILE_PATH - write message to file before committing (can be - combined with --dry-run) - -s, --signoff Deprecated, use 'cz commit -- -s' instead - -a, --all Tell the command to automatically stage files that - have been modified and deleted, but new files you have - not told Git about are not affected. - -e, --edit edit the commit message before committing + Write message to FILE_PATH before committing (can be + used with --dry-run). + -s, --signoff Deprecated, use `cz commit -- -s` instead. + -a, --all Automatically stage files that have been modified and + deleted, but new files you have not told Git about are + not affected. + -e, --edit Edit the commit message before committing. -l, --message-length-limit MESSAGE_LENGTH_LIMIT - length limit of the commit message; 0 for no limit - -- Positional arguments separator (recommended) + Set the length limit of the commit message; 0 for no + limit. + -- Positional arguments separator (recommended). diff --git a/tests/commands/test_common_command/test_command_shows_description_when_use_help_option_py_3_14_example_.txt b/tests/commands/test_common_command/test_command_shows_description_when_use_help_option_py_3_14_example_.txt index b9bf7f84fc..8a0f1c9d94 100644 --- a/tests/commands/test_common_command/test_command_shows_description_when_use_help_option_py_3_14_example_.txt +++ b/tests/commands/test_common_command/test_command_shows_description_when_use_help_option_py_3_14_example_.txt @@ -1,6 +1,6 @@ usage: cz example [-h] -show commit example +Show commit example options: -h, --help show this help message and exit diff --git a/tests/commands/test_common_command/test_command_shows_description_when_use_help_option_py_3_14_info_.txt b/tests/commands/test_common_command/test_command_shows_description_when_use_help_option_py_3_14_info_.txt index 99b1ba8a4a..ed5ae2522e 100644 --- a/tests/commands/test_common_command/test_command_shows_description_when_use_help_option_py_3_14_info_.txt +++ b/tests/commands/test_common_command/test_command_shows_description_when_use_help_option_py_3_14_info_.txt @@ -1,6 +1,6 @@ usage: cz info [-h] -show information about the cz +Show information about the cz options: -h, --help show this help message and exit diff --git a/tests/commands/test_common_command/test_command_shows_description_when_use_help_option_py_3_14_init_.txt b/tests/commands/test_common_command/test_command_shows_description_when_use_help_option_py_3_14_init_.txt index 0f72042f88..546ab51cb3 100644 --- a/tests/commands/test_common_command/test_command_shows_description_when_use_help_option_py_3_14_init_.txt +++ b/tests/commands/test_common_command/test_command_shows_description_when_use_help_option_py_3_14_init_.txt @@ -1,6 +1,6 @@ usage: cz init [-h] -init commitizen configuration +Initialize commitizen configuration options: -h, --help show this help message and exit diff --git a/tests/commands/test_common_command/test_command_shows_description_when_use_help_option_py_3_14_ls_.txt b/tests/commands/test_common_command/test_command_shows_description_when_use_help_option_py_3_14_ls_.txt index 5fa8fe1f79..253da1722c 100644 --- a/tests/commands/test_common_command/test_command_shows_description_when_use_help_option_py_3_14_ls_.txt +++ b/tests/commands/test_common_command/test_command_shows_description_when_use_help_option_py_3_14_ls_.txt @@ -1,6 +1,6 @@ usage: cz ls [-h] -show available commitizens +Show available Commitizens options: -h, --help show this help message and exit diff --git a/tests/commands/test_common_command/test_command_shows_description_when_use_help_option_py_3_14_schema_.txt b/tests/commands/test_common_command/test_command_shows_description_when_use_help_option_py_3_14_schema_.txt index 6666db4d41..dd05ead81b 100644 --- a/tests/commands/test_common_command/test_command_shows_description_when_use_help_option_py_3_14_schema_.txt +++ b/tests/commands/test_common_command/test_command_shows_description_when_use_help_option_py_3_14_schema_.txt @@ -1,6 +1,6 @@ usage: cz schema [-h] -show commit schema +Show commit schema options: -h, --help show this help message and exit diff --git a/tests/commands/test_common_command/test_command_shows_description_when_use_help_option_py_3_14_version_.txt b/tests/commands/test_common_command/test_command_shows_description_when_use_help_option_py_3_14_version_.txt index a194615a98..0061a97514 100644 --- a/tests/commands/test_common_command/test_command_shows_description_when_use_help_option_py_3_14_version_.txt +++ b/tests/commands/test_common_command/test_command_shows_description_when_use_help_option_py_3_14_version_.txt @@ -1,16 +1,16 @@ usage: cz version [-h] [-r | -p | -c | -v] [--major | --minor] -get the version of the installed commitizen or the current project (default: +Get the version of the installed commitizen or the current project (default: installed commitizen) options: -h, --help show this help message and exit - -r, --report get system information for reporting bugs - -p, --project get the version of the current project - -c, --commitizen get the version of the installed commitizen - -v, --verbose get the version of both the installed commitizen and the - current project - --major get just the major version. Need to be used with --project + -r, --report Output the system information for reporting bugs. + -p, --project Output the version of the current project. + -c, --commitizen Output the version of the installed commitizen. + -v, --verbose Output the version of both the installed commitizen and + the current project. + --major Output just the major version. Must be used with --project or --verbose. - --minor get just the minor version. Need to be used with --project + --minor Output just the minor version. Must be used with --project or --verbose. From ac2b31d769d8c46d37a72bbc8b1432d0513fa37e Mon Sep 17 00:00:00 2001 From: Tim Hsiung Date: Sat, 31 Jan 2026 14:40:52 +0800 Subject: [PATCH 08/19] fix(message_length_limit): align the behavior of message_length_limit (#1813) --- commitizen/commands/check.py | 4 +- commitizen/commands/commit.py | 22 ++++++---- commitizen/cz/base.py | 2 +- commitizen/defaults.py | 4 +- tests/commands/test_check_command.py | 59 +-------------------------- tests/commands/test_commit_command.py | 2 +- tests/test_conf.py | 4 +- 7 files changed, 23 insertions(+), 74 deletions(-) diff --git a/commitizen/commands/check.py b/commitizen/commands/check.py index 8ec5b47f8d..182839910d 100644 --- a/commitizen/commands/check.py +++ b/commitizen/commands/check.py @@ -20,7 +20,7 @@ class CheckArgs(TypedDict, total=False): commit_msg: str rev_range: str allow_abort: bool - message_length_limit: int | None + message_length_limit: int allowed_prefixes: list[str] message: str use_default_range: bool @@ -46,7 +46,7 @@ def __init__(self, config: BaseConfig, arguments: CheckArgs, *args: object) -> N self.use_default_range = bool(arguments.get("use_default_range")) self.max_msg_length = arguments.get( - "message_length_limit", config.settings.get("message_length_limit", None) + "message_length_limit", config.settings.get("message_length_limit", 0) ) # we need to distinguish between None and [], which is a valid value diff --git a/commitizen/commands/commit.py b/commitizen/commands/commit.py index 3894d0b77e..5776af4201 100644 --- a/commitizen/commands/commit.py +++ b/commitizen/commands/commit.py @@ -36,7 +36,7 @@ class CommitArgs(TypedDict, total=False): dry_run: bool edit: bool extra_cli_args: str - message_length_limit: int | None + message_length_limit: int no_retry: bool signoff: bool write_message_to_file: Path | None @@ -83,19 +83,23 @@ def _get_message_by_prompt_commit_questions(self) -> str: raise NoAnswersError() message = self.cz.message(answers) - if limit := self.arguments.get( - "message_length_limit", self.config.settings.get("message_length_limit", 0) - ): - self._validate_subject_length(message=message, length_limit=limit) - + self._validate_subject_length(message) return message - def _validate_subject_length(self, *, message: str, length_limit: int) -> None: + def _validate_subject_length(self, message: str) -> None: + message_length_limit = self.arguments.get( + "message_length_limit", self.config.settings.get("message_length_limit", 0) + ) # By the contract, message_length_limit is set to 0 for no limit + if ( + message_length_limit is None or message_length_limit <= 0 + ): # do nothing for no limit + return + subject = message.partition("\n")[0].strip() - if len(subject) > length_limit: + if len(subject) > message_length_limit: raise CommitMessageLengthExceededError( - f"Length of commit message exceeds limit ({len(subject)}/{length_limit}), subject: '{subject}'" + f"Length of commit message exceeds limit ({len(subject)}/{message_length_limit}), subject: '{subject}'" ) def manual_edit(self, message: str) -> str: diff --git a/commitizen/cz/base.py b/commitizen/cz/base.py index 90633c42e6..5e7f2663ca 100644 --- a/commitizen/cz/base.py +++ b/commitizen/cz/base.py @@ -130,7 +130,7 @@ def validate_commit_message( if any(map(commit_msg.startswith, allowed_prefixes)): return ValidationResult(True, []) - if max_msg_length is not None: + if max_msg_length is not None and max_msg_length > 0: msg_len = len(commit_msg.partition("\n")[0].strip()) if msg_len > max_msg_length: # TODO: capitalize the first letter of the error message for consistency in v5 diff --git a/commitizen/defaults.py b/commitizen/defaults.py index 6de41f63d1..4865ccc188 100644 --- a/commitizen/defaults.py +++ b/commitizen/defaults.py @@ -48,7 +48,7 @@ class Settings(TypedDict, total=False): ignored_tag_formats: Sequence[str] legacy_tag_formats: Sequence[str] major_version_zero: bool - message_length_limit: int | None + message_length_limit: int name: str post_bump_hooks: list[str] | None pre_bump_hooks: list[str] | None @@ -114,7 +114,7 @@ class Settings(TypedDict, total=False): "template": None, # default provided by plugin "extras": {}, "breaking_change_exclamation_in_title": False, - "message_length_limit": None, # None for no limit + "message_length_limit": 0, # 0 for no limit } MAJOR = "MAJOR" diff --git a/tests/commands/test_check_command.py b/tests/commands/test_check_command.py index b5e3fd2b08..f225e912ea 100644 --- a/tests/commands/test_check_command.py +++ b/tests/commands/test_check_command.py @@ -7,7 +7,7 @@ from commitizen import commands, git from commitizen.cz import registry -from commitizen.cz.base import BaseCommitizen, ValidationResult +from commitizen.cz.base import BaseCommitizen from commitizen.exceptions import ( CommitMessageLengthExceededError, InvalidCommandArgumentError, @@ -16,7 +16,6 @@ ) if TYPE_CHECKING: - import re from collections.abc import Mapping from pytest_mock import MockFixture, MockType @@ -385,7 +384,7 @@ def test_check_command_cli_overrides_config_message_length_limit( ): message = "fix(scope): some commit message" config.settings["message_length_limit"] = len(message) - 1 - for message_length_limit in [len(message) + 1, None]: + for message_length_limit in [len(message) + 1, 0]: success_mock.reset_mock() commands.Check( config=config, @@ -419,60 +418,6 @@ def example(self) -> str: def info(self) -> str: return "Commit message must start with an issue number like ABC-123" - def validate_commit_message( - self, - *, - commit_msg: str, - pattern: re.Pattern[str], - allow_abort: bool, - allowed_prefixes: list[str], - max_msg_length: int | None, - commit_hash: str, - ) -> ValidationResult: - """Validate commit message against the pattern.""" - if not commit_msg: - return ValidationResult( - allow_abort, [] if allow_abort else ["commit message is empty"] - ) - - if any(map(commit_msg.startswith, allowed_prefixes)): - return ValidationResult(True, []) - - if max_msg_length: - msg_len = len(commit_msg.partition("\n")[0].strip()) - if msg_len > max_msg_length: - # TODO: capitalize the first letter of the error message for consistency in v5 - raise CommitMessageLengthExceededError( - f"commit validation: failed!\n" - f"commit message length exceeds the limit.\n" - f'commit "{commit_hash}": "{commit_msg}"\n' - f"message length limit: {max_msg_length} (actual: {msg_len})" - ) - - return ValidationResult( - bool(pattern.match(commit_msg)), [f"pattern: {pattern.pattern}"] - ) - - def format_exception_message( - self, invalid_commits: list[tuple[git.GitCommit, list]] - ) -> str: - """Format commit errors.""" - displayed_msgs_content = "\n".join( - [ - ( - f'commit "{commit.rev}": "{commit.message}"\nerrors:\n\n'.join( - f"- {error}" for error in errors - ) - ) - for (commit, errors) in invalid_commits - ] - ) - return ( - "commit validation: failed!\n" - "please enter a commit message in the commitizen format.\n" - f"{displayed_msgs_content}" - ) - @pytest.fixture def use_cz_custom_validator(mocker): diff --git a/tests/commands/test_commit_command.py b/tests/commands/test_commit_command.py index 87c7aca42c..89a9224b85 100644 --- a/tests/commands/test_commit_command.py +++ b/tests/commands/test_commit_command.py @@ -363,5 +363,5 @@ def test_commit_command_with_config_message_length_limit( success_mock.assert_called_once() success_mock.reset_mock() - commands.Commit(config, {"message_length_limit": None})() + commands.Commit(config, {"message_length_limit": 0})() success_mock.assert_called_once() diff --git a/tests/test_conf.py b/tests/test_conf.py index 6e4256f162..ee5eba5b3c 100644 --- a/tests/test_conf.py +++ b/tests/test_conf.py @@ -106,7 +106,7 @@ "template": None, "extras": {}, "breaking_change_exclamation_in_title": False, - "message_length_limit": None, + "message_length_limit": 0, } _new_settings: dict[str, Any] = { @@ -146,7 +146,7 @@ "template": None, "extras": {}, "breaking_change_exclamation_in_title": False, - "message_length_limit": None, + "message_length_limit": 0, } From 215fe364ac2f085af39a67d1e0f6fdecd285498d Mon Sep 17 00:00:00 2001 From: Yu-Ting Hsiung Date: Sat, 31 Jan 2026 14:48:33 +0800 Subject: [PATCH 09/19] test: update test files --- tests/test_cli/test_no_argv_py_3_10_.txt | 38 ++++++++++++------------ tests/test_cli/test_no_argv_py_3_11_.txt | 38 ++++++++++++------------ tests/test_cli/test_no_argv_py_3_12_.txt | 38 ++++++++++++------------ tests/test_cli/test_no_argv_py_3_13_.txt | 38 ++++++++++++------------ tests/test_cli/test_no_argv_py_3_14_.txt | 38 ++++++++++++------------ 5 files changed, 95 insertions(+), 95 deletions(-) diff --git a/tests/test_cli/test_no_argv_py_3_10_.txt b/tests/test_cli/test_no_argv_py_3_10_.txt index 691c75a86f..69f410e96d 100644 --- a/tests/test_cli/test_no_argv_py_3_10_.txt +++ b/tests/test_cli/test_no_argv_py_3_10_.txt @@ -7,28 +7,28 @@ For more information, please visit https://commitizen-tools.github.io/commitizen options: -h, --help show this help message and exit - --config CONFIG the path of configuration file - --debug use debug mode - -n NAME, --name NAME use the given commitizen (default: - cz_conventional_commits) + --config CONFIG The path to the configuration file. + --debug Use debug mode. + -n NAME, --name NAME Use the given commitizen (default: + cz_conventional_commits). -nr NO_RAISE, --no-raise NO_RAISE - comma separated error codes that won't raise error, - e.g: cz -nr 1,2,3 bump. See codes at + Comma-separated error codes that won't raise error, + e.g., cz -nr 1,2,3 bump. See codes at https://commitizen- tools.github.io/commitizen/exit_codes/ commands: {init,commit,c,ls,example,info,schema,bump,changelog,ch,check,version} - init init commitizen configuration - commit (c) create new commit - ls show available commitizens - example show commit example - info show information about the cz - schema show commit schema - bump bump semantic version based on the git log - changelog (ch) generate changelog (note that it will overwrite - existing file) - check validates that a commit message matches the commitizen - schema - version get the version of the installed commitizen or the - current project (default: installed commitizen) + init Initialize commitizen configuration. + commit (c) Create new commit. + ls Show available Commitizens. + example Show commit example. + info Show information about the cz. + schema Show commit schema. + bump Bump semantic version based on the git log. + changelog (ch) Generate changelog (note that it will overwrite + existing files). + check Validate that a commit message matches the commitizen + schema. + version Get the version of the installed commitizen or the + current project (default: installed commitizen). diff --git a/tests/test_cli/test_no_argv_py_3_11_.txt b/tests/test_cli/test_no_argv_py_3_11_.txt index 691c75a86f..69f410e96d 100644 --- a/tests/test_cli/test_no_argv_py_3_11_.txt +++ b/tests/test_cli/test_no_argv_py_3_11_.txt @@ -7,28 +7,28 @@ For more information, please visit https://commitizen-tools.github.io/commitizen options: -h, --help show this help message and exit - --config CONFIG the path of configuration file - --debug use debug mode - -n NAME, --name NAME use the given commitizen (default: - cz_conventional_commits) + --config CONFIG The path to the configuration file. + --debug Use debug mode. + -n NAME, --name NAME Use the given commitizen (default: + cz_conventional_commits). -nr NO_RAISE, --no-raise NO_RAISE - comma separated error codes that won't raise error, - e.g: cz -nr 1,2,3 bump. See codes at + Comma-separated error codes that won't raise error, + e.g., cz -nr 1,2,3 bump. See codes at https://commitizen- tools.github.io/commitizen/exit_codes/ commands: {init,commit,c,ls,example,info,schema,bump,changelog,ch,check,version} - init init commitizen configuration - commit (c) create new commit - ls show available commitizens - example show commit example - info show information about the cz - schema show commit schema - bump bump semantic version based on the git log - changelog (ch) generate changelog (note that it will overwrite - existing file) - check validates that a commit message matches the commitizen - schema - version get the version of the installed commitizen or the - current project (default: installed commitizen) + init Initialize commitizen configuration. + commit (c) Create new commit. + ls Show available Commitizens. + example Show commit example. + info Show information about the cz. + schema Show commit schema. + bump Bump semantic version based on the git log. + changelog (ch) Generate changelog (note that it will overwrite + existing files). + check Validate that a commit message matches the commitizen + schema. + version Get the version of the installed commitizen or the + current project (default: installed commitizen). diff --git a/tests/test_cli/test_no_argv_py_3_12_.txt b/tests/test_cli/test_no_argv_py_3_12_.txt index 691c75a86f..69f410e96d 100644 --- a/tests/test_cli/test_no_argv_py_3_12_.txt +++ b/tests/test_cli/test_no_argv_py_3_12_.txt @@ -7,28 +7,28 @@ For more information, please visit https://commitizen-tools.github.io/commitizen options: -h, --help show this help message and exit - --config CONFIG the path of configuration file - --debug use debug mode - -n NAME, --name NAME use the given commitizen (default: - cz_conventional_commits) + --config CONFIG The path to the configuration file. + --debug Use debug mode. + -n NAME, --name NAME Use the given commitizen (default: + cz_conventional_commits). -nr NO_RAISE, --no-raise NO_RAISE - comma separated error codes that won't raise error, - e.g: cz -nr 1,2,3 bump. See codes at + Comma-separated error codes that won't raise error, + e.g., cz -nr 1,2,3 bump. See codes at https://commitizen- tools.github.io/commitizen/exit_codes/ commands: {init,commit,c,ls,example,info,schema,bump,changelog,ch,check,version} - init init commitizen configuration - commit (c) create new commit - ls show available commitizens - example show commit example - info show information about the cz - schema show commit schema - bump bump semantic version based on the git log - changelog (ch) generate changelog (note that it will overwrite - existing file) - check validates that a commit message matches the commitizen - schema - version get the version of the installed commitizen or the - current project (default: installed commitizen) + init Initialize commitizen configuration. + commit (c) Create new commit. + ls Show available Commitizens. + example Show commit example. + info Show information about the cz. + schema Show commit schema. + bump Bump semantic version based on the git log. + changelog (ch) Generate changelog (note that it will overwrite + existing files). + check Validate that a commit message matches the commitizen + schema. + version Get the version of the installed commitizen or the + current project (default: installed commitizen). diff --git a/tests/test_cli/test_no_argv_py_3_13_.txt b/tests/test_cli/test_no_argv_py_3_13_.txt index f880f99772..b47528ec3e 100644 --- a/tests/test_cli/test_no_argv_py_3_13_.txt +++ b/tests/test_cli/test_no_argv_py_3_13_.txt @@ -6,28 +6,28 @@ For more information, please visit https://commitizen-tools.github.io/commitizen options: -h, --help show this help message and exit - --config CONFIG the path of configuration file - --debug use debug mode - -n, --name NAME use the given commitizen (default: - cz_conventional_commits) + --config CONFIG The path to the configuration file. + --debug Use debug mode. + -n, --name NAME Use the given commitizen (default: + cz_conventional_commits). -nr, --no-raise NO_RAISE - comma separated error codes that won't raise error, - e.g: cz -nr 1,2,3 bump. See codes at + Comma-separated error codes that won't raise error, + e.g., cz -nr 1,2,3 bump. See codes at https://commitizen- tools.github.io/commitizen/exit_codes/ commands: {init,commit,c,ls,example,info,schema,bump,changelog,ch,check,version} - init init commitizen configuration - commit (c) create new commit - ls show available commitizens - example show commit example - info show information about the cz - schema show commit schema - bump bump semantic version based on the git log - changelog (ch) generate changelog (note that it will overwrite - existing file) - check validates that a commit message matches the commitizen - schema - version get the version of the installed commitizen or the - current project (default: installed commitizen) + init Initialize commitizen configuration. + commit (c) Create new commit. + ls Show available Commitizens. + example Show commit example. + info Show information about the cz. + schema Show commit schema. + bump Bump semantic version based on the git log. + changelog (ch) Generate changelog (note that it will overwrite + existing files). + check Validate that a commit message matches the commitizen + schema. + version Get the version of the installed commitizen or the + current project (default: installed commitizen). diff --git a/tests/test_cli/test_no_argv_py_3_14_.txt b/tests/test_cli/test_no_argv_py_3_14_.txt index f880f99772..b47528ec3e 100644 --- a/tests/test_cli/test_no_argv_py_3_14_.txt +++ b/tests/test_cli/test_no_argv_py_3_14_.txt @@ -6,28 +6,28 @@ For more information, please visit https://commitizen-tools.github.io/commitizen options: -h, --help show this help message and exit - --config CONFIG the path of configuration file - --debug use debug mode - -n, --name NAME use the given commitizen (default: - cz_conventional_commits) + --config CONFIG The path to the configuration file. + --debug Use debug mode. + -n, --name NAME Use the given commitizen (default: + cz_conventional_commits). -nr, --no-raise NO_RAISE - comma separated error codes that won't raise error, - e.g: cz -nr 1,2,3 bump. See codes at + Comma-separated error codes that won't raise error, + e.g., cz -nr 1,2,3 bump. See codes at https://commitizen- tools.github.io/commitizen/exit_codes/ commands: {init,commit,c,ls,example,info,schema,bump,changelog,ch,check,version} - init init commitizen configuration - commit (c) create new commit - ls show available commitizens - example show commit example - info show information about the cz - schema show commit schema - bump bump semantic version based on the git log - changelog (ch) generate changelog (note that it will overwrite - existing file) - check validates that a commit message matches the commitizen - schema - version get the version of the installed commitizen or the - current project (default: installed commitizen) + init Initialize commitizen configuration. + commit (c) Create new commit. + ls Show available Commitizens. + example Show commit example. + info Show information about the cz. + schema Show commit schema. + bump Bump semantic version based on the git log. + changelog (ch) Generate changelog (note that it will overwrite + existing files). + check Validate that a commit message matches the commitizen + schema. + version Get the version of the installed commitizen or the + current project (default: installed commitizen). From 2cd841891c670ffba9befd8980cae395e284f75b Mon Sep 17 00:00:00 2001 From: Tim Hsiung Date: Sat, 31 Jan 2026 14:51:26 +0800 Subject: [PATCH 10/19] fix: add pytest ruff rule PT and fix missing deprecation warning (#1826) --- commitizen/changelog_formats/__init__.py | 7 ++++ pyproject.toml | 13 ++++++- tests/commands/test_init_command.py | 15 ++++---- tests/test_bump_hooks.py | 4 +-- tests/test_bump_update_version_in_files.py | 1 - tests/test_conf.py | 22 ++++++------ tests/test_deprecated.py | 14 ++++---- tests/test_factory.py | 9 +++-- tests/test_version_scheme_pep440.py | 41 ---------------------- tests/test_version_scheme_semver.py | 10 ------ tests/test_version_scheme_semver2.py | 40 --------------------- tests/test_version_schemes.py | 4 +-- 12 files changed, 54 insertions(+), 126 deletions(-) diff --git a/commitizen/changelog_formats/__init__.py b/commitizen/changelog_formats/__init__.py index c92a43087c..26e697cadd 100644 --- a/commitizen/changelog_formats/__init__.py +++ b/commitizen/changelog_formats/__init__.py @@ -1,5 +1,6 @@ from __future__ import annotations +import warnings from importlib import metadata from typing import TYPE_CHECKING, ClassVar, Protocol @@ -99,5 +100,11 @@ def _guess_changelog_format(filename: str | None) -> type[ChangelogFormat] | Non def __getattr__(name: str) -> Callable[[str], type[ChangelogFormat] | None]: if name == "guess_changelog_format": + warnings.warn( + "guess_changelog_format is deprecated and will be removed in v5. " + "Use _guess_changelog_format instead.", + DeprecationWarning, + stacklevel=2, + ) return _guess_changelog_format raise AttributeError(f"module {__name__} has no attribute {name}") diff --git a/pyproject.toml b/pyproject.toml index 855bfb6c72..18ebe46362 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -223,6 +223,8 @@ select = [ "RUF022", # unused-noqa "RUF100", + # flake8-pytest-style + "PT", # Checks for uses of the assert keyword. "S101", # flake8-type-checking (TC) @@ -233,7 +235,16 @@ select = [ "TC005", "TC006", ] -ignore = ["E501", "D1", "D415"] +ignore = [ + "E501", + "D1", + "D415", + "PT006", # TODO(bearomorphism): enable this rule + "PT007", # TODO(bearomorphism): enable this rule + "PT011", # TODO(bearomorphism): enable this rule + "PT022", # TODO(bearomorphism): enable this rule + "PT030", # TODO(bearomorphism): enable this rule +] extend-safe-fixes = [ "TC", # Move imports inside/outside TYPE_CHECKING blocks "UP", # Update syntaxes for current Python version recommendations diff --git a/tests/commands/test_init_command.py b/tests/commands/test_init_command.py index 8398e784bc..4c7f3923a7 100644 --- a/tests/commands/test_init_command.py +++ b/tests/commands/test_init_command.py @@ -133,7 +133,7 @@ def pre_commit_installed(mocker: MockFixture): ) -@pytest.fixture(scope="function", params=["pyproject.toml", ".cz.json", ".cz.yaml"]) +@pytest.fixture(params=["pyproject.toml", ".cz.json", ".cz.yaml"]) def default_choice(request, mocker: MockFixture): mocker.patch( "questionary.select", @@ -150,7 +150,7 @@ def default_choice(request, mocker: MockFixture): "questionary.checkbox", return_value=FakeQuestion(["commit-msg", "pre-push"]), ) - yield request.param + return request.param def check_cz_config(config_filepath: str): @@ -179,7 +179,7 @@ def check_pre_commit_config(expected: list[dict[str, Any]]): @pytest.mark.usefixtures("pre_commit_installed") class TestPreCommitCases: def test_no_existing_pre_commit_config( - _, default_choice: str, tmpdir, config: BaseConfig + self, default_choice: str, tmpdir, config: BaseConfig ): with tmpdir.as_cwd(): commands.Init(config)() @@ -187,7 +187,7 @@ def test_no_existing_pre_commit_config( check_pre_commit_config([cz_hook_config]) def test_empty_pre_commit_config( - _, default_choice: str, tmpdir, config: BaseConfig + self, default_choice: str, tmpdir, config: BaseConfig ): with tmpdir.as_cwd(): p = tmpdir.join(pre_commit_config_filename) @@ -198,7 +198,7 @@ def test_empty_pre_commit_config( check_pre_commit_config([cz_hook_config]) def test_pre_commit_config_without_cz_hook( - _, default_choice: str, tmpdir, config: BaseConfig + self, default_choice: str, tmpdir, config: BaseConfig ): existing_hook_config = { "repo": "https://github.com/pre-commit/pre-commit-hooks", @@ -215,7 +215,7 @@ def test_pre_commit_config_without_cz_hook( check_pre_commit_config([existing_hook_config, cz_hook_config]) def test_cz_hook_exists_in_pre_commit_config( - _, default_choice: str, tmpdir, config: BaseConfig + self, default_choice: str, tmpdir, config: BaseConfig ): with tmpdir.as_cwd(): p = tmpdir.join(pre_commit_config_filename) @@ -228,8 +228,9 @@ def test_cz_hook_exists_in_pre_commit_config( class TestNoPreCommitInstalled: + @pytest.mark.usefixtures("default_choice") def test_pre_commit_not_installed( - _, mocker: MockFixture, config: BaseConfig, default_choice: str, tmpdir + self, mocker: MockFixture, config: BaseConfig, tmpdir ): # Assume `pre-commit` is not installed mocker.patch( diff --git a/tests/test_bump_hooks.py b/tests/test_bump_hooks.py index 70ed7fe0b1..739d1ce6ad 100644 --- a/tests/test_bump_hooks.py +++ b/tests/test_bump_hooks.py @@ -38,5 +38,5 @@ def test_run_error(mocker: MockFixture): def test_format_env(): result = hooks._format_env("TEST_", {"foo": "bar", "bar": "baz"}) - assert "TEST_FOO" in result and result["TEST_FOO"] == "bar" - assert "TEST_BAR" in result and result["TEST_BAR"] == "baz" + assert result["TEST_FOO"] == "bar" + assert result["TEST_BAR"] == "baz" diff --git a/tests/test_bump_update_version_in_files.py b/tests/test_bump_update_version_in_files.py index 2cc464e8f1..8fd4c465b8 100644 --- a/tests/test_bump_update_version_in_files.py +++ b/tests/test_bump_update_version_in_files.py @@ -57,7 +57,6 @@ def docker_compose_file(sample_file: SampleFileFixture) -> Path: @pytest.fixture( - scope="function", params=( "multiple_versions_to_update_pyproject.toml", "multiple_versions_to_update_pyproject_wo_eol.toml", diff --git a/tests/test_conf.py b/tests/test_conf.py index ee5eba5b3c..99d19793cd 100644 --- a/tests/test_conf.py +++ b/tests/test_conf.py @@ -184,16 +184,16 @@ class TestReadCfg: @pytest.mark.parametrize( "config_files_manager", defaults.CONFIG_FILES, indirect=True ) - def test_load_conf(_, config_files_manager): + def test_load_conf(self, config_files_manager): cfg = config.read_cfg() assert cfg.settings == _settings - def test_conf_returns_default_when_no_files(_, tmpdir): + def test_conf_returns_default_when_no_files(self, tmpdir): with tmpdir.as_cwd(): cfg = config.read_cfg() assert cfg.settings == defaults.DEFAULT_SETTINGS - def test_load_empty_pyproject_toml_and_cz_toml_with_config(_, tmpdir): + def test_load_empty_pyproject_toml_and_cz_toml_with_config(self, tmpdir): with tmpdir.as_cwd(): p = tmpdir.join("pyproject.toml") p.write("") @@ -203,7 +203,7 @@ def test_load_empty_pyproject_toml_and_cz_toml_with_config(_, tmpdir): cfg = config.read_cfg() assert cfg.settings == _settings - def test_load_pyproject_toml_from_config_argument(_, tmpdir): + def test_load_pyproject_toml_from_config_argument(self, tmpdir): with tmpdir.as_cwd(): _not_root_path = tmpdir.mkdir("not_in_root").join("pyproject.toml") _not_root_path.write(PYPROJECT) @@ -211,7 +211,7 @@ def test_load_pyproject_toml_from_config_argument(_, tmpdir): cfg = config.read_cfg(filepath="./not_in_root/pyproject.toml") assert cfg.settings == _settings - def test_load_cz_json_not_from_config_argument(_, tmpdir): + def test_load_cz_json_not_from_config_argument(self, tmpdir): with tmpdir.as_cwd(): _not_root_path = tmpdir.mkdir("not_in_root").join(".cz.json") _not_root_path.write(JSON_STR) @@ -220,7 +220,7 @@ def test_load_cz_json_not_from_config_argument(_, tmpdir): json_cfg_by_class = JsonConfig(data=JSON_STR, path=_not_root_path) assert cfg.settings == json_cfg_by_class.settings - def test_load_cz_yaml_not_from_config_argument(_, tmpdir): + def test_load_cz_yaml_not_from_config_argument(self, tmpdir): with tmpdir.as_cwd(): _not_root_path = tmpdir.mkdir("not_in_root").join(".cz.yaml") _not_root_path.write(YAML_STR) @@ -229,7 +229,7 @@ def test_load_cz_yaml_not_from_config_argument(_, tmpdir): yaml_cfg_by_class = YAMLConfig(data=YAML_STR, path=_not_root_path) assert cfg.settings == yaml_cfg_by_class._settings - def test_load_empty_pyproject_toml_from_config_argument(_, tmpdir): + def test_load_empty_pyproject_toml_from_config_argument(self, tmpdir): with tmpdir.as_cwd(): _not_root_path = tmpdir.mkdir("not_in_root").join("pyproject.toml") _not_root_path.write("") @@ -260,7 +260,7 @@ class TestWarnMultipleConfigFiles: ], ) def test_warn_multiple_config_files_same_dir( - _, tmpdir, capsys, files, expected_path, should_warn + self, tmpdir, capsys, files, expected_path, should_warn ): """Test warning when multiple config files exist in same directory.""" with tmpdir.as_cwd(): @@ -296,7 +296,7 @@ def test_warn_multiple_config_files_same_dir( ], ) def test_warn_same_filename_different_directories_with_git( - _, tmpdir, capsys, config_file, content + self, tmpdir, capsys, config_file, content ): """Test warning when same config filename exists in the current directory and in the git root.""" with tmpdir.as_cwd(): @@ -317,7 +317,7 @@ def test_warn_same_filename_different_directories_with_git( assert f"Using config file: '{config_file}'" in captured.err assert cfg.path == Path(config_file) - def test_no_warn_with_explicit_config_path(_, tmpdir, capsys): + def test_no_warn_with_explicit_config_path(self, tmpdir, capsys): """Test that no warning is issued when user explicitly specifies config.""" with tmpdir.as_cwd(): # Create multiple config files @@ -352,7 +352,7 @@ def test_no_warn_with_explicit_config_path(_, tmpdir, capsys): ], ) def test_no_warn_with_single_config_file( - _, tmpdir, capsys, config_file, content, with_git + self, tmpdir, capsys, config_file, content, with_git ): """Test that no warning is issued when user explicitly specifies config.""" with tmpdir.as_cwd(): diff --git a/tests/test_deprecated.py b/tests/test_deprecated.py index 41bea81a73..6e695c300c 100644 --- a/tests/test_deprecated.py +++ b/tests/test_deprecated.py @@ -5,26 +5,28 @@ def test_getattr_deprecated_vars(): # Test each deprecated variable - with pytest.warns(DeprecationWarning) as record: + with pytest.warns(DeprecationWarning, match="is deprecated and will be removed"): assert defaults.bump_pattern == defaults.BUMP_PATTERN + with pytest.warns(DeprecationWarning, match="is deprecated and will be removed"): assert defaults.bump_map == defaults.BUMP_MAP + with pytest.warns(DeprecationWarning, match="is deprecated and will be removed"): assert ( defaults.bump_map_major_version_zero == defaults.BUMP_MAP_MAJOR_VERSION_ZERO ) + with pytest.warns(DeprecationWarning, match="is deprecated and will be removed"): assert defaults.bump_message == defaults.BUMP_MESSAGE + with pytest.warns(DeprecationWarning, match="is deprecated and will be removed"): assert defaults.change_type_order == defaults.CHANGE_TYPE_ORDER + with pytest.warns(DeprecationWarning, match="is deprecated and will be removed"): assert defaults.encoding == defaults.ENCODING + with pytest.warns(DeprecationWarning, match="is deprecated and will be removed"): assert defaults.name == defaults.DEFAULT_SETTINGS["name"] + with pytest.warns(DeprecationWarning, match="is deprecated and will be removed"): assert ( changelog_formats._guess_changelog_format == changelog_formats.guess_changelog_format ) - # Verify warning messages - assert len(record) == 7 - for warning in record: - assert "is deprecated and will be removed" in str(warning.message) - def test_getattr_non_existent(): # Test non-existent attribute diff --git a/tests/test_factory.py b/tests/test_factory.py index 20ce49d781..303ae4e728 100644 --- a/tests/test_factory.py +++ b/tests/test_factory.py @@ -52,14 +52,13 @@ class Plugin: pass ) sys.path.append(tmp_path.as_posix()) - with pytest.warns(UserWarning) as record: + with pytest.warns( + UserWarning, + match="Legacy plugin 'cz_legacy' has been ignored: please expose it the 'commitizen.plugin' entrypoint", + ): discovered_plugins = discover_plugins([tmp_path.as_posix()]) sys.path.pop() - assert ( - record[0].message.args[0] - == "Legacy plugin 'cz_legacy' has been ignored: please expose it the 'commitizen.plugin' entrypoint" - ) assert "cz_legacy" not in discovered_plugins diff --git a/tests/test_version_scheme_pep440.py b/tests/test_version_scheme_pep440.py index 0ce4f81545..3c15eeb4a9 100644 --- a/tests/test_version_scheme_pep440.py +++ b/tests/test_version_scheme_pep440.py @@ -249,16 +249,6 @@ ), "0.1.1.dev1", ), - ( - VersionSchemeTestArgs( - current_version="0.1.1", - increment="MINOR", - prerelease=None, - prerelease_offset=0, - devrelease=None, - ), - "0.2.0", - ), ( VersionSchemeTestArgs( current_version="0.2.0", @@ -733,26 +723,6 @@ ), "1.1.0a0", ), - ( - VersionSchemeTestArgs( - current_version="1.1.0a0", - increment="PATCH", - prerelease="alpha", - prerelease_offset=0, - devrelease=None, - ), - "1.1.0a1", - ), - ( - VersionSchemeTestArgs( - current_version="1.1.0a1", - increment="MINOR", - prerelease="alpha", - prerelease_offset=0, - devrelease=None, - ), - "1.1.0a2", - ), ( VersionSchemeTestArgs( current_version="1.1.0a2", @@ -1020,17 +990,6 @@ ), "3.1.4rc0", ), - # - ( - VersionSchemeTestArgs( - current_version="3.1.4", - increment=None, - prerelease="alpha", - prerelease_offset=0, - devrelease=None, - ), - "3.1.4a0", - ), ( VersionSchemeTestArgs( current_version="3.1.4a0", diff --git a/tests/test_version_scheme_semver.py b/tests/test_version_scheme_semver.py index 8a163d4f6b..1a75cd3eae 100644 --- a/tests/test_version_scheme_semver.py +++ b/tests/test_version_scheme_semver.py @@ -271,16 +271,6 @@ ), "0.1.1-dev1", ), - ( - VersionSchemeTestArgs( - current_version="0.1.1", - increment="MINOR", - prerelease=None, - prerelease_offset=0, - devrelease=None, - ), - "0.2.0", - ), ( VersionSchemeTestArgs( current_version="0.2.0", diff --git a/tests/test_version_scheme_semver2.py b/tests/test_version_scheme_semver2.py index 4a35e6470a..6ce00e06ed 100644 --- a/tests/test_version_scheme_semver2.py +++ b/tests/test_version_scheme_semver2.py @@ -220,16 +220,6 @@ ), "1.0.0-beta.1", ), - ( - VersionSchemeTestArgs( - current_version="1.0.0-alpha.1", - increment=None, - prerelease="alpha", - prerelease_offset=0, - devrelease=None, - ), - "1.0.0-alpha.2", - ), ( VersionSchemeTestArgs( current_version="1", @@ -271,16 +261,6 @@ ), "0.1.1-dev.1", ), - ( - VersionSchemeTestArgs( - current_version="0.1.1", - increment="MINOR", - prerelease=None, - prerelease_offset=0, - devrelease=None, - ), - "0.2.0", - ), ( VersionSchemeTestArgs( current_version="0.2.0", @@ -391,16 +371,6 @@ ), "1.0.0-alpha.1", ), - ( - VersionSchemeTestArgs( - current_version="1.0.0-alpha.1", - increment=None, - prerelease="alpha", - prerelease_offset=0, - devrelease=None, - ), - "1.0.0-alpha.2", - ), ( VersionSchemeTestArgs( current_version="1.0.0-alpha.1", @@ -451,16 +421,6 @@ ), "1.0.0-beta.1", ), - ( - VersionSchemeTestArgs( - current_version="1.0.0-beta.1", - increment=None, - prerelease="rc", - prerelease_offset=0, - devrelease=None, - ), - "1.0.0-rc.0", - ), ( VersionSchemeTestArgs( current_version="1.0.0-rc.0", diff --git a/tests/test_version_schemes.py b/tests/test_version_schemes.py index 7b1ec7579a..0f38f90d80 100644 --- a/tests/test_version_schemes.py +++ b/tests/test_version_schemes.py @@ -38,7 +38,7 @@ def test_raise_for_unknown_version_scheme(config: BaseConfig): def test_version_scheme_from_deprecated_config(config: BaseConfig): config.settings["version_type"] = "semver" - with pytest.warns(DeprecationWarning): + with pytest.warns(DeprecationWarning, match="Please use `version_scheme` instead"): scheme = get_version_scheme(config.settings) assert scheme is SemVer @@ -46,7 +46,7 @@ def test_version_scheme_from_deprecated_config(config: BaseConfig): def test_version_scheme_from_config_priority(config: BaseConfig): config.settings["version_scheme"] = "pep440" config.settings["version_type"] = "semver" - with pytest.warns(DeprecationWarning): + with pytest.warns(DeprecationWarning, match="Please use `version_scheme` instead"): scheme = get_version_scheme(config.settings) assert scheme is Pep440 From 908a10ec910a8c9dab36f4b9bb4e936f356769b5 Mon Sep 17 00:00:00 2001 From: Yazdan Ranjbar Date: Sat, 31 Jan 2026 01:52:32 -0500 Subject: [PATCH 11/19] feat(tags): enable version schemes with less than 3 components (#1705) Co-authored-by: Wei Lee Co-authored-by: Benedikt Ziegler --- commitizen/tags.py | 21 +++++- docs/commands/bump.md | 13 ++++ tests/commands/test_bump_command.py | 29 ++++++++ tests/test_tags.py | 101 ++++++++++++++++++++++++++++ 4 files changed, 163 insertions(+), 1 deletion(-) create mode 100644 tests/test_tags.py diff --git a/commitizen/tags.py b/commitizen/tags.py index 68c74a72e6..dcddbd335f 100644 --- a/commitizen/tags.py +++ b/commitizen/tags.py @@ -228,7 +228,7 @@ def normalize_tag( version = self.scheme(version) if isinstance(version, str) else version tag_format = tag_format or self.tag_format - major, minor, patch = version.release + major, minor, patch = (list(version.release) + [0, 0, 0])[:3] prerelease = version.prerelease or "" t = Template(tag_format) @@ -245,6 +245,25 @@ def find_tag_for( ) -> GitTag | None: """Find the first matching tag for a given version.""" version = self.scheme(version) if isinstance(version, str) else version + release = version.release + + # If the requested version is incomplete (e.g., "1.2"), try to find the latest + # matching tag that shares the provided prefix. + if len(release) < 3: + matching_versions: list[tuple[Version, GitTag]] = [] + for tag in tags: + try: + tag_version = self.extract_version(tag) + except InvalidVersion: + continue + if tag_version.release[: len(release)] != release: + continue + matching_versions.append((tag_version, tag)) + + if matching_versions: + _, latest_tag = max(matching_versions, key=lambda vt: vt[0]) + return latest_tag + possible_tags = set(self.normalize_tag(version, f) for f in self.tag_formats) candidates = [t for t in tags if t.name in possible_tags] if len(candidates) > 1: diff --git a/docs/commands/bump.md b/docs/commands/bump.md index e7a7c04030..03fc83402c 100644 --- a/docs/commands/bump.md +++ b/docs/commands/bump.md @@ -65,6 +65,19 @@ You can also set this in the configuration file with `version_scheme = "semver"` | Devrelease | `0.1.1.dev1` | `0.1.1-dev1` | | Dev and pre | `1.0.0a3.dev1` | `1.0.0-a3-dev1` | + +!!! note "Incomplete Version Handling" + Commitizen treats a three-part version (major.minor.patch) as complete. + If your configured version is incomplete (for example, `1` or `1.2`), Commitizen pads missing parts with zeros when it needs `major/minor/patch` for tag formatting. + The tag output depends on your `tag_format`: formats using `${version}` keep `1`/`1.2`, while formats using `${major}.${minor}.${patch}` will render `1.0.0`/`1.2.0`. + + When bumping from an incomplete version, Commitizen looks for the latest existing tag that matches the provided release prefix. + For example, if the current version is `1.2` and the latest `1.2.x` tag is `1.2.3`, then a patch bump yields `1.2.4` and a minor bump yields `1.3.0`. + +!!! tip + To control the behaviour of bumping and version parsing, you may implement your own `version_scheme` by inheriting from `commitizen.version_schemes.BaseVersion` or use an existing plugin package. + + ### PEP440 Version Examples Commitizen supports the [PEP 440][pep440] version format, which includes several version types. Here are examples of each: diff --git a/tests/commands/test_bump_command.py b/tests/commands/test_bump_command.py index a1c70b9480..b9a6bf90f0 100644 --- a/tests/commands/test_bump_command.py +++ b/tests/commands/test_bump_command.py @@ -755,6 +755,8 @@ def test_bump_invalid_manual_version_raises_exception( "0.1.1", "0.2.0", "1.0.0", + "1.2", + "1", ], ) def test_bump_manual_version(util: UtilFixture, manual_version): @@ -775,6 +777,33 @@ def test_bump_manual_version_disallows_major_version_zero(util: UtilFixture): ) +@pytest.mark.parametrize( + "initial_version, expected_version_after_bump", + [ + ("1", "1.1.0"), + ("1.2", "1.3.0"), + ], +) +def test_bump_version_with_less_components_in_config( + tmp_commitizen_project_initial, + initial_version, + expected_version_after_bump, + util: UtilFixture, +): + tmp_commitizen_project = tmp_commitizen_project_initial(version=initial_version) + util.run_cli("bump", "--yes") + + tag_exists = git.tag_exist(expected_version_after_bump) + assert tag_exists is True + + for version_file in [ + tmp_commitizen_project.join("__version__.py"), + tmp_commitizen_project.join("pyproject.toml"), + ]: + with open(version_file) as f: + assert expected_version_after_bump in f.read() + + @pytest.mark.parametrize("commit_msg", ("feat: new file", "feat(user): new file")) def test_bump_with_pre_bump_hooks( commit_msg, mocker: MockFixture, tmp_commitizen_project, util: UtilFixture diff --git a/tests/test_tags.py b/tests/test_tags.py new file mode 100644 index 0000000000..2471b8461b --- /dev/null +++ b/tests/test_tags.py @@ -0,0 +1,101 @@ +from commitizen.git import GitTag +from commitizen.tags import TagRules + + +def _git_tag(name: str) -> GitTag: + return GitTag(name, "rev", "2024-01-01") + + +def test_find_tag_for_partial_version_returns_latest_match(): + tags = [ + _git_tag("1.2.0"), + _git_tag("1.2.2"), + _git_tag("1.2.1"), + _git_tag("1.3.0"), + ] + + rules = TagRules() + + found = rules.find_tag_for(tags, "1.2") + + assert found is not None + assert found.name == "1.2.2" + + +def test_find_tag_for_full_version_remains_exact(): + tags = [ + _git_tag("1.2.0"), + _git_tag("1.2.2"), + _git_tag("1.2.1"), + ] + + rules = TagRules() + + found = rules.find_tag_for(tags, "1.2.1") + + assert found is not None + assert found.name == "1.2.1" + + +def test_find_tag_for_partial_version_with_prereleases_prefers_latest_version(): + tags = [ + _git_tag("1.2.0b1"), + _git_tag("1.2.0"), + _git_tag("1.2.1b1"), + ] + + rules = TagRules() + + found = rules.find_tag_for(tags, "1.2") + + assert found is not None + # 1.2.1b1 > 1.2.0 so it should be selected + assert found.name == "1.2.1b1" + + +def test_find_tag_for_partial_version_respects_tag_format(): + tags = [ + _git_tag("v1.2.0"), + _git_tag("v1.2.1"), + _git_tag("v1.3.0"), + ] + + rules = TagRules(tag_format="v$version") + + found = rules.find_tag_for(tags, "1.2") + + assert found is not None + assert found.name == "v1.2.1" + + found = rules.find_tag_for(tags, "1") + + assert found is not None + assert found.name == "v1.3.0" + + +def test_find_tag_for_partial_version_returns_none_when_no_match(): + tags = [ + _git_tag("2.0.0"), + _git_tag("2.1.0"), + ] + + rules = TagRules() + + found = rules.find_tag_for(tags, "1.2") + + assert found is None + + +def test_find_tag_for_partial_version_ignores_invalid_tags(): + tags = [ + _git_tag("not-a-version"), + _git_tag("1.2.0"), + _git_tag("1.2.1"), + ] + + rules = TagRules() + + found = rules.find_tag_for(tags, "1.2") + + assert found is not None + assert found.name == "1.2.1" From 53c994985096d1fc6492535afb2ecfbf2c90c9ef Mon Sep 17 00:00:00 2001 From: "andre.liang" <54308739+namwoam@users.noreply.github.com> Date: Sat, 31 Jan 2026 15:14:48 +0800 Subject: [PATCH 12/19] feat(cli): add description when choosing a commit rule (#1825) --- commitizen/commands/init.py | 24 ++++++++++++++++++++++-- tests/commands/test_init_command.py | 20 ++++++++++++++++++++ 2 files changed, 42 insertions(+), 2 deletions(-) diff --git a/commitizen/commands/init.py b/commitizen/commands/init.py index 62678a2244..0773b71e42 100644 --- a/commitizen/commands/init.py +++ b/commitizen/commands/init.py @@ -11,7 +11,11 @@ from commitizen.config.factory import create_config from commitizen.cz import registry from commitizen.defaults import CONFIG_FILES, DEFAULT_SETTINGS -from commitizen.exceptions import InitFailedError, NoAnswersError +from commitizen.exceptions import ( + InitFailedError, + MissingCzCustomizeConfigError, + NoAnswersError, +) from commitizen.git import get_latest_tag_name, get_tag_names, smart_open from commitizen.version_schemes import KNOWN_SCHEMES, Version, get_version_scheme @@ -167,12 +171,28 @@ def _ask_config_path(self) -> Path: def _ask_name(self) -> str: name: str = questionary.select( "Please choose a cz (commit rule): (default: cz_conventional_commits)", - choices=list(registry.keys()), + choices=self._construct_name_choice_with_description(), default="cz_conventional_commits", style=self.cz.style, ).unsafe_ask() return name + def _construct_name_choice_with_description(self) -> list[questionary.Choice]: + choices = [] + for cz_name, cz_class in registry.items(): + try: + cz_obj = cz_class(self.config) + except MissingCzCustomizeConfigError: + choices.append(questionary.Choice(title=cz_name, value=cz_name)) + continue + first_example = cz_obj.schema().partition("\n")[0] + choices.append( + questionary.Choice( + title=cz_name, value=cz_name, description=first_example + ) + ) + return choices + def _ask_tag(self) -> str: latest_tag = get_latest_tag_name() if not latest_tag: diff --git a/tests/commands/test_init_command.py b/tests/commands/test_init_command.py index 4c7f3923a7..0cf6377ead 100644 --- a/tests/commands/test_init_command.py +++ b/tests/commands/test_init_command.py @@ -10,6 +10,7 @@ from commitizen import cmd, commands from commitizen.__version__ import __version__ +from commitizen.cz import registry from commitizen.exceptions import InitFailedError, NoAnswersError if TYPE_CHECKING: @@ -463,3 +464,22 @@ def test_init_configuration_with_version_provider( assert ( "version = " not in config_data ) # Version should not be set when using version_provider + + +def test_construct_name_choice_with_description( + config: BaseConfig, mocker: MockFixture +): + """Test the construction of cz name choices with descriptions.""" + init = commands.Init(config) + # mock the registry to have only one cz for testing + mocker.patch.dict( + "commitizen.cz.registry", + {"cz_conventional_commits": registry["cz_conventional_commits"]}, + clear=True, + ) + choices = init._construct_name_choice_with_description() + assert len(choices) == 1 + choice = choices[0] + assert choice.title == "cz_conventional_commits" + assert choice.value == "cz_conventional_commits" + assert choice.description == "(): " From 68c7ba615f6d86a0e58c4d91a41259dce00a393f Mon Sep 17 00:00:00 2001 From: Finn Date: Sat, 31 Jan 2026 01:40:34 -0600 Subject: [PATCH 13/19] feat(version): add --tag tag to version command (#1819) --- commitizen/cli.py | 6 +++ commitizen/commands/version.py | 9 +++++ ..._when_use_help_option_py_3_10_version_.txt | 4 +- ..._when_use_help_option_py_3_11_version_.txt | 4 +- ..._when_use_help_option_py_3_12_version_.txt | 4 +- ..._when_use_help_option_py_3_13_version_.txt | 4 +- ..._when_use_help_option_py_3_14_version_.txt | 4 +- tests/commands/test_version_command.py | 39 +++++++++++++++++++ 8 files changed, 69 insertions(+), 5 deletions(-) diff --git a/commitizen/cli.py b/commitizen/cli.py index 99c36f8e4c..d057bd97dc 100644 --- a/commitizen/cli.py +++ b/commitizen/cli.py @@ -546,6 +546,12 @@ def __call__( "action": "store_true", "exclusive_group": "group2", }, + { + "name": ["--tag"], + "help": "get the version with tag prefix. Need to be used with --project or --verbose.", + "action": "store_true", + "exclusive_group": "group2", + }, ], }, ], diff --git a/commitizen/commands/version.py b/commitizen/commands/version.py index 9290e80b8f..c8a76fe27f 100644 --- a/commitizen/commands/version.py +++ b/commitizen/commands/version.py @@ -7,6 +7,7 @@ from commitizen.config import BaseConfig from commitizen.exceptions import NoVersionSpecifiedError, VersionSchemeUnknown from commitizen.providers import get_provider +from commitizen.tags import TagRules from commitizen.version_schemes import get_version_scheme @@ -17,6 +18,7 @@ class VersionArgs(TypedDict, total=False): verbose: bool major: bool minor: bool + tag: bool class Version: @@ -59,6 +61,9 @@ def __call__(self) -> None: version = f"{version_scheme.major}" elif self.arguments.get("minor"): version = f"{version_scheme.minor}" + elif self.arguments.get("tag"): + tag_rules = TagRules.from_settings(self.config.settings) + version = tag_rules.normalize_tag(version_scheme) out.write( f"Project Version: {version}" @@ -73,5 +78,9 @@ def __call__(self) -> None: ) return + if self.arguments.get("tag"): + out.error("Tag can only be used with --project or --verbose.") + return + # If no arguments are provided, just show the installed commitizen version out.write(__version__) diff --git a/tests/commands/test_common_command/test_command_shows_description_when_use_help_option_py_3_10_version_.txt b/tests/commands/test_common_command/test_command_shows_description_when_use_help_option_py_3_10_version_.txt index 0061a97514..5085d0fd3c 100644 --- a/tests/commands/test_common_command/test_command_shows_description_when_use_help_option_py_3_10_version_.txt +++ b/tests/commands/test_common_command/test_command_shows_description_when_use_help_option_py_3_10_version_.txt @@ -1,4 +1,4 @@ -usage: cz version [-h] [-r | -p | -c | -v] [--major | --minor] +usage: cz version [-h] [-r | -p | -c | -v] [--major | --minor | --tag] Get the version of the installed commitizen or the current project (default: installed commitizen) @@ -14,3 +14,5 @@ options: or --verbose. --minor Output just the minor version. Must be used with --project or --verbose. + --tag get the version with tag prefix. Need to be used with + --project or --verbose. diff --git a/tests/commands/test_common_command/test_command_shows_description_when_use_help_option_py_3_11_version_.txt b/tests/commands/test_common_command/test_command_shows_description_when_use_help_option_py_3_11_version_.txt index 0061a97514..5085d0fd3c 100644 --- a/tests/commands/test_common_command/test_command_shows_description_when_use_help_option_py_3_11_version_.txt +++ b/tests/commands/test_common_command/test_command_shows_description_when_use_help_option_py_3_11_version_.txt @@ -1,4 +1,4 @@ -usage: cz version [-h] [-r | -p | -c | -v] [--major | --minor] +usage: cz version [-h] [-r | -p | -c | -v] [--major | --minor | --tag] Get the version of the installed commitizen or the current project (default: installed commitizen) @@ -14,3 +14,5 @@ options: or --verbose. --minor Output just the minor version. Must be used with --project or --verbose. + --tag get the version with tag prefix. Need to be used with + --project or --verbose. diff --git a/tests/commands/test_common_command/test_command_shows_description_when_use_help_option_py_3_12_version_.txt b/tests/commands/test_common_command/test_command_shows_description_when_use_help_option_py_3_12_version_.txt index 0061a97514..5085d0fd3c 100644 --- a/tests/commands/test_common_command/test_command_shows_description_when_use_help_option_py_3_12_version_.txt +++ b/tests/commands/test_common_command/test_command_shows_description_when_use_help_option_py_3_12_version_.txt @@ -1,4 +1,4 @@ -usage: cz version [-h] [-r | -p | -c | -v] [--major | --minor] +usage: cz version [-h] [-r | -p | -c | -v] [--major | --minor | --tag] Get the version of the installed commitizen or the current project (default: installed commitizen) @@ -14,3 +14,5 @@ options: or --verbose. --minor Output just the minor version. Must be used with --project or --verbose. + --tag get the version with tag prefix. Need to be used with + --project or --verbose. diff --git a/tests/commands/test_common_command/test_command_shows_description_when_use_help_option_py_3_13_version_.txt b/tests/commands/test_common_command/test_command_shows_description_when_use_help_option_py_3_13_version_.txt index 0061a97514..5085d0fd3c 100644 --- a/tests/commands/test_common_command/test_command_shows_description_when_use_help_option_py_3_13_version_.txt +++ b/tests/commands/test_common_command/test_command_shows_description_when_use_help_option_py_3_13_version_.txt @@ -1,4 +1,4 @@ -usage: cz version [-h] [-r | -p | -c | -v] [--major | --minor] +usage: cz version [-h] [-r | -p | -c | -v] [--major | --minor | --tag] Get the version of the installed commitizen or the current project (default: installed commitizen) @@ -14,3 +14,5 @@ options: or --verbose. --minor Output just the minor version. Must be used with --project or --verbose. + --tag get the version with tag prefix. Need to be used with + --project or --verbose. diff --git a/tests/commands/test_common_command/test_command_shows_description_when_use_help_option_py_3_14_version_.txt b/tests/commands/test_common_command/test_command_shows_description_when_use_help_option_py_3_14_version_.txt index 0061a97514..5085d0fd3c 100644 --- a/tests/commands/test_common_command/test_command_shows_description_when_use_help_option_py_3_14_version_.txt +++ b/tests/commands/test_common_command/test_command_shows_description_when_use_help_option_py_3_14_version_.txt @@ -1,4 +1,4 @@ -usage: cz version [-h] [-r | -p | -c | -v] [--major | --minor] +usage: cz version [-h] [-r | -p | -c | -v] [--major | --minor | --tag] Get the version of the installed commitizen or the current project (default: installed commitizen) @@ -14,3 +14,5 @@ options: or --verbose. --minor Output just the minor version. Must be used with --project or --verbose. + --tag get the version with tag prefix. Need to be used with + --project or --verbose. diff --git a/tests/commands/test_version_command.py b/tests/commands/test_version_command.py index 17f7238403..af22ba7ad2 100644 --- a/tests/commands/test_version_command.py +++ b/tests/commands/test_version_command.py @@ -161,3 +161,42 @@ def test_version_just_major_error_no_project(config, capsys, argument: str): "Major or minor version can only be used with --project or --verbose." in captured.err ) + + +@pytest.mark.parametrize( + "version, tag_format, expected_output", + [ + ("1.2.3", "v$version", "v1.2.3\n"), + ("1.2.3", "$version", "1.2.3\n"), + ("2.0.0", "release-$version", "release-2.0.0\n"), + ("0.1.0", "ver$version", "ver0.1.0\n"), + ], +) +def test_version_with_tag_format( + config, capsys, version: str, tag_format: str, expected_output: str +): + """Test --tag option applies tag_format to version""" + config.settings["version"] = version + config.settings["tag_format"] = tag_format + commands.Version( + config, + { + "project": True, + "tag": True, + }, + )() + captured = capsys.readouterr() + assert captured.out == expected_output + + +def test_version_tag_without_project_error(config, capsys): + """Test --tag requires --project or --verbose""" + commands.Version( + config, + { + "tag": True, + }, + )() + captured = capsys.readouterr() + assert not captured.out + assert "Tag can only be used with --project or --verbose." in captured.err From f7fba4805a077c598ac859bd28db35a4669b5a83 Mon Sep 17 00:00:00 2001 From: Tim Hsiung Date: Sat, 31 Jan 2026 16:08:21 +0800 Subject: [PATCH 14/19] fix(config): include pyproject.toml in multi config file warning (#1803) --- commitizen/config/__init__.py | 38 ++++++++++------------ tests/test_conf.py | 60 ++++++++++++++++++++--------------- 2 files changed, 51 insertions(+), 47 deletions(-) diff --git a/commitizen/config/__init__.py b/commitizen/config/__init__.py index cce3a266cd..ae980af9c0 100644 --- a/commitizen/config/__init__.py +++ b/commitizen/config/__init__.py @@ -9,7 +9,7 @@ from .base_config import BaseConfig -def _resolve_config_paths() -> list[Path]: +def _resolve_config_candidates() -> list[BaseConfig]: git_project_root = git.find_git_project_root() cfg_search_paths = [Path(".")] @@ -18,12 +18,18 @@ def _resolve_config_paths() -> list[Path]: # The following algorithm is ugly, but we need to ensure that the order of the candidates are preserved before v5. # Also, the number of possible config files is limited, so the complexity is not a problem. - candidates: list[Path] = [] + candidates: list[BaseConfig] = [] for dir in cfg_search_paths: for filename in defaults.CONFIG_FILES: out_path = dir / Path(filename) - if out_path.exists() and all(not out_path.samefile(p) for p in candidates): - candidates.append(out_path) + if ( + out_path.exists() + and not any( + out_path.samefile(candidate.path) for candidate in candidates + ) + and not (conf := _create_config_from_path(out_path)).is_empty_config + ): + candidates.append(conf) return candidates @@ -44,21 +50,11 @@ def read_cfg(filepath: str | None = None) -> BaseConfig: raise ConfigFileIsEmpty() return conf - config_candidate_paths = _resolve_config_paths() - - # Check for multiple config files and warn the user - config_candidates_exclude_pyproject = [ - path for path in config_candidate_paths if path.name != "pyproject.toml" - ] - - for config_candidate_path in config_candidate_paths: - conf = _create_config_from_path(config_candidate_path) - if not conf.is_empty_config: - if len(config_candidates_exclude_pyproject) > 1: - out.warn( - f"Multiple config files detected: {', '.join(map(str, config_candidates_exclude_pyproject))}. " - f"Using config file: '{config_candidate_path}'." - ) - return conf + config_candidates = _resolve_config_candidates() + if len(config_candidates) > 1: + out.warn( + f"Multiple config files detected: {', '.join(str(conf.path) for conf in config_candidates)}. " + f"Using config file: '{config_candidates[0].path}'." + ) - return BaseConfig() + return config_candidates[0] if config_candidates else BaseConfig() diff --git a/tests/test_conf.py b/tests/test_conf.py index 99d19793cd..f1ff76ff88 100644 --- a/tests/test_conf.py +++ b/tests/test_conf.py @@ -14,7 +14,7 @@ from commitizen.config.yaml_config import YAMLConfig from commitizen.exceptions import ConfigFileIsEmpty, InvalidConfigurationError -PYPROJECT = """ +TOML_STR = """ [tool.commitizen] name = "cz_jira" version = "1.0.0" @@ -30,12 +30,17 @@ "scripts/generate_documentation.sh" ] post_bump_hooks = ["scripts/slack_notification.sh"] +""" + +PYPROJECT = f""" +{TOML_STR} [tool.black] line-length = 88 target-version = ['py36', 'py37', 'py38'] """ + DICT_CONFIG = { "commitizen": { "name": "cz_jira", @@ -198,7 +203,7 @@ def test_load_empty_pyproject_toml_and_cz_toml_with_config(self, tmpdir): p = tmpdir.join("pyproject.toml") p.write("") p = tmpdir.join(".cz.toml") - p.write(PYPROJECT) + p.write(TOML_STR) cfg = config.read_cfg() assert cfg.settings == _settings @@ -240,27 +245,25 @@ def test_load_empty_pyproject_toml_from_config_argument(self, tmpdir): class TestWarnMultipleConfigFiles: @pytest.mark.parametrize( - "files,expected_path,should_warn", + "files,expected_path", [ # Same directory, different file types - ([(".cz.toml", PYPROJECT), (".cz.json", JSON_STR)], ".cz.toml", True), - ([(".cz.json", JSON_STR), (".cz.yaml", YAML_STR)], ".cz.json", True), - ([(".cz.toml", PYPROJECT), (".cz.yaml", YAML_STR)], ".cz.toml", True), - # With pyproject.toml (excluded from warning) + ([(".cz.toml", TOML_STR), (".cz.json", JSON_STR)], ".cz.toml"), + ([(".cz.json", JSON_STR), (".cz.yaml", YAML_STR)], ".cz.json"), + ([(".cz.toml", TOML_STR), (".cz.yaml", YAML_STR)], ".cz.toml"), + # With pyproject.toml ( [("pyproject.toml", PYPROJECT), (".cz.json", JSON_STR)], ".cz.json", - False, ), ( - [("pyproject.toml", PYPROJECT), (".cz.toml", PYPROJECT)], + [("pyproject.toml", PYPROJECT), (".cz.toml", TOML_STR)], ".cz.toml", - False, ), ], ) def test_warn_multiple_config_files_same_dir( - self, tmpdir, capsys, files, expected_path, should_warn + self, tmpdir, capsys, files, expected_path ): """Test warning when multiple config files exist in same directory.""" with tmpdir.as_cwd(): @@ -270,27 +273,20 @@ def test_warn_multiple_config_files_same_dir( cfg = config.read_cfg() captured = capsys.readouterr() - if should_warn: - assert "Multiple config files detected" in captured.err - assert "Using" in captured.err - for filename, _ in files: - if filename != "pyproject.toml": - assert filename in captured.err - else: - assert "Multiple config files detected" not in captured.err + assert "Multiple config files detected" in captured.err + for filename, _ in files: + assert filename in captured.err + assert f"Using config file: '{expected_path}'" in captured.err assert cfg.path == Path(expected_path) - # Verify config loaded correctly (name and version match expected) - assert cfg.settings["name"] == "cz_jira" - assert cfg.settings["version"] == "1.0.0" @pytest.mark.parametrize( "config_file,content", [ (".cz.json", JSON_STR), - (".cz.toml", PYPROJECT), + (".cz.toml", TOML_STR), (".cz.yaml", YAML_STR), - ("cz.toml", PYPROJECT), + ("cz.toml", TOML_STR), ("cz.json", JSON_STR), ("cz.yaml", YAML_STR), ], @@ -340,11 +336,11 @@ def test_no_warn_with_explicit_config_path(self, tmpdir, capsys): [ (file, content, with_git) for file, content in [ - (".cz.toml", PYPROJECT), + (".cz.toml", TOML_STR), (".cz.json", JSON_STR), (".cz.yaml", YAML_STR), ("pyproject.toml", PYPROJECT), - ("cz.toml", PYPROJECT), + ("cz.toml", TOML_STR), ("cz.json", JSON_STR), ("cz.yaml", YAML_STR), ] @@ -368,6 +364,18 @@ def test_no_warn_with_single_config_file( assert "Multiple config files detected" not in captured.err assert cfg.path == Path(config_file) + def test_no_warn_with_no_commitizen_section_in_pyproject_toml_and_cz_toml( + self, tmpdir, capsys + ): + with tmpdir.as_cwd(): + tmpdir.join("pyproject.toml").write("[tool.foo]\nbar = 'baz'") + tmpdir.join(".cz.toml").write(TOML_STR) + + cfg = config.read_cfg() + captured = capsys.readouterr() + assert "Multiple config files detected" not in captured.err + assert cfg.path == Path(".cz.toml") + @pytest.mark.parametrize( "config_file", From 5ef1be5164256c2cb2106606e0a19580e1477f86 Mon Sep 17 00:00:00 2001 From: YU HAN-CHENG Date: Sat, 31 Jan 2026 16:24:19 +0800 Subject: [PATCH 15/19] test: add match parameter to pytest.warns to resolve PT030 (#1828) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: 余翰承 --- pyproject.toml | 1 - tests/commands/test_bump_command.py | 4 ++-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 18ebe46362..38cf5da23c 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -243,7 +243,6 @@ ignore = [ "PT007", # TODO(bearomorphism): enable this rule "PT011", # TODO(bearomorphism): enable this rule "PT022", # TODO(bearomorphism): enable this rule - "PT030", # TODO(bearomorphism): enable this rule ] extend-safe-fixes = [ "TC", # Move imports inside/outside TYPE_CHECKING blocks diff --git a/tests/commands/test_bump_command.py b/tests/commands/test_bump_command.py index b9a6bf90f0..2c4bd269bc 100644 --- a/tests/commands/test_bump_command.py +++ b/tests/commands/test_bump_command.py @@ -1027,7 +1027,7 @@ def test_bump_with_major_version_zero_with_plugin( def test_bump_command_version_type_deprecation(util: UtilFixture): util.create_file_and_commit("feat: check deprecation on --version-type") - with pytest.warns(DeprecationWarning): + with pytest.warns(DeprecationWarning, match=r".*--version-type.*deprecated"): util.run_cli( "bump", "--prerelease", @@ -1044,7 +1044,7 @@ def test_bump_command_version_type_deprecation(util: UtilFixture): def test_bump_command_version_scheme_priority_over_version_type(util: UtilFixture): util.create_file_and_commit("feat: check deprecation on --version-type") - with pytest.warns(DeprecationWarning): + with pytest.warns(DeprecationWarning, match=r".*--version-type.*deprecated"): util.run_cli( "bump", "--prerelease", From 107680da73b7b126be33ff3b06a50e66ffa24fc6 Mon Sep 17 00:00:00 2001 From: Tim Hsiung Date: Sat, 31 Jan 2026 20:53:41 +0800 Subject: [PATCH 16/19] refactor: replace hard-coded string "cz_conventional_commits" with DEFAULT_SETTINGS (#1830) --- commitizen/cli.py | 3 ++- commitizen/commands/init.py | 4 ++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/commitizen/cli.py b/commitizen/cli.py index d057bd97dc..854238cc9b 100644 --- a/commitizen/cli.py +++ b/commitizen/cli.py @@ -13,6 +13,7 @@ from decli import cli from commitizen import commands, config, out, version_schemes +from commitizen.defaults import DEFAULT_SETTINGS from commitizen.exceptions import ( CommitizenException, ExitCode, @@ -672,7 +673,7 @@ def main() -> None: if args.name: conf.update({"name": args.name}) elif not conf.path: - conf.update({"name": "cz_conventional_commits"}) + conf.update({"name": DEFAULT_SETTINGS["name"]}) if args.debug: logging.getLogger("commitizen").setLevel(logging.DEBUG) diff --git a/commitizen/commands/init.py b/commitizen/commands/init.py index 0773b71e42..9d33e7081a 100644 --- a/commitizen/commands/init.py +++ b/commitizen/commands/init.py @@ -170,9 +170,9 @@ def _ask_config_path(self) -> Path: def _ask_name(self) -> str: name: str = questionary.select( - "Please choose a cz (commit rule): (default: cz_conventional_commits)", + f"Please choose a cz (commit rule): (default: {DEFAULT_SETTINGS['name']})", choices=self._construct_name_choice_with_description(), - default="cz_conventional_commits", + default=DEFAULT_SETTINGS["name"], style=self.cz.style, ).unsafe_ask() return name From ad35515244ee1bbb6005e0e807ef3b5e2eafdeae Mon Sep 17 00:00:00 2001 From: Tim Hsiung Date: Sun, 1 Feb 2026 18:53:42 +0800 Subject: [PATCH 17/19] feat(bump): add --version-files-only and deprecate --files-only (#1802) Co-authored-by: abhishek --- commitizen/cli.py | 7 ++++++- commitizen/commands/bump.py | 10 +++++++++- docs/commands/bump.md | 4 ++-- tests/commands/test_bump_command.py | 15 +++++++++++++-- ...ription_when_use_help_option_py_3_10_bump_.txt | 13 ++++++++----- ...ription_when_use_help_option_py_3_11_bump_.txt | 13 ++++++++----- ...ription_when_use_help_option_py_3_12_bump_.txt | 13 ++++++++----- ...ription_when_use_help_option_py_3_13_bump_.txt | 13 ++++++++----- ...ription_when_use_help_option_py_3_14_bump_.txt | 13 ++++++++----- 9 files changed, 70 insertions(+), 31 deletions(-) diff --git a/commitizen/cli.py b/commitizen/cli.py index 854238cc9b..79988fb5cb 100644 --- a/commitizen/cli.py +++ b/commitizen/cli.py @@ -210,7 +210,12 @@ def __call__( { "name": "--files-only", # TODO: rename to --version-files-only "action": "store_true", - "help": "Bump version in the `version_files` specified in the configuration file only.", + "help": "Bump version in the `version_files` specified in the configuration file only(deprecated; use --version-files-only instead).", + }, + { + "name": "--version-files-only", + "action": "store_true", + "help": "Bump version in the files from the config", }, { "name": "--local-version", diff --git a/commitizen/commands/bump.py b/commitizen/commands/bump.py index affe2bd358..6084c8c151 100644 --- a/commitizen/commands/bump.py +++ b/commitizen/commands/bump.py @@ -49,6 +49,7 @@ class BumpArgs(Settings, total=False): dry_run: bool file_name: str files_only: bool | None + version_files_only: bool | None get_next: bool # TODO: maybe rename to `next_version_to_stdout` git_output_to_stderr: bool increment_mode: str @@ -365,7 +366,14 @@ def __call__(self) -> None: changelog_file_name=changelog_file_name, ) - if self.arguments["files_only"]: + if self.arguments.get("files_only"): + warnings.warn( + "--files-only is deprecated and will be removed in v5. Use --version-files-only instead.", + DeprecationWarning, + ) + raise ExpectedExit() + + if self.arguments.get("version_files_only"): raise ExpectedExit() # FIXME: check if any changes have been staged diff --git a/docs/commands/bump.md b/docs/commands/bump.md index 03fc83402c..cbd6d5452b 100644 --- a/docs/commands/bump.md +++ b/docs/commands/bump.md @@ -122,12 +122,12 @@ Commitizen supports the [PEP 440][pep440] version format, which includes several ![cz bump --help](../images/cli_help/cz_bump___help.svg) -### `--files-only` +### `--version-files-only` Bumps the version in the files defined in [`version_files`][version_files] without creating a commit and tag on the git repository. ```bash -cz bump --files-only +cz bump --version-files-only ``` ### `--changelog` diff --git a/tests/commands/test_bump_command.py b/tests/commands/test_bump_command.py index 2c4bd269bc..d458e34d8e 100644 --- a/tests/commands/test_bump_command.py +++ b/tests/commands/test_bump_command.py @@ -418,7 +418,8 @@ def test_bump_files_only(tmp_commitizen_project, util: UtilFixture): util.create_file_and_commit("feat: another new feature") with pytest.raises(ExpectedExit): - util.run_cli("bump", "--yes", "--files-only") + util.run_cli("bump", "--yes", "--version-files-only") + assert git.tag_exist("0.3.0") is False with open(tmp_version_file, encoding="utf-8") as f: @@ -1204,7 +1205,7 @@ def test_bump_changelog_contains_increment_only( # it should only include v3 changes util.create_file_and_commit("feat(next)!: next version") with pytest.raises(ExpectedExit): - util.run_cli("bump", "--yes", "--files-only", "--changelog-to-stdout") + util.run_cli("bump", "--yes", "--version-files-only", "--changelog-to-stdout") out, _ = capsys.readouterr() assert "3.0.0" in out @@ -1492,3 +1493,13 @@ def test_changelog_config_flag_merge_prerelease_only_prerelease_present( out = f.read() file_regression.check(out, extension=".md") + + +@pytest.mark.usefixtures("tmp_commitizen_project") +def test_bump_deprecate_files_only(util: UtilFixture): + util.create_file_and_commit("feat: new file") + with ( + pytest.warns(DeprecationWarning, match=r".*--files-only.*deprecated"), + pytest.raises(ExpectedExit), + ): + util.run_cli("bump", "--yes", "--files-only") diff --git a/tests/commands/test_common_command/test_command_shows_description_when_use_help_option_py_3_10_bump_.txt b/tests/commands/test_common_command/test_command_shows_description_when_use_help_option_py_3_10_bump_.txt index d56e739277..fa696d063d 100644 --- a/tests/commands/test_common_command/test_command_shows_description_when_use_help_option_py_3_10_bump_.txt +++ b/tests/commands/test_common_command/test_command_shows_description_when_use_help_option_py_3_10_bump_.txt @@ -1,7 +1,8 @@ -usage: cz bump [-h] [--dry-run] [--files-only] [--local-version] [--changelog] - [--no-verify] [--yes] [--tag-format TAG_FORMAT] - [--bump-message BUMP_MESSAGE] [--prerelease {alpha,beta,rc}] - [--devrelease DEVRELEASE] [--increment {MAJOR,MINOR,PATCH}] +usage: cz bump [-h] [--dry-run] [--files-only] [--version-files-only] + [--local-version] [--changelog] [--no-verify] [--yes] + [--tag-format TAG_FORMAT] [--bump-message BUMP_MESSAGE] + [--prerelease {alpha,beta,rc}] [--devrelease DEVRELEASE] + [--increment {MAJOR,MINOR,PATCH}] [--increment-mode {linear,exact}] [--check-consistency] [--annotated-tag] [--annotated-tag-message ANNOTATED_TAG_MESSAGE] [--gpg-sign] @@ -24,7 +25,9 @@ options: --dry-run Perform a dry run, without committing or modifying files. --files-only Bump version in the `version_files` specified in the - configuration file only. + configuration file only(deprecated; use --version- + files-only instead). + --version-files-only Bump version in the files from the config --local-version Bump version only the local version portion (ignoring the public version). --changelog, -ch Generate the changelog for the latest version. diff --git a/tests/commands/test_common_command/test_command_shows_description_when_use_help_option_py_3_11_bump_.txt b/tests/commands/test_common_command/test_command_shows_description_when_use_help_option_py_3_11_bump_.txt index d56e739277..fa696d063d 100644 --- a/tests/commands/test_common_command/test_command_shows_description_when_use_help_option_py_3_11_bump_.txt +++ b/tests/commands/test_common_command/test_command_shows_description_when_use_help_option_py_3_11_bump_.txt @@ -1,7 +1,8 @@ -usage: cz bump [-h] [--dry-run] [--files-only] [--local-version] [--changelog] - [--no-verify] [--yes] [--tag-format TAG_FORMAT] - [--bump-message BUMP_MESSAGE] [--prerelease {alpha,beta,rc}] - [--devrelease DEVRELEASE] [--increment {MAJOR,MINOR,PATCH}] +usage: cz bump [-h] [--dry-run] [--files-only] [--version-files-only] + [--local-version] [--changelog] [--no-verify] [--yes] + [--tag-format TAG_FORMAT] [--bump-message BUMP_MESSAGE] + [--prerelease {alpha,beta,rc}] [--devrelease DEVRELEASE] + [--increment {MAJOR,MINOR,PATCH}] [--increment-mode {linear,exact}] [--check-consistency] [--annotated-tag] [--annotated-tag-message ANNOTATED_TAG_MESSAGE] [--gpg-sign] @@ -24,7 +25,9 @@ options: --dry-run Perform a dry run, without committing or modifying files. --files-only Bump version in the `version_files` specified in the - configuration file only. + configuration file only(deprecated; use --version- + files-only instead). + --version-files-only Bump version in the files from the config --local-version Bump version only the local version portion (ignoring the public version). --changelog, -ch Generate the changelog for the latest version. diff --git a/tests/commands/test_common_command/test_command_shows_description_when_use_help_option_py_3_12_bump_.txt b/tests/commands/test_common_command/test_command_shows_description_when_use_help_option_py_3_12_bump_.txt index d56e739277..fa696d063d 100644 --- a/tests/commands/test_common_command/test_command_shows_description_when_use_help_option_py_3_12_bump_.txt +++ b/tests/commands/test_common_command/test_command_shows_description_when_use_help_option_py_3_12_bump_.txt @@ -1,7 +1,8 @@ -usage: cz bump [-h] [--dry-run] [--files-only] [--local-version] [--changelog] - [--no-verify] [--yes] [--tag-format TAG_FORMAT] - [--bump-message BUMP_MESSAGE] [--prerelease {alpha,beta,rc}] - [--devrelease DEVRELEASE] [--increment {MAJOR,MINOR,PATCH}] +usage: cz bump [-h] [--dry-run] [--files-only] [--version-files-only] + [--local-version] [--changelog] [--no-verify] [--yes] + [--tag-format TAG_FORMAT] [--bump-message BUMP_MESSAGE] + [--prerelease {alpha,beta,rc}] [--devrelease DEVRELEASE] + [--increment {MAJOR,MINOR,PATCH}] [--increment-mode {linear,exact}] [--check-consistency] [--annotated-tag] [--annotated-tag-message ANNOTATED_TAG_MESSAGE] [--gpg-sign] @@ -24,7 +25,9 @@ options: --dry-run Perform a dry run, without committing or modifying files. --files-only Bump version in the `version_files` specified in the - configuration file only. + configuration file only(deprecated; use --version- + files-only instead). + --version-files-only Bump version in the files from the config --local-version Bump version only the local version portion (ignoring the public version). --changelog, -ch Generate the changelog for the latest version. diff --git a/tests/commands/test_common_command/test_command_shows_description_when_use_help_option_py_3_13_bump_.txt b/tests/commands/test_common_command/test_command_shows_description_when_use_help_option_py_3_13_bump_.txt index c472a040e9..8e4c863585 100644 --- a/tests/commands/test_common_command/test_command_shows_description_when_use_help_option_py_3_13_bump_.txt +++ b/tests/commands/test_common_command/test_command_shows_description_when_use_help_option_py_3_13_bump_.txt @@ -1,7 +1,8 @@ -usage: cz bump [-h] [--dry-run] [--files-only] [--local-version] [--changelog] - [--no-verify] [--yes] [--tag-format TAG_FORMAT] - [--bump-message BUMP_MESSAGE] [--prerelease {alpha,beta,rc}] - [--devrelease DEVRELEASE] [--increment {MAJOR,MINOR,PATCH}] +usage: cz bump [-h] [--dry-run] [--files-only] [--version-files-only] + [--local-version] [--changelog] [--no-verify] [--yes] + [--tag-format TAG_FORMAT] [--bump-message BUMP_MESSAGE] + [--prerelease {alpha,beta,rc}] [--devrelease DEVRELEASE] + [--increment {MAJOR,MINOR,PATCH}] [--increment-mode {linear,exact}] [--check-consistency] [--annotated-tag] [--annotated-tag-message ANNOTATED_TAG_MESSAGE] [--gpg-sign] @@ -24,7 +25,9 @@ options: --dry-run Perform a dry run, without committing or modifying files. --files-only Bump version in the `version_files` specified in the - configuration file only. + configuration file only(deprecated; use --version- + files-only instead). + --version-files-only Bump version in the files from the config --local-version Bump version only the local version portion (ignoring the public version). --changelog, -ch Generate the changelog for the latest version. diff --git a/tests/commands/test_common_command/test_command_shows_description_when_use_help_option_py_3_14_bump_.txt b/tests/commands/test_common_command/test_command_shows_description_when_use_help_option_py_3_14_bump_.txt index c472a040e9..8e4c863585 100644 --- a/tests/commands/test_common_command/test_command_shows_description_when_use_help_option_py_3_14_bump_.txt +++ b/tests/commands/test_common_command/test_command_shows_description_when_use_help_option_py_3_14_bump_.txt @@ -1,7 +1,8 @@ -usage: cz bump [-h] [--dry-run] [--files-only] [--local-version] [--changelog] - [--no-verify] [--yes] [--tag-format TAG_FORMAT] - [--bump-message BUMP_MESSAGE] [--prerelease {alpha,beta,rc}] - [--devrelease DEVRELEASE] [--increment {MAJOR,MINOR,PATCH}] +usage: cz bump [-h] [--dry-run] [--files-only] [--version-files-only] + [--local-version] [--changelog] [--no-verify] [--yes] + [--tag-format TAG_FORMAT] [--bump-message BUMP_MESSAGE] + [--prerelease {alpha,beta,rc}] [--devrelease DEVRELEASE] + [--increment {MAJOR,MINOR,PATCH}] [--increment-mode {linear,exact}] [--check-consistency] [--annotated-tag] [--annotated-tag-message ANNOTATED_TAG_MESSAGE] [--gpg-sign] @@ -24,7 +25,9 @@ options: --dry-run Perform a dry run, without committing or modifying files. --files-only Bump version in the `version_files` specified in the - configuration file only. + configuration file only(deprecated; use --version- + files-only instead). + --version-files-only Bump version in the files from the config --local-version Bump version only the local version portion (ignoring the public version). --changelog, -ch Generate the changelog for the latest version. From d214704eaeae4c16b893f70b624f3bab477bc6a7 Mon Sep 17 00:00:00 2001 From: Yu-Ting Hsiung Date: Sun, 1 Feb 2026 18:54:56 +0800 Subject: [PATCH 18/19] Revert "fix(pre-commit-hooks): remove magic constants on pre-push hook (#1815)" This reverts commit 047c914f072a781c6daa1280f929f5a81a985690. --- .pre-commit-hooks.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.pre-commit-hooks.yaml b/.pre-commit-hooks.yaml index 650f0acedb..c142634581 100644 --- a/.pre-commit-hooks.yaml +++ b/.pre-commit-hooks.yaml @@ -19,7 +19,7 @@ the fact (e.g., pre-push or in CI) without an expensive check of the entire repository history. entry: cz check - args: [--rev-range, "$PRE_COMMIT_TO_REF $PRE_COMMIT_FROM_REF"] + args: [--rev-range, origin/HEAD..HEAD] always_run: true pass_filenames: false language: python From e6b6976e153400c192356640c8feeb4897b3ee2d Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Sun, 1 Feb 2026 11:00:47 +0000 Subject: [PATCH 19/19] =?UTF-8?q?bump:=20version=204.12.1=20=E2=86=92=204.?= =?UTF-8?q?13.0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .pre-commit-config.yaml | 2 +- CHANGELOG.md | 21 +++++++++++++++++++++ commitizen/__version__.py | 2 +- pyproject.toml | 2 +- uv.lock | 2 +- 5 files changed, 25 insertions(+), 4 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 2a7cc5672b..0f69f0a42e 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -56,7 +56,7 @@ repos: - tomli - repo: https://github.com/commitizen-tools/commitizen - rev: v4.12.1 # automatically updated by Commitizen + rev: v4.13.0 # automatically updated by Commitizen hooks: - id: commitizen - id: commitizen-branch diff --git a/CHANGELOG.md b/CHANGELOG.md index 6c7b7598c8..db91c63b39 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,24 @@ +## v4.13.0 (2026-02-01) + +### Feat + +- **bump**: add --version-files-only and deprecate --files-only (#1802) +- **version**: add --tag tag to version command (#1819) +- **cli**: add description when choosing a commit rule (#1825) +- **tags**: enable version schemes with less than 3 components (#1705) + +### Fix + +- **config**: include pyproject.toml in multi config file warning (#1803) +- add pytest ruff rule PT and fix missing deprecation warning (#1826) +- **message_length_limit**: align the behavior of message_length_limit (#1813) +- **cli**: capitalize the first characters of help texts and fix minor grammar errors + +### Refactor + +- replace hard-coded string "cz_conventional_commits" with DEFAULT_SETTINGS (#1830) +- **bump**: fix unbounded variable type issue + ## v4.12.1 (2026-01-22) ### Fix diff --git a/commitizen/__version__.py b/commitizen/__version__.py index 33111828cc..5b886240e3 100644 --- a/commitizen/__version__.py +++ b/commitizen/__version__.py @@ -1 +1 @@ -__version__ = "4.12.1" +__version__ = "4.13.0" diff --git a/pyproject.toml b/pyproject.toml index 38cf5da23c..ad639ba9bd 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [project] name = "commitizen" -version = "4.12.1" +version = "4.13.0" description = "Python commitizen client tool" authors = [{ name = "Santiago Fraire", email = "santiwilly@gmail.com" }] maintainers = [ diff --git a/uv.lock b/uv.lock index 75732c7ac0..69e2f8e9e4 100644 --- a/uv.lock +++ b/uv.lock @@ -195,7 +195,7 @@ wheels = [ [[package]] name = "commitizen" -version = "4.12.1" +version = "4.13.0" source = { editable = "." } dependencies = [ { name = "argcomplete" },