Skip to content

Commit 2841bcc

Browse files
authored
Merge branch 'v4-9-0-test' into fix_deprecated_precommit
2 parents 9f063cd + a69d441 commit 2841bcc

File tree

12 files changed

+133
-159
lines changed

12 files changed

+133
-159
lines changed

.github/workflows/docspublish.yml

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ on:
44
push:
55
branches:
66
- master
7+
workflow_dispatch:
78

89
jobs:
910
update-cli-screenshots:
@@ -58,21 +59,19 @@ jobs:
5859
python -m pip install -U pip poetry poethepoet
5960
poetry --version
6061
poetry install --no-root --only documentation
61-
- name: Build docs
62-
env:
63-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
64-
run: |
65-
poetry doc:build
6662
- name: Generate Sponsors 💖
6763
uses: JamesIves/github-sponsors-readme-action@v1
6864
with:
6965
token: ${{ secrets.PERSONAL_ACCESS_TOKEN_FOR_ORG }}
7066
file: "docs/README.md"
71-
- name: Push doc to Github Page
72-
uses: peaceiris/actions-gh-pages@v4
67+
organization: true
68+
- name: Build docs
69+
env:
70+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
71+
run: |
72+
poetry doc:build
73+
- name: Deploy 🚀
74+
uses: JamesIves/github-pages-deploy-action@v4
7375
with:
74-
personal_token: ${{ secrets.PERSONAL_ACCESS_TOKEN }}
75-
publish_branch: gh-pages
76-
publish_dir: ./site
77-
user_name: "github-actions[bot]"
78-
user_email: "github-actions[bot]@users.noreply.github.com"
76+
folder: ./site # The folder the action should deploy.
77+
branch: gh-pages

.github/workflows/homebrewpublish.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ jobs:
2424
run: |
2525
echo "project_version=$(cz version --project)" >> $GITHUB_ENV
2626
- name: Update Homebrew formula
27-
uses: dawidd6/action-homebrew-bump-formula@v4
27+
uses: dawidd6/action-homebrew-bump-formula@v5
2828
with:
2929
token: ${{secrets.PERSONAL_ACCESS_TOKEN}}
3030
formula: commitizen

commitizen/changelog.py

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929

3030
import re
3131
from collections import OrderedDict, defaultdict
32-
from collections.abc import Generator, Iterable, Mapping, Sequence
32+
from collections.abc import Generator, Iterable, Mapping, MutableMapping, Sequence
3333
from dataclasses import dataclass
3434
from datetime import date
3535
from typing import TYPE_CHECKING, Any
@@ -167,8 +167,8 @@ def process_commit_message(
167167
hook: MessageBuilderHook | None,
168168
parsed: re.Match[str],
169169
commit: GitCommit,
170-
changes: dict[str | None, list],
171-
change_type_map: dict[str, str] | None = None,
170+
ref_changes: MutableMapping[str | None, list],
171+
change_type_map: Mapping[str, str] | None = None,
172172
) -> None:
173173
message: dict[str, Any] = {
174174
"sha1": commit.rev,
@@ -178,13 +178,16 @@ def process_commit_message(
178178
**parsed.groupdict(),
179179
}
180180

181-
if processed := hook(message, commit) if hook else message:
182-
messages = [processed] if isinstance(processed, dict) else processed
183-
for msg in messages:
184-
change_type = msg.pop("change_type", None)
185-
if change_type_map:
186-
change_type = change_type_map.get(change_type, change_type)
187-
changes[change_type].append(msg)
181+
processed_msg = hook(message, commit) if hook else message
182+
if not processed_msg:
183+
return
184+
185+
messages = [processed_msg] if isinstance(processed_msg, dict) else processed_msg
186+
for msg in messages:
187+
change_type = msg.pop("change_type", None)
188+
if change_type_map:
189+
change_type = change_type_map.get(change_type, change_type)
190+
ref_changes[change_type].append(msg)
188191

189192

190193
def generate_ordered_changelog_tree(

commitizen/commands/init.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -238,7 +238,7 @@ def _ask_version_provider(self) -> str:
238238
"npm": "npm: Get and set version from package.json:project.version field",
239239
"pep621": "pep621: Get and set version from pyproject.toml:project.version field",
240240
"poetry": "poetry: Get and set version from pyproject.toml:tool.poetry.version field",
241-
"uv": "uv: Get and Get and set version from pyproject.toml and uv.lock",
241+
"uv": "uv: Get and set version from pyproject.toml and uv.lock",
242242
"scm": "scm: Fetch the version from git and does not need to set it back",
243243
}
244244

commitizen/defaults.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,6 @@
88

99
from commitizen.question import CzQuestion
1010

11-
# Type
12-
Questions = Iterable[MutableMapping[str, Any]] # TODO: deprecate this?
13-
1411

1512
class CzSettings(TypedDict, total=False):
1613
bump_pattern: str
@@ -161,6 +158,10 @@ def get_tag_regexes(
161158
}
162159

163160

161+
# Type
162+
Questions = Iterable[MutableMapping[str, Any]] # TODO: remove this in v5
163+
164+
164165
def __getattr__(name: str) -> Any:
165166
# PEP-562: deprecate module-level variable
166167

@@ -176,6 +177,7 @@ def __getattr__(name: str) -> Any:
176177
"change_type_order": (CHANGE_TYPE_ORDER, "CHANGE_TYPE_ORDER"),
177178
"encoding": (ENCODING, "ENCODING"),
178179
"name": (DEFAULT_SETTINGS["name"], "DEFAULT_SETTINGS['name']"),
180+
"Questions": (Questions, "Iterable[CzQuestion]"),
179181
}
180182
if name in deprecated_vars:
181183
value, replacement = deprecated_vars[name]

