Skip to content

refactor(init): remote extra words #1568

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 12 commits into from
Aug 6, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 11 additions & 12 deletions .github/workflows/docspublish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ on:
push:
branches:
- master
workflow_dispatch:

jobs:
update-cli-screenshots:
Expand Down Expand Up @@ -58,21 +59,19 @@ jobs:
python -m pip install -U pip poetry poethepoet
poetry --version
poetry install --no-root --only documentation
- name: Build docs
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
poetry doc:build
- name: Generate Sponsors 💖
uses: JamesIves/github-sponsors-readme-action@v1
with:
token: ${{ secrets.PERSONAL_ACCESS_TOKEN_FOR_ORG }}
file: "docs/README.md"
- name: Push doc to Github Page
uses: peaceiris/actions-gh-pages@v4
organization: true
- name: Build docs
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
poetry doc:build
- name: Deploy 🚀
uses: JamesIves/github-pages-deploy-action@v4
with:
personal_token: ${{ secrets.PERSONAL_ACCESS_TOKEN }}
publish_branch: gh-pages
publish_dir: ./site
user_name: "github-actions[bot]"
user_email: "github-actions[bot]@users.noreply.github.com"
folder: ./site # The folder the action should deploy.
branch: gh-pages
2 changes: 1 addition & 1 deletion .github/workflows/homebrewpublish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ jobs:
run: |
echo "project_version=$(cz version --project)" >> $GITHUB_ENV
- name: Update Homebrew formula
uses: dawidd6/action-homebrew-bump-formula@v4
uses: dawidd6/action-homebrew-bump-formula@v5
with:
token: ${{secrets.PERSONAL_ACCESS_TOKEN}}
formula: commitizen
Expand Down
2 changes: 1 addition & 1 deletion commitizen/commands/init.py
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ def _ask_version_provider(self) -> str:
"npm": "npm: Get and set version from package.json:project.version field",
"pep621": "pep621: Get and set version from pyproject.toml:project.version field",
"poetry": "poetry: Get and set version from pyproject.toml:tool.poetry.version field",
"uv": "uv: Get and Get and set version from pyproject.toml and uv.lock",
"uv": "uv: Get and set version from pyproject.toml and uv.lock",
"scm": "scm: Fetch the version from git and does not need to set it back",
}

Expand Down
8 changes: 5 additions & 3 deletions commitizen/defaults.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,6 @@

from commitizen.question import CzQuestion

# Type
Questions = Iterable[MutableMapping[str, Any]] # TODO: deprecate this?


class CzSettings(TypedDict, total=False):
bump_pattern: str
Expand Down Expand Up @@ -161,6 +158,10 @@ def get_tag_regexes(
}


# Type
Questions = Iterable[MutableMapping[str, Any]] # TODO: remove this in v5


def __getattr__(name: str) -> Any:
# PEP-562: deprecate module-level variable

Expand All @@ -176,6 +177,7 @@ def __getattr__(name: str) -> Any:
"change_type_order": (CHANGE_TYPE_ORDER, "CHANGE_TYPE_ORDER"),
"encoding": (ENCODING, "ENCODING"),
"name": (DEFAULT_SETTINGS["name"], "DEFAULT_SETTINGS['name']"),
"Questions": (Questions, "Iterable[CzQuestion]"),
}
if name in deprecated_vars:
value, replacement = deprecated_vars[name]
Expand Down
3 changes: 2 additions & 1 deletion docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ Before installing Commitizen, ensure you have:
#### Global Installation (Recommended)

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:

**Using pipx:**
```bash
# Install Commitizen
Expand Down Expand Up @@ -111,7 +112,7 @@ poetry add commitizen --dev

**Using uv:**
```bash
uv add commitizen
uv add --dev commitizen
```

**Using pdm:**
Expand Down
47 changes: 24 additions & 23 deletions docs/commands/bump.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ cz bump --version-scheme semver
```

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

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

For example, if we have `pyproject.toml`

```toml
```toml title="pyproject.toml"
[tool.commitizen]
version = "1.21.0"
version_files = [
Expand All @@ -162,15 +162,16 @@ version_files = [
]
```

`src/__version__.py`,
`src/__version__.py`

```python

```python title="src/__version__.py"
__version__ = "1.21.0"
```

and `setup.py`.
and `setup.py`

```python
```python title="setup.py"
from setuptools import setup

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

For example, if we have `pyproject.toml`

```toml
```toml title="pyproject.toml"
[tool.commitizen]
version = "5.3.5+0.1.0"
```
Expand Down Expand Up @@ -454,7 +455,7 @@ In your `pyproject.toml` or `.cz.toml`
tag_format = "v$major.$minor.$patch$prerelease"
```

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

Supported variables:

Expand All @@ -471,7 +472,7 @@ Supported variables:

### `version_files` \*

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

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

`pyproject.toml`, `.cz.toml` or `cz.toml`

```toml
```toml title="pyproject.toml"
[tool.commitizen]
version_files = [
"src/__version__.py",
"setup.py:version"
"packages/*/pyproject.toml:version",
"setup.py:version",
]
```

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

!!! note
Files can be specified using relative (to the execution) paths, absolute paths
or glob patterns.
Files can be specified using relative (to the execution) paths, absolute paths, or glob patterns.

---

Expand All @@ -516,7 +517,7 @@ Some examples

`pyproject.toml`, `.cz.toml` or `cz.toml`

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

Defaults to: `false`

```toml
```toml title="pyproject.toml"
[tool.commitizen]
update_changelog_on_bump = true
```
Expand All @@ -540,7 +541,7 @@ update_changelog_on_bump = true

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

```toml
```toml title="pyproject.toml"
[tool.commitizen]
annotated_tag = true
```
Expand All @@ -551,7 +552,7 @@ annotated_tag = true

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

```toml
```toml title="pyproject.toml"
[tool.commitizen]
gpg_sign = true
```
Expand All @@ -565,7 +566,7 @@ Useful during the initial development stage of your project.

Defaults to: `false`

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

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

```toml
```toml title="pyproject.toml"
[tool.commitizen]
post_bump_hooks = [
"scripts/slack_notification.sh"
Expand All @@ -631,7 +632,7 @@ Offset with which to start counting prereleases.

Defaults to: `0`

```toml
```toml title="pyproject.toml"
[tool.commitizen]
prerelease_offset = 1
```
Expand All @@ -651,7 +652,7 @@ Options: `pep440`, `semver`, `semver2`

Defaults to: `pep440`

```toml
```toml title="pyproject.toml"
[tool.commitizen]
version_scheme = "semver"
```
Expand Down
2 changes: 1 addition & 1 deletion docs/config.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ Type: `list`

Default: `[ ]`

Files were the version will be updated. A pattern to match a line, can also be specified, separated by `:` [Read more][version_files]
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]

### `version_provider`

Expand Down
Loading
Loading