Skip to content

Commit 440c948

Browse files
Merge remote-tracking branch 'origin/master' into docs/skill-md-cleanup
# Conflicts: # .agents/skills/commitizen/SKILL.md Co-authored-by: bearomorphism <26526132+bearomorphism@users.noreply.github.com>
2 parents b501b2d + cc710a9 commit 440c948

28 files changed

Lines changed: 345 additions & 139 deletions

.agents/skills/commitizen/SKILL.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ license: MIT
55
metadata:
66
project: commitizen-tools/commitizen
77
docs: https://commitizen-tools.github.io/commitizen/
8-
install: "pip install commitizen"
8+
install: "pipx install commitizen"
99
---
1010

1111
# Commitizen
@@ -38,7 +38,7 @@ Commitizen is a CLI for enforcing Conventional Commits, automating version bumps
3838

3939
## Important domain details
4040

41-
- Commitizen installs with `pip install commitizen` or `uv add commitizen`.
41+
- Commitizen supports both global installation (recommended for the `cz` CLI) and project-local installation; see the installation section in `docs/README.md` for the full matrix of supported tools.
4242
- The default version scheme is PEP 440; `semver` and `semver2` are also supported.
4343
- Common version providers include `commitizen`, `pep621`, `poetry`, `cargo`, `npm`, `composer`, `uv`, and `scm`.
4444
- `cz changelog` generates Markdown changelogs.

.github/CODEOWNERS

Lines changed: 0 additions & 1 deletion
This file was deleted.

.github/workflows/bumpversion.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ jobs:
3939
- id: bump-version
4040
run: |
4141
old_sha="$(git rev-parse HEAD)"
42-
cz bump --yes --no-raise 21
42+
cz --no-raise 21 bump --yes
4343
4444
if [ "$(git rev-parse HEAD)" = "$old_sha" ]; then
4545
echo "No bump-eligible commits found, skipping release."

.github/workflows/pythonpublish.yml

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,15 @@ on:
55
push:
66
tags:
77
- "v*"
8+
# Manual trigger for republishing a specific tag if the original push-on-tag
9+
# run failed and is now too old to be re-run via the GitHub UI (#1790).
10+
# ``ref`` should be a tag name like ``v4.11.1``.
11+
workflow_dispatch:
12+
inputs:
13+
ref:
14+
description: "Tag to republish (e.g., v4.11.1)"
15+
required: true
16+
type: string
817

918
jobs:
1019
deploy:
@@ -14,10 +23,19 @@ jobs:
1423
id-token: write
1524
contents: read
1625
steps:
26+
- name: Validate dispatch ref is a tag
27+
if: github.event_name == 'workflow_dispatch'
28+
env:
29+
TAG: ${{ github.event.inputs.ref }}
30+
run: |
31+
if ! git ls-remote --tags "https://github.com/${GITHUB_REPOSITORY}" "refs/tags/${TAG}" | grep -q .; then
32+
echo "::error::Dispatch ref '${TAG}' is not an existing tag"
33+
exit 1
34+
fi
1735
- uses: actions/checkout@v6
1836
with:
1937
fetch-depth: 0
20-
ref: ${{ github.ref_name }}
38+
ref: ${{ github.event_name == 'workflow_dispatch' && format('refs/tags/{0}', github.event.inputs.ref) || github.ref }}
2139
- name: Set up Python
2240
uses: astral-sh/setup-uv@v7
2341
- name: Build

.pre-commit-config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ repos:
5656
- tomli
5757

5858
- repo: https://github.com/commitizen-tools/commitizen
59-
rev: v4.15.1 # automatically updated by Commitizen
59+
rev: v4.16.2 # automatically updated by Commitizen
6060
hooks:
6161
- id: commitizen
6262
- id: commitizen-branch

commitizen/__version__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
__version__ = "4.15.1"
1+
__version__ = "4.16.2"

commitizen/cz/customize/customize.py

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
from __future__ import annotations
22

3+
from collections import OrderedDict
34
from pathlib import Path
45
from typing import TYPE_CHECKING, Any
56

@@ -19,11 +20,29 @@
1920

2021
from commitizen import defaults
2122
from commitizen.cz.base import BaseCommitizen
23+
from commitizen.defaults import MAJOR, MINOR
2224
from commitizen.exceptions import MissingCzCustomizeConfigError
2325

2426
__all__ = ["CustomizeCommitsCz"]
2527

2628