docs/README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ Before installing Commitizen, ensure you have:
6363
#### Global Installation (Recommended)
6464

6565
The recommended way to install Commitizen is using [`pipx`](https://pipx.pypa.io/) or [`uv`](https://docs.astral.sh/uv/), which ensures a clean, isolated installation:
66+
6667
**Using pipx:**
6768
```bash
6869
# Install Commitizen
@@ -111,7 +112,7 @@ poetry add commitizen --dev
111112

112113
**Using uv:**
113114
```bash
114-
uv add commitizen
115+
uv add --dev commitizen
115116
```
116117

117118
**Using pdm:**

docs/commands/bump.md

Lines changed: 24 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ cz bump --version-scheme semver
3131
```
3232

3333
2. Configuration file:
34-
```toml
34+
```toml title="pyproject.toml"
3535
[tool.commitizen]
3636
version_scheme = "semver"
3737
```
@@ -113,7 +113,7 @@ Note that as per [semantic versioning spec](https://semver.org/#spec-item-9)
113113
For example, the following versions (using the [PEP 440](https://peps.python.org/pep-0440/) scheme) are ordered
114114
by their precedence and showcase how a release might flow through a development cycle:
115115

116-
- `1.0.0` is the current published version
116+
- `1.0.0` is the currently published version
117117
- `1.0.1a0` after committing a `fix:` for pre-release
118118
- `1.1.0a1` after committing an additional `feat:` for pre-release
119119
- `1.1.0b0` after bumping a beta release
@@ -153,7 +153,7 @@ cz bump --check-consistency
153153

154154
For example, if we have `pyproject.toml`
155155

156-
```toml
156+
```toml title="pyproject.toml"
157157
[tool.commitizen]
158158
version = "1.21.0"
159159
version_files = [
@@ -162,15 +162,16 @@ version_files = [
162162
]
163163
```
164164

165-
`src/__version__.py`,
165+
`src/__version__.py`
166166

167-
```python
167+
168+
```python title="src/__version__.py"
168169
__version__ = "1.21.0"
169170
```
170171

171-
and `setup.py`.
172+
and `setup.py`
172173

173-
```python
174+
```python title="setup.py"
174175
from setuptools import setup
175176

176177
setup(..., version="1.0.5", ...)
@@ -193,7 +194,7 @@ cz bump --local-version
193194

194195
For example, if we have `pyproject.toml`
195196

196-
```toml
197+
```toml title="pyproject.toml"
197198
[tool.commitizen]
198199
version = "5.3.5+0.1.0"
199200
```
@@ -454,7 +455,7 @@ In your `pyproject.toml` or `.cz.toml`
454455
tag_format = "v$major.$minor.$patch$prerelease"
455456
```
456457

457-
The variables must be preceded by a `$` sign and optionally can be wrapped in `{}` . Default is `$version`.
458+
The variables must be preceded by a `$` sign and optionally can be wrapped in `{}`. The default is `$version`.
458459

459460
Supported variables:
460461

@@ -471,7 +472,7 @@ Supported variables:
471472

472473
### `version_files` \*
473474

474-
It is used to identify the files which should be updated with the new version.
475+
It is used to identify the files or glob patterns which should be updated with the new version.
475476
It is also possible to provide a pattern for each file, separated by colons (`:`).
476477

477478
Commitizen will update its configuration file automatically (`pyproject.toml`, `.cz`) when bumping,
@@ -483,11 +484,12 @@ Some examples
483484

484485
`pyproject.toml`, `.cz.toml` or `cz.toml`
485486

486-
```toml
487+
```toml title="pyproject.toml"
487488
[tool.commitizen]
488489
version_files = [
489490
"src/__version__.py",
490-
"setup.py:version"
491+
"packages/*/pyproject.toml:version",
492+
"setup.py:version",
491493
]
492494
```
493495

@@ -496,8 +498,7 @@ This means that it will find a file `setup.py` and will only make a change
496498
in a line containing the `version` substring.
497499

498500
!!! note
499-
Files can be specified using relative (to the execution) paths, absolute paths
500-
or glob patterns.
501+
Files can be specified using relative (to the execution) paths, absolute paths, or glob patterns.
501502

502503
---
503504

@@ -516,7 +517,7 @@ Some examples
516517

517518
`pyproject.toml`, `.cz.toml` or `cz.toml`
518519

519-
```toml
520+
```toml title="pyproject.toml"
520521
[tool.commitizen]
521522
bump_message = "release $current_version → $new_version [skip-ci]"
522523
```
@@ -529,7 +530,7 @@ When set to `true` the changelog is always updated incrementally when running `c
529530

530531
Defaults to: `false`
531532

532-
```toml
533+
```toml title="pyproject.toml"
533534
[tool.commitizen]
534535
update_changelog_on_bump = true
535536
```
@@ -540,7 +541,7 @@ update_changelog_on_bump = true
540541

541542
When set to `true`, Commitizen will create annotated tags.
542543

543-
```toml
544+
```toml title="pyproject.toml"
544545
[tool.commitizen]
545546
annotated_tag = true
546547
```
@@ -551,7 +552,7 @@ annotated_tag = true
551552

552553
When set to `true`, Commitizen will create gpg signed tags.
553554

554-
```toml
555+
```toml title="pyproject.toml"
555556
[tool.commitizen]
556557
gpg_sign = true
557558
```
@@ -565,7 +566,7 @@ Useful during the initial development stage of your project.
565566

566567
Defaults to: `false`
567568

568-
```toml
569+
```toml title="pyproject.toml"
569570
[tool.commitizen]
570571
major_version_zero = true
571572
```
@@ -591,7 +592,7 @@ execution of the script, some environment variables are available:
591592
| `CZ_PRE_INCREMENT` | Whether this is a `MAJOR`, `MINOR` or `PATH` release |
592593
| `CZ_PRE_CHANGELOG_FILE_NAME` | Path to the changelog file, if available |
593594

594-
```toml
595+
```toml title="pyproject.toml"
595596
[tool.commitizen]
596597
pre_bump_hooks = [
597598
"scripts/generate_documentation.sh"
@@ -618,7 +619,7 @@ release. During execution of the script, some environment variables are availabl
618619
| `CZ_POST_INCREMENT` | Whether this was a `MAJOR`, `MINOR` or `PATH` release |
619620
| `CZ_POST_CHANGELOG_FILE_NAME` | Path to the changelog file, if available |
620621

621-
```toml
622+
```toml title="pyproject.toml"
622623
[tool.commitizen]
623624
post_bump_hooks = [
624625
"scripts/slack_notification.sh"
@@ -631,7 +632,7 @@ Offset with which to start counting prereleases.
631632

632633
Defaults to: `0`
633634

634-
```toml
635+
```toml title="pyproject.toml"
635636
[tool.commitizen]
636637
prerelease_offset = 1
637638
```
@@ -651,7 +652,7 @@ Options: `pep440`, `semver`, `semver2`
651652

652653
Defaults to: `pep440`
653654

654-
```toml
655+
```toml title="pyproject.toml"
655656
[tool.commitizen]
656657
version_scheme = "semver"
657658
```

docs/config.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ Type: `list`
2424

2525
Default: `[ ]`
2626

27-
Files were the version will be updated. A pattern to match a line, can also be specified, separated by `:` [Read more][version_files]
27+
Files (or glob patterns) where the version will be updated. A pattern to match a line, can also be specified, separated by `:` [Read more][version_files]
2828

2929
### `version_provider`
3030

0 commit comments

Comments
 (0)