29+
def _derive_major_version_zero(
30+
bump_map: Mapping[str, str],
31+
) -> OrderedDict[str, str]:
32+
"""Derive a ``bump_map_major_version_zero`` from a user-supplied
33+
``bump_map`` by demoting any ``MAJOR`` rule to ``MINOR``.
34+
35+
See #1728: when a ``cz_customize`` user supplies ``bump_map`` but not
36+
``bump_map_major_version_zero``, the latter previously fell through to
37+
``defaults.BUMP_MAP_MAJOR_VERSION_ZERO``, silently overriding the
38+
user's intent during ``major_version_zero = true`` bumps.
39+
"""
40+
return OrderedDict(
41+
(pattern, MINOR if increment == MAJOR else increment)
42+
for pattern, increment in bump_map.items()
43+
)
44+
45+
2746
class CustomizeCommitsCz(BaseCommitizen):
2847
bump_pattern = defaults.BUMP_PATTERN
2948
bump_map = defaults.BUMP_MAP
@@ -49,6 +68,16 @@ def __init__(self, config: BaseConfig) -> None:
4968
if value := self.custom_settings.get(attr_name):
5069
setattr(self, attr_name, value)
5170

71+
# When the user supplies a custom ``bump_map`` but no matching
72+
# ``bump_map_major_version_zero``, derive the latter so that bumps
73+
# under ``major_version_zero = true`` use the user's mapping rather
74+
# than the (totally unrelated) ``defaults.BUMP_MAP_MAJOR_VERSION_ZERO``
75+
# fallback. See #1728.
76+
if self.custom_settings.get("bump_map") and not self.custom_settings.get(
77+
"bump_map_major_version_zero"
78+
):
79+
self.bump_map_major_version_zero = _derive_major_version_zero(self.bump_map)
80+
5281
def questions(self) -> list[CzQuestion]:
5382
return self.custom_settings.get("questions", [{}]) # type: ignore[return-value]
5483

commitizen/defaults.py

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -156,8 +156,17 @@ def get_tag_regexes(
156156
"major": r"(?P<major>\d+)",
157157
"minor": r"(?P<minor>\d+)",
158158
"patch": r"(?P<patch>\d+)",
159-
"prerelease": r"(?P<prerelease>\w+\d+)?",
160-
"devrelease": r"(?P<devrelease>\.dev\d+)?",
159+
# Allow ``\w+`` (PEP-440 ``rc0``) as well as ``\w+\.\w+(\.\w+)*``
160+
# (SemVer2 ``rc.0``, ``alpha.beta.1``). The original ``\w+\d+`` only
161+
# matched the PEP-440 form and produced "Invalid version tag" warnings
162+
# for SemVer2-style tags created by commitizen itself (#1614).
163+
"prerelease": r"(?P<prerelease>\w+(?:\.\w+)*)?",
164+
# Match either ``.dev1`` (PEP-440 with leading dot) or ``dev1``
165+
# (SemVer / SemVer2 / users substituting ``${devrelease}`` directly
166+
# in a ``tag_format`` -- see #1615). A bare ``\d+`` after the prefix
167+
# would let the regex match arbitrary numeric suffixes, so the
168+
# ``dev`` literal is required.
169+
"devrelease": r"(?P<devrelease>\.?dev\d+)?",
161170
}
162171
return {
163172
**{f"${k}": v for k, v in regexes.items()},

docs/exit_codes.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,24 @@ The `--no-raise` (or `-nr`) flag allows you to specify exit codes that should no
5757

5858
Multiple exit codes can be specified as a comma-separated list.
5959

60+
!!! warning "Flag placement"
61+
`--no-raise` / `-nr` is a **top-level Commitizen flag**, so it must be passed
62+
**before** the subcommand:
63+
64+
```sh
65+
cz --no-raise 21 bump --yes # ✅ correct
66+
cz -nr 21 bump --yes # ✅ correct (short form)
67+
```
68+
69+
Placing it after the subcommand fails with exit code 18
70+
(`InvalidCommandArgumentError`):
71+
72+
```sh
73+
cz bump --yes --no-raise 21 # ❌ wrong
74+
# Invalid commitizen arguments were found: `--no-raise`.
75+
# Please use -- separator for extra git args
76+
```
77+
6078
### Common Use Cases
6179

6280
#### Ignoring No Increment Errors
-773 Bytes
Loading

0 commit comments

Comments
 (0)