diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml
index 2b4a030fc6..6e56cb341f 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.13.2 # automatically updated by Commitizen
+ rev: v4.13.4 # automatically updated by Commitizen
hooks:
- id: commitizen
- id: commitizen-branch
diff --git a/.pre-commit-hooks.yaml b/.pre-commit-hooks.yaml
index c142634581..d57006f153 100644
--- a/.pre-commit-hooks.yaml
+++ b/.pre-commit-hooks.yaml
@@ -19,9 +19,10 @@
the fact (e.g., pre-push or in CI) without an expensive check of the entire
repository history.
entry: cz check
- args: [--rev-range, origin/HEAD..HEAD]
+ args: [--rev-range, "$PRE_COMMIT_FROM_REF..$PRE_COMMIT_TO_REF"]
always_run: true
pass_filenames: false
language: python
language_version: python3
minimum_pre_commit_version: "3.2.0"
+ stages: [pre-push]
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 2ba2ed463c..1d70b41f39 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,3 +1,15 @@
+## v4.13.4 (2026-02-04)
+
+### Fix
+
+- **pre-commit-hooks**: correct rev-range syntax in commitizen-branch (#1841)
+
+## v4.13.3 (2026-02-04)
+
+### Refactor
+
+- **version_schemes**: shorten generate_prerelease (#1838)
+
## v4.13.2 (2026-02-03)
### Refactor
diff --git a/commitizen/__version__.py b/commitizen/__version__.py
index 13398e442b..8718ed6825 100644
--- a/commitizen/__version__.py
+++ b/commitizen/__version__.py
@@ -1 +1 @@
-__version__ = "4.13.2"
+__version__ = "4.13.4"
diff --git a/commitizen/commands/init.py b/commitizen/commands/init.py
index b0df9381dc..d0f4b686ac 100644
--- a/commitizen/commands/init.py
+++ b/commitizen/commands/init.py
@@ -171,24 +171,31 @@ def _ask_config_path(self) -> Path:
def _ask_name(self) -> str:
name: str = questionary.select(
f"Please choose a cz (commit rule): (default: {DEFAULT_SETTINGS['name']})",
- choices=self._construct_name_choice_with_description(),
+ choices=self._construct_name_choices_from_registry(),
default=DEFAULT_SETTINGS["name"],
style=self.cz.style,
).unsafe_ask()
return name
- def _construct_name_choice_with_description(self) -> list[questionary.Choice]:
+ def _construct_name_choices_from_registry(self) -> list[questionary.Choice]:
+ """
+ Construct questionary choices of cz names from registry.
+ """
choices = []
for cz_name, cz_class in registry.items():
try:
cz_obj = cz_class(self.config)
except MissingCzCustomizeConfigError:
+ # Fallback if description is not available
choices.append(questionary.Choice(title=cz_name, value=cz_name))
continue
- first_example = cz_obj.schema().partition("\n")[0]
+
+ # Get the first line of the schema as the description
+ # TODO(bearomorphism): schema is a workaround. Add a description method to the cz class.
+ description = cz_obj.schema().partition("\n")[0]
choices.append(
questionary.Choice(
- title=cz_name, value=cz_name, description=first_example
+ title=cz_name, value=cz_name, description=description
)
)
return choices
diff --git a/docs/images/cli_help/cz___help.svg b/docs/images/cli_help/cz___help.svg
index 64b79fc0bb..5c8f8fef39 100644
--- a/docs/images/cli_help/cz___help.svg
+++ b/docs/images/cli_help/cz___help.svg
@@ -19,136 +19,136 @@
font-weight: 700;
}
- .terminal-199999382-matrix {
+ .terminal-1104329960-matrix {
font-family: Fira Code, monospace;
font-size: 20px;
line-height: 24.4px;
font-variant-east-asian: full-width;
}
- .terminal-199999382-title {
+ .terminal-1104329960-title {
font-size: 18px;
font-weight: bold;
font-family: arial;
}
- .terminal-199999382-r1 { fill: #c5c8c6 }
-.terminal-199999382-r2 { fill: #c5c8c6;font-weight: bold }
-.terminal-199999382-r3 { fill: #d0b344 }
-.terminal-199999382-r4 { fill: #1984e9;text-decoration: underline; }
-.terminal-199999382-r5 { fill: #68a0b3;font-weight: bold }
+ .terminal-1104329960-r1 { fill: #c5c8c6 }
+.terminal-1104329960-r2 { fill: #c5c8c6;font-weight: bold }
+.terminal-1104329960-r3 { fill: #d0b344 }
+.terminal-1104329960-r4 { fill: #1984e9;text-decoration: underline; }
+.terminal-1104329960-r5 { fill: #68a0b3;font-weight: bold }
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
@@ -160,46 +160,46 @@
-
+
-
- $ cz --help
-usage: cz [-h][--config CONFIG][--debug][-n NAME][-nr NO_RAISE]
-{init,commit,c,ls,example,info,schema,bump,changelog,ch,check,version}
-...
-
-Commitizen is a powerful release management tool that helps teams maintain
-consistent and meaningful commit messages while automating version management.
-For more information, please visit https://commitizen-tools.github.io/commitizen
-
-options:
- -h, --help show this help message and exit
- --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
-https://commitizen-
- tools.github.io/commitizen/exit_codes/
-
-commands:
-{init,commit,c,ls,example,info,schema,bump,changelog,ch,check,version}
- 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).
-
+
+ $ cz --help
+usage: cz [-h][--config CONFIG][--debug][-n NAME][-nr NO_RAISE]
+{init,commit,c,ls,example,info,schema,bump,changelog,ch,check,version}
+...
+
+Commitizen is a powerful release management tool that helps teams maintain
+consistent and meaningful commit messages while automating version management.
+For more information, please visit https://commitizen-tools.github.io/commitizen
+
+options:
+ -h, --help show this help message and exit
+ --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
+https://commitizen-
+ tools.github.io/commitizen/exit_codes/
+
+commands:
+{init,commit,c,ls,example,info,schema,bump,changelog,ch,check,version}
+ 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/docs/images/cli_help/cz_bump___help.svg b/docs/images/cli_help/cz_bump___help.svg
index ec6b4816f1..42f618ea9c 100644
--- a/docs/images/cli_help/cz_bump___help.svg
+++ b/docs/images/cli_help/cz_bump___help.svg
@@ -19,292 +19,292 @@
font-weight: 700;
}
- .terminal-993994783-matrix {
+ .terminal-4007273841-matrix {
font-family: Fira Code, monospace;
font-size: 20px;
line-height: 24.4px;
font-variant-east-asian: full-width;
}
- .terminal-993994783-title {
+ .terminal-4007273841-title {
font-size: 18px;
font-weight: bold;
font-family: arial;
}
- .terminal-993994783-r1 { fill: #c5c8c6 }
-.terminal-993994783-r2 { fill: #c5c8c6;font-weight: bold }
-.terminal-993994783-r3 { fill: #68a0b3;font-weight: bold }
-.terminal-993994783-r4 { fill: #98729f;font-weight: bold }
-.terminal-993994783-r5 { fill: #98a84b }
+ .terminal-4007273841-r1 { fill: #c5c8c6 }
+.terminal-4007273841-r2 { fill: #c5c8c6;font-weight: bold }
+.terminal-4007273841-r3 { fill: #68a0b3;font-weight: bold }
+.terminal-4007273841-r4 { fill: #98729f;font-weight: bold }
+.terminal-4007273841-r5 { fill: #98a84b }
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
@@ -316,98 +316,98 @@
-
+
-
- $ cz bump --help
-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]
-[--changelog-to-stdout][--git-output-to-stderr][--retry]
-[--major-version-zero][--template TEMPLATE][--extra EXTRA]
-[--file-name FILE_NAME][--prerelease-offset PRERELEASE_OFFSET]
-[--version-scheme {pep440,semver,semver2}]
-[--version-type {pep440,semver,semver2}]
-[--build-metadata BUILD_METADATA][--get-next]
-[--allow-no-commit]
-[MANUAL_VERSION]
-
-Bump semantic version based on the git log
-
-positional arguments:
- MANUAL_VERSION Bump to the given version (e.g., 1.5.3).
-
-options:
- -h, --help show this help message and exit
- --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(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.
- --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, and wrap around simple quotes.
- --bump-message BUMP_MESSAGE
- Template used to create the release commit, useful
- when working with CI.
- --prerelease {alpha,beta,rc}, -pr {alpha,beta,rc}
- Type of prerelease.
- --devrelease DEVRELEASE, -d DEVRELEASE
- Specify non-negative integer for dev release.
- --increment {MAJOR,MINOR,PATCH}
- Specify the desired increment.
- --increment-mode {linear,exact}
- 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, ensuring the increment
- and pre-release are always honored.
- --check-consistency, -cc
- 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.
- --changelog-to-stdout
- Output changelog to stdout.
- --git-output-to-stderr
- 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).
- --extra EXTRA, -e EXTRA
- Changelog extra variables (in the form 'key=value').
- --file-name FILE_NAME
- File name of changelog (default: 'CHANGELOG.md').
- --prerelease-offset PRERELEASE_OFFSET
- Start pre-releases with this offset.
- --version-scheme {pep440,semver,semver2}
- Choose version scheme.
- --version-type {pep440,semver,semver2}
- 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.
-
+
+ $ cz bump --help
+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]
+[--changelog-to-stdout][--git-output-to-stderr][--retry]
+[--major-version-zero][--template TEMPLATE][--extra EXTRA]
+[--file-name FILE_NAME][--prerelease-offset PRERELEASE_OFFSET]
+[--version-scheme {pep440,semver,semver2}]
+[--version-type {pep440,semver,semver2}]
+[--build-metadata BUILD_METADATA][--get-next]
+[--allow-no-commit]
+[MANUAL_VERSION]
+
+Bump semantic version based on the git log
+
+positional arguments:
+ MANUAL_VERSION Bump to the given version (e.g., 1.5.3).
+
+options:
+ -h, --help show this help message and exit
+ --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(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.
+ --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, and wrap around simple quotes.
+ --bump-message BUMP_MESSAGE
+ Template used to create the release commit, useful
+ when working with CI.
+ --prerelease {alpha,beta,rc}, -pr {alpha,beta,rc}
+ Type of prerelease.
+ --devrelease DEVRELEASE, -d DEVRELEASE
+ Specify non-negative integer for dev release.
+ --increment {MAJOR,MINOR,PATCH}
+ Specify the desired increment.
+ --increment-mode {linear,exact}
+ 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, ensuring the increment
+ and pre-release are always honored.
+ --check-consistency, -cc
+ 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.
+ --changelog-to-stdout
+ Output changelog to stdout.
+ --git-output-to-stderr
+ 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).
+ --extra EXTRA, -e EXTRA
+ Changelog extra variables (in the form 'key=value').
+ --file-name FILE_NAME
+ File name of changelog (default: 'CHANGELOG.md').
+ --prerelease-offset PRERELEASE_OFFSET
+ Start pre-releases with this offset.
+ --version-scheme {pep440,semver,semver2}
+ Choose version scheme.
+ --version-type {pep440,semver,semver2}
+ 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.
+
diff --git a/docs/images/cli_help/cz_changelog___help.svg b/docs/images/cli_help/cz_changelog___help.svg
index b0d048caed..00031d48f6 100644
--- a/docs/images/cli_help/cz_changelog___help.svg
+++ b/docs/images/cli_help/cz_changelog___help.svg
@@ -19,156 +19,156 @@
font-weight: 700;
}
- .terminal-922159541-matrix {
+ .terminal-771491591-matrix {
font-family: Fira Code, monospace;
font-size: 20px;
line-height: 24.4px;
font-variant-east-asian: full-width;
}
- .terminal-922159541-title {
+ .terminal-771491591-title {
font-size: 18px;
font-weight: bold;
font-family: arial;
}
- .terminal-922159541-r1 { fill: #c5c8c6 }
-.terminal-922159541-r2 { fill: #c5c8c6;font-weight: bold }
-.terminal-922159541-r3 { fill: #68a0b3;font-weight: bold }
-.terminal-922159541-r4 { fill: #98a84b }
+ .terminal-771491591-r1 { fill: #c5c8c6 }
+.terminal-771491591-r2 { fill: #c5c8c6;font-weight: bold }
+.terminal-771491591-r3 { fill: #68a0b3;font-weight: bold }
+.terminal-771491591-r4 { fill: #98a84b }
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
@@ -180,53 +180,53 @@
-
+
-
- $ cz changelog --help
-usage: cz changelog [-h][--dry-run][--file-name FILE_NAME]
-[--unreleased-version UNRELEASED_VERSION][--incremental]
-[--start-rev START_REV][--merge-prerelease]
-[--version-scheme {pep440,semver,semver2}]
-[--export-template EXPORT_TEMPLATE][--template TEMPLATE]
-[--extra EXTRA][--tag-format TAG_FORMAT]
-
-
-Generate changelog (note that it will overwrite existing files)
-
-positional arguments:
- 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.
- --file-name FILE_NAME
- 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 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 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.
- --export-template EXPORT_TEMPLATE
- Export the changelog template into this file instead
- of rendering it.
- --template TEMPLATE, -t TEMPLATE
- Changelog template file name (relative to the current
- working directory).
- --extra EXTRA, -e EXTRA
- Changelog extra variables (in the form 'key=value').
- --tag-format TAG_FORMAT
- The format of the tag, wrap around simple quotes.
-
+
+ $ cz changelog --help
+usage: cz changelog [-h][--dry-run][--file-name FILE_NAME]
+[--unreleased-version UNRELEASED_VERSION][--incremental]
+[--start-rev START_REV][--merge-prerelease]
+[--version-scheme {pep440,semver,semver2}]
+[--export-template EXPORT_TEMPLATE][--template TEMPLATE]
+[--extra EXTRA][--tag-format TAG_FORMAT]
+
+
+Generate changelog (note that it will overwrite existing files)
+
+positional arguments:
+ 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.
+ --file-name FILE_NAME
+ 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 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 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.
+ --export-template EXPORT_TEMPLATE
+ Export the changelog template into this file instead
+ of rendering it.
+ --template TEMPLATE, -t TEMPLATE
+ Changelog template file name (relative to the current
+ working directory).
+ --extra EXTRA, -e EXTRA
+ Changelog extra variables (in the form 'key=value').
+ --tag-format TAG_FORMAT
+ The format of the tag, wrap around simple quotes.
+
diff --git a/docs/images/cli_help/cz_check___help.svg b/docs/images/cli_help/cz_check___help.svg
index 1091491d36..57dd5ee1a4 100644
--- a/docs/images/cli_help/cz_check___help.svg
+++ b/docs/images/cli_help/cz_check___help.svg
@@ -19,120 +19,120 @@
font-weight: 700;
}
- .terminal-1597319345-matrix {
+ .terminal-3704235523-matrix {
font-family: Fira Code, monospace;
font-size: 20px;
line-height: 24.4px;
font-variant-east-asian: full-width;
}
- .terminal-1597319345-title {
+ .terminal-3704235523-title {
font-size: 18px;
font-weight: bold;
font-family: arial;
}
- .terminal-1597319345-r1 { fill: #c5c8c6 }
-.terminal-1597319345-r2 { fill: #c5c8c6;font-weight: bold }
-.terminal-1597319345-r3 { fill: #d0b344 }
-.terminal-1597319345-r4 { fill: #68a0b3;font-weight: bold }
+ .terminal-3704235523-r1 { fill: #c5c8c6 }
+.terminal-3704235523-r2 { fill: #c5c8c6;font-weight: bold }
+.terminal-3704235523-r3 { fill: #d0b344 }
+.terminal-3704235523-r4 { fill: #68a0b3;font-weight: bold }
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
@@ -144,41 +144,41 @@
-
+
-
- $ cz check --help
-usage: cz check [-h]
-[--commit-msg-file COMMIT_MSG_FILE | --rev-range REV_RANGE | -d
-| -m MESSAGE]
-[--allow-abort][--allowed-prefixes [ALLOWED_PREFIXES ...]]
-[-l MESSAGE_LENGTH_LIMIT]
-
-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 temporary file that contains
- the commit message. Use it in a git hook script:
-MSG_FILE=$1.
- --rev-range REV_RANGE
- Validate the commits in the given range of git rev,
- e.g., master..HEAD.
- -d, --use-default-range
- Validate the commits from the default branch to HEAD,
- e.g., refs/remotes/origin/master..HEAD.
- -m MESSAGE, --message MESSAGE
- Validate the given commit message.
- --allow-abort Allow empty commit messages, which typically abort a
- commit.
- --allowed-prefixes [ALLOWED_PREFIXES ...]
- Skip validation for commit messages that start with
- the specified prefixes.
- -l MESSAGE_LENGTH_LIMIT, --message-length-limit MESSAGE_LENGTH_LIMIT
- Restrict the length of the **first line** of the
- commit message; 0 for no limit.
-
+
+ $ cz check --help
+usage: cz check [-h]
+[--commit-msg-file COMMIT_MSG_FILE | --rev-range REV_RANGE | -d
+| -m MESSAGE]
+[--allow-abort][--allowed-prefixes [ALLOWED_PREFIXES ...]]
+[-l MESSAGE_LENGTH_LIMIT]
+
+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 temporary file that contains
+ the commit message. Use it in a git hook script:
+MSG_FILE=$1.
+ --rev-range REV_RANGE
+ Validate the commits in the given range of git rev,
+ e.g., master..HEAD.
+ -d, --use-default-range
+ Validate the commits from the default branch to HEAD,
+ e.g., refs/remotes/origin/master..HEAD.
+ -m MESSAGE, --message MESSAGE
+ Validate the given commit message.
+ --allow-abort Allow empty commit messages, which typically abort a
+ commit.
+ --allowed-prefixes [ALLOWED_PREFIXES ...]
+ Skip validation for commit messages that start with
+ the specified prefixes.
+ -l MESSAGE_LENGTH_LIMIT, --message-length-limit MESSAGE_LENGTH_LIMIT
+ Restrict the length of the **first line** of the
+ commit message; 0 for no limit.
+
diff --git a/docs/images/cli_help/cz_commit___help.svg b/docs/images/cli_help/cz_commit___help.svg
index 1905186bb5..633cea8fd0 100644
--- a/docs/images/cli_help/cz_commit___help.svg
+++ b/docs/images/cli_help/cz_commit___help.svg
@@ -19,104 +19,104 @@
font-weight: 700;
}
- .terminal-1022884229-matrix {
+ .terminal-2417358551-matrix {
font-family: Fira Code, monospace;
font-size: 20px;
line-height: 24.4px;
font-variant-east-asian: full-width;
}
- .terminal-1022884229-title {
+ .terminal-2417358551-title {
font-size: 18px;
font-weight: bold;
font-family: arial;
}
- .terminal-1022884229-r1 { fill: #c5c8c6 }
-.terminal-1022884229-r2 { fill: #c5c8c6;font-weight: bold }
-.terminal-1022884229-r3 { fill: #68a0b3;font-weight: bold }
+ .terminal-2417358551-r1 { fill: #c5c8c6 }
+.terminal-2417358551-r2 { fill: #c5c8c6;font-weight: bold }
+.terminal-2417358551-r3 { fill: #68a0b3;font-weight: bold }
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
@@ -128,36 +128,36 @@
-
+
-
- $ cz commit --help
-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
-
-options:
- -h, --help show this help message and exit
- --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_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
- Set the length limit of the commit message; 0 for no
- limit.
- -- Positional arguments separator (recommended).
-
+
+ $ cz commit --help
+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
+
+options:
+ -h, --help show this help message and exit
+ --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_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
+ Set the length limit of the commit message; 0 for no
+ limit.
+ -- Positional arguments separator (recommended).
+
diff --git a/docs/images/cli_help/cz_example___help.svg b/docs/images/cli_help/cz_example___help.svg
index 6bf85336b8..5ac29a22e3 100644
--- a/docs/images/cli_help/cz_example___help.svg
+++ b/docs/images/cli_help/cz_example___help.svg
@@ -19,46 +19,46 @@
font-weight: 700;
}
- .terminal-1249345926-matrix {
+ .terminal-703430360-matrix {
font-family: Fira Code, monospace;
font-size: 20px;
line-height: 24.4px;
font-variant-east-asian: full-width;
}
- .terminal-1249345926-title {
+ .terminal-703430360-title {
font-size: 18px;
font-weight: bold;
font-family: arial;
}
- .terminal-1249345926-r1 { fill: #c5c8c6 }
-.terminal-1249345926-r2 { fill: #c5c8c6;font-weight: bold }
+ .terminal-703430360-r1 { fill: #c5c8c6 }
+.terminal-703430360-r2 { fill: #c5c8c6;font-weight: bold }
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
@@ -70,17 +70,17 @@
-
+
-
- $ cz example --help
-usage: cz example [-h]
-
-Show commit example
-
-options:
- -h, --help show this help message and exit
-
+
+ $ cz example --help
+usage: cz example [-h]
+
+Show commit example
+
+options:
+ -h, --help show this help message and exit
+
diff --git a/docs/images/cli_help/cz_info___help.svg b/docs/images/cli_help/cz_info___help.svg
index 5ab81ec051..63ce1ee394 100644
--- a/docs/images/cli_help/cz_info___help.svg
+++ b/docs/images/cli_help/cz_info___help.svg
@@ -19,46 +19,46 @@
font-weight: 700;
}
- .terminal-3780805296-matrix {
+ .terminal-3108929538-matrix {
font-family: Fira Code, monospace;
font-size: 20px;
line-height: 24.4px;
font-variant-east-asian: full-width;
}
- .terminal-3780805296-title {
+ .terminal-3108929538-title {
font-size: 18px;
font-weight: bold;
font-family: arial;
}
- .terminal-3780805296-r1 { fill: #c5c8c6 }
-.terminal-3780805296-r2 { fill: #c5c8c6;font-weight: bold }
+ .terminal-3108929538-r1 { fill: #c5c8c6 }
+.terminal-3108929538-r2 { fill: #c5c8c6;font-weight: bold }
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
@@ -70,17 +70,17 @@
-
+
-
- $ cz info --help
-usage: cz info [-h]
-
-Show information about the cz
-
-options:
- -h, --help show this help message and exit
-
+
+ $ cz info --help
+usage: cz info [-h]
+
+Show information about the cz
+
+options:
+ -h, --help show this help message and exit
+
diff --git a/docs/images/cli_help/cz_init___help.svg b/docs/images/cli_help/cz_init___help.svg
index 709b779189..daf7d90cd7 100644
--- a/docs/images/cli_help/cz_init___help.svg
+++ b/docs/images/cli_help/cz_init___help.svg
@@ -19,46 +19,46 @@
font-weight: 700;
}
- .terminal-3508504009-matrix {
+ .terminal-2562163483-matrix {
font-family: Fira Code, monospace;
font-size: 20px;
line-height: 24.4px;
font-variant-east-asian: full-width;
}
- .terminal-3508504009-title {
+ .terminal-2562163483-title {
font-size: 18px;
font-weight: bold;
font-family: arial;
}
- .terminal-3508504009-r1 { fill: #c5c8c6 }
-.terminal-3508504009-r2 { fill: #c5c8c6;font-weight: bold }
+ .terminal-2562163483-r1 { fill: #c5c8c6 }
+.terminal-2562163483-r2 { fill: #c5c8c6;font-weight: bold }
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
@@ -70,17 +70,17 @@
-
+
-
- $ cz init --help
-usage: cz init [-h]
-
-Initialize commitizen configuration
-
-options:
- -h, --help show this help message and exit
-
+
+ $ cz init --help
+usage: cz init [-h]
+
+Initialize commitizen configuration
+
+options:
+ -h, --help show this help message and exit
+
diff --git a/docs/images/cli_help/cz_ls___help.svg b/docs/images/cli_help/cz_ls___help.svg
index fc6e0bc7e7..27bd6b760a 100644
--- a/docs/images/cli_help/cz_ls___help.svg
+++ b/docs/images/cli_help/cz_ls___help.svg
@@ -19,46 +19,46 @@
font-weight: 700;
}
- .terminal-4097343530-matrix {
+ .terminal-3771170172-matrix {
font-family: Fira Code, monospace;
font-size: 20px;
line-height: 24.4px;
font-variant-east-asian: full-width;
}
- .terminal-4097343530-title {
+ .terminal-3771170172-title {
font-size: 18px;
font-weight: bold;
font-family: arial;
}
- .terminal-4097343530-r1 { fill: #c5c8c6 }
-.terminal-4097343530-r2 { fill: #c5c8c6;font-weight: bold }
+ .terminal-3771170172-r1 { fill: #c5c8c6 }
+.terminal-3771170172-r2 { fill: #c5c8c6;font-weight: bold }
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
@@ -70,17 +70,17 @@
-
+
-
- $ cz ls --help
-usage: cz ls [-h]
-
-Show available Commitizens
-
-options:
- -h, --help show this help message and exit
-
+
+ $ cz ls --help
+usage: cz ls [-h]
+
+Show available Commitizens
+
+options:
+ -h, --help show this help message and exit
+
diff --git a/docs/images/cli_help/cz_schema___help.svg b/docs/images/cli_help/cz_schema___help.svg
index 110569a022..3a0098b2db 100644
--- a/docs/images/cli_help/cz_schema___help.svg
+++ b/docs/images/cli_help/cz_schema___help.svg
@@ -19,46 +19,46 @@
font-weight: 700;
}
- .terminal-1104904213-matrix {
+ .terminal-721452391-matrix {
font-family: Fira Code, monospace;
font-size: 20px;
line-height: 24.4px;
font-variant-east-asian: full-width;
}
- .terminal-1104904213-title {
+ .terminal-721452391-title {
font-size: 18px;
font-weight: bold;
font-family: arial;
}
- .terminal-1104904213-r1 { fill: #c5c8c6 }
-.terminal-1104904213-r2 { fill: #c5c8c6;font-weight: bold }
+ .terminal-721452391-r1 { fill: #c5c8c6 }
+.terminal-721452391-r2 { fill: #c5c8c6;font-weight: bold }
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
@@ -70,17 +70,17 @@
-
+
-
- $ cz schema --help
-usage: cz schema [-h]
-
-Show commit schema
-
-options:
- -h, --help show this help message and exit
-
+
+ $ cz schema --help
+usage: cz schema [-h]
+
+Show commit schema
+
+options:
+ -h, --help show this help message and exit
+
diff --git a/docs/images/cli_help/cz_version___help.svg b/docs/images/cli_help/cz_version___help.svg
index 0c45576bc5..20331e0972 100644
--- a/docs/images/cli_help/cz_version___help.svg
+++ b/docs/images/cli_help/cz_version___help.svg
@@ -19,82 +19,82 @@
font-weight: 700;
}
- .terminal-3401796841-matrix {
+ .terminal-1926777403-matrix {
font-family: Fira Code, monospace;
font-size: 20px;
line-height: 24.4px;
font-variant-east-asian: full-width;
}
- .terminal-3401796841-title {
+ .terminal-1926777403-title {
font-size: 18px;
font-weight: bold;
font-family: arial;
}
- .terminal-3401796841-r1 { fill: #c5c8c6 }
-.terminal-3401796841-r2 { fill: #c5c8c6;font-weight: bold }
+ .terminal-1926777403-r1 { fill: #c5c8c6 }
+.terminal-1926777403-r2 { fill: #c5c8c6;font-weight: bold }
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
@@ -106,29 +106,29 @@
-
+
-
- $ cz version --help
-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)
-
-options:
- -h, --help show this help message and exit
- -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 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.
-
+
+ $ cz version --help
+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)
+
+options:
+ -h, --help show this help message and exit
+ -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 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/pyproject.toml b/pyproject.toml
index fd8c1dfc21..ad97177945 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -1,6 +1,6 @@
[project]
name = "commitizen"
-version = "4.13.2"
+version = "4.13.4"
description = "Python commitizen client tool"
authors = [{ name = "Santiago Fraire", email = "santiwilly@gmail.com" }]
maintainers = [
diff --git a/scripts/gen_cli_help_screenshots.py b/scripts/gen_cli_help_screenshots.py
index 0706612391..35dee8a972 100644
--- a/scripts/gen_cli_help_screenshots.py
+++ b/scripts/gen_cli_help_screenshots.py
@@ -1,42 +1,44 @@
import os
import subprocess
+from itertools import chain
from pathlib import Path
from rich.console import Console
from commitizen.cli import data
-project_root = Path(__file__).parent.parent.absolute()
-images_root = project_root / Path("docs") / Path("images") / Path("cli_help")
-
def gen_cli_help_screenshots() -> None:
"""Generate the screenshot for help message on each cli command and save them as svg files."""
- if not os.path.exists(images_root):
- os.makedirs(images_root)
- print(f"Created {images_root}")
-
- help_cmds = _list_help_cmds()
- for cmd in help_cmds:
+ images_root = Path(__file__).parent.parent / "docs" / "images" / "cli_help"
+ images_root.mkdir(parents=True, exist_ok=True)
+
+ cz_commands = (
+ command["name"] if isinstance(command["name"], str) else command["name"][0]
+ for command in data["subcommands"]["commands"]
+ )
+ for cmd in chain(
+ ["cz --help"], (f"cz {cz_command} --help" for cz_command in cz_commands)
+ ):
file_name = f"{cmd.replace(' ', '_').replace('-', '_')}.svg"
- _export_cmd_as_svg(cmd, f"{images_root}/{file_name}")
-
+ _export_cmd_as_svg(cmd, images_root / file_name)
-def _list_help_cmds() -> list[str]:
- cmds = [f"{data['prog']} --help"] + [
- f"{data['prog']} {sub_c['name'] if isinstance(sub_c['name'], str) else sub_c['name'][0]} --help"
- for sub_c in data["subcommands"]["commands"]
- ]
- return cmds
+def _export_cmd_as_svg(cmd: str, file_path: Path) -> None:
+ console = Console(record=True, width=80, file=open(os.devnull, "w"))
+ print("Processing command:", cmd)
-def _export_cmd_as_svg(cmd: str, file_name: str) -> None:
+ console.print(f"$ {cmd}")
stdout = subprocess.run(cmd, shell=True, capture_output=True).stdout.decode("utf-8")
- console = Console(record=True, width=80)
- console.print(f"$ {cmd}\n{stdout}")
- console.save_svg(file_name, title="")
+ console.print(stdout)
+ console.save_svg(file_path.as_posix(), title="")
+
+ print("Saved to:", file_path.as_posix())
+
+# TODO: generate the screenshot of cz init interactive mode
+# TODO: generate the screenshot of cz commit interactive mode
if __name__ == "__main__":
gen_cli_help_screenshots()
diff --git a/tests/commands/conftest.py b/tests/commands/conftest.py
index c7d5904504..ad7e1bc766 100644
--- a/tests/commands/conftest.py
+++ b/tests/commands/conftest.py
@@ -1,21 +1,11 @@
-import os
from pathlib import Path
import pytest
from pytest_mock import MockerFixture, MockType
-from commitizen import defaults
-from commitizen.config import BaseConfig
from commitizen.config.json_config import JsonConfig
-@pytest.fixture
-def config() -> BaseConfig:
- _config = BaseConfig()
- _config.settings.update({"name": defaults.DEFAULT_SETTINGS["name"]})
- return _config
-
-
@pytest.fixture
def config_customize() -> JsonConfig:
json_string = r"""{
@@ -46,13 +36,13 @@ def config_customize() -> JsonConfig:
@pytest.fixture
-def changelog_path() -> str:
- return os.path.join(os.getcwd(), "CHANGELOG.md")
+def changelog_path() -> Path:
+ return Path("CHANGELOG.md")
@pytest.fixture
-def config_path() -> str:
- return os.path.join(os.getcwd(), "pyproject.toml")
+def config_path() -> Path:
+ return Path("pyproject.toml")
@pytest.fixture
diff --git a/tests/commands/test_bump_command.py b/tests/commands/test_bump_command.py
index d458e34d8e..6b8d903d68 100644
--- a/tests/commands/test_bump_command.py
+++ b/tests/commands/test_bump_command.py
@@ -422,10 +422,10 @@ def test_bump_files_only(tmp_commitizen_project, util: UtilFixture):
assert git.tag_exist("0.3.0") is False
- with open(tmp_version_file, encoding="utf-8") as f:
+ with tmp_version_file.open(encoding="utf-8") as f:
assert "0.3.0" in f.read()
- with open(tmp_commitizen_cfg_file, encoding="utf-8") as f:
+ with tmp_commitizen_cfg_file.open(encoding="utf-8") as f:
assert "0.3.0" in f.read()
@@ -444,7 +444,7 @@ def test_bump_local_version(tmp_commitizen_project, util: UtilFixture):
util.run_cli("bump", "--yes", "--local-version")
assert git.tag_exist("4.5.1+0.2.0") is True
- with open(tmp_version_file, encoding="utf-8") as f:
+ with tmp_version_file.open(encoding="utf-8") as f:
assert "4.5.1+0.2.0" in f.read()
@@ -504,7 +504,7 @@ def test_bump_with_changelog_arg(util: UtilFixture, changelog_path):
util.run_cli("bump", "--yes", "--changelog")
assert git.tag_exist("0.2.0") is True
- with open(changelog_path, encoding="utf-8") as f:
+ with changelog_path.open(encoding="utf-8") as f:
out = f.read()
assert out.startswith("#")
assert "0.2.0" in out
@@ -513,13 +513,13 @@ def test_bump_with_changelog_arg(util: UtilFixture, changelog_path):
@pytest.mark.usefixtures("tmp_commitizen_project")
def test_bump_with_changelog_config(util: UtilFixture, changelog_path, config_path):
util.create_file_and_commit("feat(user): new file")
- with open(config_path, "a", encoding="utf-8") as fp:
+ with config_path.open("a", encoding="utf-8") as fp:
fp.write("update_changelog_on_bump = true\n")
util.run_cli("bump", "--yes")
assert git.tag_exist("0.2.0") is True
- with open(changelog_path, encoding="utf-8") as f:
+ with changelog_path.open(encoding="utf-8") as f:
out = f.read()
assert out.startswith("#")
assert "0.2.0" in out
@@ -557,7 +557,7 @@ def test_bump_with_changelog_to_stdout_arg(
assert "this should appear in stdout" in out
assert git.tag_exist("0.2.0") is True
- with open(changelog_path, encoding="utf-8") as f:
+ with changelog_path.open(encoding="utf-8") as f:
out = f.read()
assert out.startswith("#")
assert "0.2.0" in out
@@ -794,14 +794,13 @@ def test_bump_version_with_less_components_in_config(
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
+ assert git.tag_exist(expected_version_after_bump) is True
for version_file in [
tmp_commitizen_project.join("__version__.py"),
tmp_commitizen_project.join("pyproject.toml"),
]:
- with open(version_file) as f:
+ with version_file.open() as f:
assert expected_version_after_bump in f.read()
@@ -914,7 +913,7 @@ def test_bump_command_prerelease_scheme_via_cli(
assert git.tag_exist("0.2.0-a0") is True
for version_file in [tmp_version_file, tmp_commitizen_cfg_file]:
- with open(version_file) as f:
+ with version_file.open() as f:
assert "0.2.0-a0" in f.read()
# PRERELEASE BUMP CREATES VERSION WITHOUT PRERELEASE
@@ -922,7 +921,7 @@ def test_bump_command_prerelease_scheme_via_cli(
assert git.tag_exist("0.2.0") is True
for version_file in [tmp_version_file, tmp_commitizen_cfg_file]:
- with open(version_file) as f:
+ with version_file.open() as f:
assert "0.2.0" in f.read()
@@ -939,14 +938,14 @@ def test_bump_command_prerelease_scheme_via_config(
assert git.tag_exist("0.2.0-a0") is True
for version_file in [tmp_version_file, tmp_commitizen_cfg_file]:
- with open(version_file) as f:
+ with version_file.open() as f:
assert "0.2.0-a0" in f.read()
util.run_cli("bump", "--prerelease", "alpha", "--yes")
assert git.tag_exist("0.2.0-a1") is True
for version_file in [tmp_version_file, tmp_commitizen_cfg_file]:
- with open(version_file) as f:
+ with version_file.open() as f:
assert "0.2.0-a1" in f.read()
# PRERELEASE BUMP CREATES VERSION WITHOUT PRERELEASE
@@ -954,7 +953,7 @@ def test_bump_command_prerelease_scheme_via_config(
assert git.tag_exist("0.2.0") is True
for version_file in [tmp_version_file, tmp_commitizen_cfg_file]:
- with open(version_file) as f:
+ with version_file.open() as f:
assert "0.2.0" in f.read()
@@ -971,14 +970,14 @@ def test_bump_command_prerelease_scheme_check_old_tags(
assert git.tag_exist("v0.2.0-a0") is True
for version_file in [tmp_version_file, tmp_commitizen_cfg_file]:
- with open(version_file) as f:
+ with version_file.open() as f:
assert "0.2.0-a0" in f.read()
util.run_cli("bump", "--prerelease", "alpha")
assert git.tag_exist("v0.2.0-a1") is True
for version_file in [tmp_version_file, tmp_commitizen_cfg_file]:
- with open(version_file) as f:
+ with version_file.open() as f:
assert "0.2.0-a1" in f.read()
# PRERELEASE BUMP CREATES VERSION WITHOUT PRERELEASE
@@ -986,7 +985,7 @@ def test_bump_command_prerelease_scheme_check_old_tags(
assert git.tag_exist("v0.2.0") is True
for version_file in [tmp_version_file, tmp_commitizen_cfg_file]:
- with open(version_file) as f:
+ with version_file.open() as f:
assert "0.2.0" in f.read()
@@ -1229,7 +1228,7 @@ def test_bump_get_next_update_changelog_on_bump(
util: UtilFixture, capsys: pytest.CaptureFixture, config_path: Path
):
util.create_file_and_commit("feat: new file")
- with open(config_path, "a", encoding="utf-8") as fp:
+ with config_path.open("a", encoding="utf-8") as fp:
fp.write("update_changelog_on_bump = true\n")
with pytest.raises(DryRunExit):
@@ -1439,12 +1438,12 @@ def test_is_initial_tag(mocker: MockFixture, tmp_commitizen_project, util: UtilF
def test_changelog_config_flag_merge_prerelease(
mocker: MockFixture,
util: UtilFixture,
- changelog_path: str,
- config_path: str,
+ changelog_path: Path,
+ config_path: Path,
file_regression: FileRegressionFixture,
test_input: str,
):
- with open(config_path, "a") as f:
+ with config_path.open("a") as f:
f.write("changelog_merge_prerelease = true\n")
f.write("update_changelog_on_bump = true\n")
f.write("annotated_tag = true\n")
@@ -1459,7 +1458,7 @@ def test_changelog_config_flag_merge_prerelease(
util.run_cli("bump", "--changelog")
- with open(changelog_path) as f:
+ with changelog_path.open() as f:
out = f.read()
file_regression.check(out, extension=".md")
@@ -1470,12 +1469,12 @@ def test_changelog_config_flag_merge_prerelease(
@pytest.mark.freeze_time("2025-01-01")
def test_changelog_config_flag_merge_prerelease_only_prerelease_present(
util: UtilFixture,
- changelog_path: str,
- config_path: str,
+ changelog_path: Path,
+ config_path: Path,
file_regression: FileRegressionFixture,
test_input: str,
):
- with open(config_path, "a") as f:
+ with config_path.open("a") as f:
f.write("changelog_merge_prerelease = true\n")
f.write("update_changelog_on_bump = true\n")
f.write("annotated_tag = true\n")
@@ -1489,7 +1488,7 @@ def test_changelog_config_flag_merge_prerelease_only_prerelease_present(
util.run_cli("bump", "--changelog")
- with open(changelog_path) as f:
+ with changelog_path.open() as f:
out = f.read()
file_regression.check(out, extension=".md")
diff --git a/tests/commands/test_changelog_command.py b/tests/commands/test_changelog_command.py
index dc97852144..c15ffeee9c 100644
--- a/tests/commands/test_changelog_command.py
+++ b/tests/commands/test_changelog_command.py
@@ -145,7 +145,7 @@ def test_changelog_replacing_unreleased_using_incremental(
@pytest.mark.usefixtures("tmp_commitizen_project")
@pytest.mark.freeze_time("2022-08-14")
def test_changelog_is_persisted_using_incremental(
- changelog_path: str,
+ changelog_path: Path,
file_regression: FileRegressionFixture,
util: UtilFixture,
):
@@ -157,7 +157,7 @@ def test_changelog_is_persisted_using_incremental(
util.run_cli("changelog")
- with open(changelog_path, "a", encoding="utf-8") as f:
+ with changelog_path.open("a", encoding="utf-8") as f:
f.write("\nnote: this should be persisted using increment\n")
util.create_file_and_commit("fix: mama gotta work")
@@ -166,7 +166,7 @@ def test_changelog_is_persisted_using_incremental(
util.run_cli("changelog", "--incremental")
- with open(changelog_path, encoding="utf-8") as f:
+ with changelog_path.open(encoding="utf-8") as f:
out = f.read()
file_regression.check(out, extension=".md")
@@ -174,11 +174,11 @@ def test_changelog_is_persisted_using_incremental(
@pytest.mark.usefixtures("tmp_commitizen_project")
def test_changelog_incremental_angular_sample(
- changelog_path: str,
+ changelog_path: Path,
file_regression: FileRegressionFixture,
util: UtilFixture,
):
- with open(changelog_path, "w", encoding="utf-8") as f:
+ with changelog_path.open("w", encoding="utf-8") as f:
f.write(
"# [10.0.0-rc.3](https://github.com/angular/angular/compare/10.0.0-rc.2...10.0.0-rc.3) (2020-04-22)\n"
"\n"
@@ -197,7 +197,7 @@ def test_changelog_incremental_angular_sample(
util.run_cli("changelog", "--incremental")
- with open(changelog_path, encoding="utf-8") as f:
+ with changelog_path.open(encoding="utf-8") as f:
out = f.read()
file_regression.check(out, extension=".md")
@@ -230,11 +230,11 @@ def test_changelog_incremental_angular_sample(
@pytest.mark.usefixtures("tmp_commitizen_project")
def test_changelog_incremental_keep_a_changelog_sample(
- changelog_path: str,
+ changelog_path: Path,
file_regression: FileRegressionFixture,
util: UtilFixture,
):
- with open(changelog_path, "w", encoding="utf-8") as f:
+ with changelog_path.open("w", encoding="utf-8") as f:
f.write(KEEP_A_CHANGELOG)
util.create_file_and_commit("irrelevant commit")
util.create_tag("1.0.0")
@@ -247,7 +247,7 @@ def test_changelog_incremental_keep_a_changelog_sample(
util.run_cli("changelog", "--incremental")
- with open(changelog_path, encoding="utf-8") as f:
+ with changelog_path.open(encoding="utf-8") as f:
out = f.read()
file_regression.check(out, extension=".md")
@@ -405,7 +405,7 @@ def test_changelog_with_non_linear_merges_commit_order(
@pytest.mark.usefixtures("tmp_commitizen_project")
def test_changelog_multiple_incremental_do_not_add_new_lines(
- changelog_path: str,
+ changelog_path: Path,
file_regression: FileRegressionFixture,
util: UtilFixture,
):
@@ -419,7 +419,7 @@ def test_changelog_multiple_incremental_do_not_add_new_lines(
util.create_file_and_commit(commit_message)
util.run_cli("changelog", "--incremental")
- with open(changelog_path, encoding="utf-8") as f:
+ with changelog_path.open(encoding="utf-8") as f:
out = f.read()
file_regression.check(out, extension=".md")
@@ -427,17 +427,17 @@ def test_changelog_multiple_incremental_do_not_add_new_lines(
@pytest.mark.usefixtures("tmp_commitizen_project")
def test_changelog_incremental_newline_separates_new_content_from_old(
- changelog_path: str,
+ changelog_path: Path,
util: UtilFixture,
file_regression: FileRegressionFixture,
):
"""Test for https://github.com/commitizen-tools/commitizen/issues/509"""
- with open(changelog_path, "w", encoding="utf-8") as f:
+ with changelog_path.open("w", encoding="utf-8") as f:
f.write("Pre-existing content that should be kept\n")
util.create_file_and_commit("feat: add more cat videos")
util.run_cli("changelog", "--incremental")
- with open(changelog_path, encoding="utf-8") as f:
+ with changelog_path.open(encoding="utf-8") as f:
out = f.read()
file_regression.check(out, extension=".md")
@@ -554,21 +554,21 @@ def test_breaking_change_content_v1_with_exclamation_mark_feat(
@pytest.mark.usefixtures("tmp_commitizen_project")
def test_changelog_config_flag_increment(
- changelog_path: str,
- config_path: str,
+ changelog_path: Path,
+ config_path: Path,
file_regression: FileRegressionFixture,
util: UtilFixture,
):
- with open(config_path, "a", encoding="utf-8") as f:
+ with config_path.open("a", encoding="utf-8") as f:
f.write("changelog_incremental = true\n")
- with open(changelog_path, "a", encoding="utf-8") as f:
+ with changelog_path.open("a", encoding="utf-8") as f:
f.write("\nnote: this should be persisted using increment\n")
util.create_file_and_commit("feat: add new output")
util.run_cli("changelog")
- with open(changelog_path, encoding="utf-8") as f:
+ with changelog_path.open(encoding="utf-8") as f:
out = f.read()
assert "this should be persisted using increment" in out
@@ -579,13 +579,13 @@ def test_changelog_config_flag_increment(
@pytest.mark.usefixtures("tmp_commitizen_project")
@pytest.mark.freeze_time("2025-12-29")
def test_changelog_config_flag_merge_prerelease(
- changelog_path: str,
- config_path: str,
+ changelog_path: Path,
+ config_path: Path,
file_regression: FileRegressionFixture,
test_input: str,
util: UtilFixture,
):
- with open(config_path, "a") as f:
+ with config_path.open("a") as f:
f.write("changelog_merge_prerelease = true\n")
util.create_file_and_commit("irrelevant commit")
@@ -602,7 +602,7 @@ def test_changelog_config_flag_merge_prerelease(
util.run_cli("changelog")
- with open(changelog_path) as f:
+ with changelog_path.open() as f:
out = f.read()
file_regression.check(out, extension=".md")
@@ -611,7 +611,7 @@ def test_changelog_config_flag_merge_prerelease(
@pytest.mark.usefixtures("tmp_commitizen_project")
def test_changelog_config_start_rev_option(
capsys: pytest.CaptureFixture,
- config_path: str,
+ config_path: Path,
file_regression: FileRegressionFixture,
util: UtilFixture,
):
@@ -623,7 +623,7 @@ def test_changelog_config_start_rev_option(
util.create_file_and_commit("feat: after 0.2.0")
util.create_file_and_commit("feat: after 0.2")
- with open(config_path, "a", encoding="utf-8") as f:
+ with config_path.open("a", encoding="utf-8") as f:
f.write('changelog_start_rev = "0.2.0"\n')
with pytest.raises(DryRunExit):
@@ -635,12 +635,12 @@ def test_changelog_config_start_rev_option(
@pytest.mark.usefixtures("tmp_commitizen_project")
def test_changelog_incremental_keep_a_changelog_sample_with_annotated_tag(
- changelog_path: str,
+ changelog_path: Path,
file_regression: FileRegressionFixture,
util: UtilFixture,
):
"""Fix #378"""
- with open(changelog_path, "w", encoding="utf-8") as f:
+ with changelog_path.open("w", encoding="utf-8") as f:
f.write(KEEP_A_CHANGELOG)
util.create_file_and_commit("irrelevant commit")
util.create_tag("1.0.0", annotated=True)
@@ -653,7 +653,7 @@ def test_changelog_incremental_keep_a_changelog_sample_with_annotated_tag(
util.run_cli("changelog", "--incremental")
- with open(changelog_path, encoding="utf-8") as f:
+ with changelog_path.open(encoding="utf-8") as f:
out = f.read()
file_regression.check(out, extension=".md")
@@ -663,13 +663,13 @@ def test_changelog_incremental_keep_a_changelog_sample_with_annotated_tag(
@pytest.mark.usefixtures("tmp_commitizen_project")
@pytest.mark.freeze_time("2021-06-11")
def test_changelog_incremental_with_release_candidate_version(
- changelog_path: str,
+ changelog_path: Path,
file_regression: FileRegressionFixture,
test_input: str,
util: UtilFixture,
):
"""Fix #357"""
- with open(changelog_path, "w", encoding="utf-8") as f:
+ with changelog_path.open("w", encoding="utf-8") as f:
f.write(KEEP_A_CHANGELOG)
util.create_file_and_commit("irrelevant commit")
util.create_tag("1.0.0", annotated=True)
@@ -685,7 +685,7 @@ def test_changelog_incremental_with_release_candidate_version(
util.run_cli("changelog", "--incremental")
- with open(changelog_path, encoding="utf-8") as f:
+ with changelog_path.open(encoding="utf-8") as f:
out = f.read()
file_regression.check(out, extension=".md")
@@ -697,13 +697,13 @@ def test_changelog_incremental_with_release_candidate_version(
@pytest.mark.usefixtures("tmp_commitizen_project")
@pytest.mark.freeze_time("2021-06-11")
def test_changelog_incremental_with_prerelease_version_to_prerelease_version(
- changelog_path: str,
+ changelog_path: Path,
file_regression: FileRegressionFixture,
from_pre: str,
to_pre: str,
util: UtilFixture,
):
- with open(changelog_path, "w") as f:
+ with changelog_path.open("w") as f:
f.write(KEEP_A_CHANGELOG)
util.create_file_and_commit("irrelevant commit")
util.create_tag("1.0.0", annotated=True)
@@ -715,7 +715,7 @@ def test_changelog_incremental_with_prerelease_version_to_prerelease_version(
util.run_cli("bump", "--changelog", "--prerelease", to_pre, "--yes")
- with open(changelog_path) as f:
+ with changelog_path.open() as f:
out = f.read()
file_regression.check(out, extension=".md")
@@ -725,13 +725,13 @@ def test_changelog_incremental_with_prerelease_version_to_prerelease_version(
@pytest.mark.usefixtures("tmp_commitizen_project")
@pytest.mark.freeze_time("2025-12-29")
def test_changelog_release_candidate_version_with_merge_prerelease(
- changelog_path: str,
+ changelog_path: Path,
file_regression: FileRegressionFixture,
test_input: str,
util: UtilFixture,
):
"""Fix #357"""
- with open(changelog_path, "w") as f:
+ with changelog_path.open("w") as f:
f.write(KEEP_A_CHANGELOG)
util.create_file_and_commit("irrelevant commit")
util.create_tag("1.0.0")
@@ -747,7 +747,7 @@ def test_changelog_release_candidate_version_with_merge_prerelease(
util.run_cli("changelog", "--merge-prerelease")
- with open(changelog_path) as f:
+ with changelog_path.open() as f:
out = f.read()
file_regression.check(out, extension=".md")
@@ -757,13 +757,13 @@ def test_changelog_release_candidate_version_with_merge_prerelease(
@pytest.mark.usefixtures("tmp_commitizen_project")
@pytest.mark.freeze_time("2023-04-16")
def test_changelog_incremental_with_merge_prerelease(
- changelog_path: str,
+ changelog_path: Path,
file_regression: FileRegressionFixture,
test_input: str,
util: UtilFixture,
):
"""Fix #357"""
- with open(changelog_path, "w") as f:
+ with changelog_path.open("w") as f:
f.write(KEEP_A_CHANGELOG)
util.create_file_and_commit("irrelevant commit")
util.create_tag("1.0.0")
@@ -782,15 +782,15 @@ def test_changelog_incremental_with_merge_prerelease(
util.run_cli("changelog", "--merge-prerelease", "--incremental")
- with open(changelog_path) as f:
+ with changelog_path.open() as f:
out = f.read()
file_regression.check(out, extension=".md")
@pytest.mark.usefixtures("tmp_commitizen_project")
-def test_changelog_with_filename_as_empty_string(config_path: str, util: UtilFixture):
- with open(config_path, "a", encoding="utf-8") as f:
+def test_changelog_with_filename_as_empty_string(config_path: Path, util: UtilFixture):
+ with config_path.open("a", encoding="utf-8") as f:
f.write("changelog_file = true\n")
util.create_file_and_commit("feat: add new output")
@@ -802,12 +802,12 @@ def test_changelog_with_filename_as_empty_string(config_path: str, util: UtilFix
@pytest.mark.usefixtures("tmp_commitizen_project")
@pytest.mark.freeze_time("2022-02-13")
def test_changelog_from_rev_first_version_from_arg(
- config_path: str,
- changelog_path: str,
+ config_path: Path,
+ changelog_path: Path,
file_regression: FileRegressionFixture,
util: UtilFixture,
):
- with open(config_path, "a", encoding="utf-8") as f:
+ with config_path.open("a", encoding="utf-8") as f:
f.write('tag_format = "$version"\n')
# create commit and tag
@@ -820,7 +820,7 @@ def test_changelog_from_rev_first_version_from_arg(
util.run_cli("bump", "--yes")
util.run_cli("changelog", "0.2.0")
- with open(changelog_path, encoding="utf-8") as f:
+ with changelog_path.open(encoding="utf-8") as f:
out = f.read()
file_regression.check(out, extension=".md")
@@ -829,12 +829,12 @@ def test_changelog_from_rev_first_version_from_arg(
@pytest.mark.usefixtures("tmp_commitizen_project")
@pytest.mark.freeze_time("2022-02-13")
def test_changelog_from_rev_latest_version_from_arg(
- config_path: str,
- changelog_path: str,
+ config_path: Path,
+ changelog_path: Path,
file_regression: FileRegressionFixture,
util: UtilFixture,
):
- with open(config_path, "a", encoding="utf-8") as f:
+ with config_path.open("a", encoding="utf-8") as f:
f.write('tag_format = "$version"\n')
# create commit and tag
@@ -848,7 +848,7 @@ def test_changelog_from_rev_latest_version_from_arg(
util.run_cli("changelog", "0.3.0")
- with open(changelog_path) as f:
+ with changelog_path.open() as f:
out = f.read()
file_regression.check(out, extension=".md")
@@ -865,10 +865,10 @@ def test_changelog_from_rev_latest_version_from_arg(
),
)
def test_changelog_from_rev_range_not_found(
- config_path: str, rev_range: str, tag: str, util: UtilFixture
+ config_path: Path, rev_range: str, tag: str, util: UtilFixture
):
"""Provides an invalid revision ID to changelog command"""
- with open(config_path, "a", encoding="utf-8") as f:
+ with config_path.open("a", encoding="utf-8") as f:
f.write('tag_format = "$version"\n')
# create commit and tag
@@ -885,9 +885,9 @@ def test_changelog_from_rev_range_not_found(
@pytest.mark.usefixtures("tmp_commitizen_project")
def test_changelog_multiple_matching_tags(
- config_path: str, changelog_path: str, util: UtilFixture
+ config_path: Path, changelog_path: Path, util: UtilFixture
):
- with open(config_path, "a", encoding="utf-8") as f:
+ with config_path.open("a", encoding="utf-8") as f:
f.write('tag_format = "new-$version"\nlegacy_tag_formats = ["legacy-$version"]')
util.create_file_and_commit("feat: new file")
@@ -903,7 +903,7 @@ def test_changelog_multiple_matching_tags(
warning = warnings[0]
assert "Multiple tags found for version 2.0.0" in str(warning.message)
- with open(changelog_path) as f:
+ with changelog_path.open() as f:
out = f.read()
# Ensure only one tag is rendered
@@ -912,7 +912,7 @@ def test_changelog_multiple_matching_tags(
@pytest.mark.usefixtures("tmp_commitizen_project")
def test_changelog_from_rev_range_default_tag_format(
- changelog_path: str, util: UtilFixture
+ changelog_path: Path, util: UtilFixture
):
"""Checks that rev_range is calculated with the default (None) tag format"""
# create commit and tag
@@ -926,7 +926,7 @@ def test_changelog_from_rev_range_default_tag_format(
util.run_cli("changelog", "0.3.0")
- with open(changelog_path) as f:
+ with changelog_path.open() as f:
out = f.read()
assert "new file" not in out
@@ -935,12 +935,12 @@ def test_changelog_from_rev_range_default_tag_format(
@pytest.mark.usefixtures("tmp_commitizen_project")
@pytest.mark.freeze_time("2022-02-13")
def test_changelog_from_rev_version_range_including_first_tag(
- config_path: str,
- changelog_path: str,
+ config_path: Path,
+ changelog_path: Path,
file_regression: FileRegressionFixture,
util: UtilFixture,
):
- with open(config_path, "a", encoding="utf-8") as f:
+ with config_path.open("a", encoding="utf-8") as f:
f.write('tag_format = "$version"\n')
# create commit and tag
@@ -953,7 +953,7 @@ def test_changelog_from_rev_version_range_including_first_tag(
util.run_cli("bump", "--yes")
util.run_cli("changelog", "0.2.0..0.3.0")
- with open(changelog_path, encoding="utf-8") as f:
+ with changelog_path.open(encoding="utf-8") as f:
out = f.read()
file_regression.check(out, extension=".md")
@@ -962,12 +962,12 @@ def test_changelog_from_rev_version_range_including_first_tag(
@pytest.mark.usefixtures("tmp_commitizen_project")
@pytest.mark.freeze_time("2022-02-13")
def test_changelog_from_rev_version_range_from_arg(
- config_path: str,
- changelog_path: str,
+ config_path: Path,
+ changelog_path: Path,
file_regression: FileRegressionFixture,
util: UtilFixture,
):
- with open(config_path, "a", encoding="utf-8") as f:
+ with config_path.open("a", encoding="utf-8") as f:
f.write('tag_format = "$version"\n')
# create commit and tag
@@ -983,7 +983,7 @@ def test_changelog_from_rev_version_range_from_arg(
util.run_cli("bump", "--yes")
util.run_cli("changelog", "0.3.0..0.4.0")
- with open(changelog_path) as f:
+ with changelog_path.open() as f:
out = f.read()
file_regression.check(out, extension=".md")
@@ -992,8 +992,8 @@ def test_changelog_from_rev_version_range_from_arg(
@pytest.mark.usefixtures("tmp_commitizen_project")
@pytest.mark.freeze_time("2022-02-13")
def test_changelog_from_rev_version_range_with_legacy_tags(
- config_path: str,
- changelog_path: str,
+ config_path: Path,
+ changelog_path: Path,
file_regression: FileRegressionFixture,
util: UtilFixture,
):
@@ -1027,7 +1027,7 @@ def test_changelog_from_rev_version_range_with_legacy_tags(
def test_changelog_from_rev_version_with_big_range_from_arg(
config_path, changelog_path, file_regression, util: UtilFixture
):
- with open(config_path, "a", encoding="utf-8") as f:
+ with config_path.open("a", encoding="utf-8") as f:
f.write('tag_format = "$version"\n')
# create commit and tag
@@ -1053,7 +1053,7 @@ def test_changelog_from_rev_version_with_big_range_from_arg(
util.run_cli("bump", "--yes") # 0.6.0
util.run_cli("changelog", "0.3.0..0.5.0")
- with open(changelog_path) as f:
+ with changelog_path.open() as f:
out = f.read()
file_regression.check(out, extension=".md")
@@ -1063,11 +1063,11 @@ def test_changelog_from_rev_version_with_big_range_from_arg(
@pytest.mark.freeze_time("2022-02-13")
def test_changelog_from_rev_latest_version_dry_run(
capsys: pytest.CaptureFixture,
- config_path: str,
+ config_path: Path,
file_regression: FileRegressionFixture,
util: UtilFixture,
):
- with open(config_path, "a") as f:
+ with config_path.open("a") as f:
f.write('tag_format = "$version"\n')
# create commit and tag
@@ -1111,12 +1111,12 @@ def test_invalid_subject_is_skipped(
@pytest.mark.usefixtures("tmp_commitizen_project")
@pytest.mark.freeze_time("2022-02-13")
def test_changelog_with_customized_change_type_order(
- config_path: str,
- changelog_path: str,
+ config_path: Path,
+ changelog_path: Path,
file_regression: FileRegressionFixture,
util: UtilFixture,
):
- with open(config_path, "a") as f:
+ with config_path.open("a") as f:
f.write('tag_format = "$version"\n')
f.write(
'change_type_order = ["BREAKING CHANGE", "Perf", "Fix", "Feat", "Refactor"]\n'
@@ -1137,7 +1137,7 @@ def test_changelog_with_customized_change_type_order(
util.run_cli("bump", "--yes")
util.run_cli("changelog", "0.3.0..0.4.0")
- with open(changelog_path) as f:
+ with changelog_path.open() as f:
out = f.read()
file_regression.check(out, extension=".md")
@@ -1157,11 +1157,11 @@ def test_empty_commit_list(mocker: MockFixture, util: UtilFixture):
@pytest.mark.freeze_time("2022-02-13")
def test_changelog_prerelease_rev_with_use_scheme_semver(
capsys: pytest.CaptureFixture,
- config_path: str,
+ config_path: Path,
file_regression: FileRegressionFixture,
util: UtilFixture,
):
- with open(config_path, "a") as f:
+ with config_path.open("a") as f:
f.write('tag_format = "$version"\nversion_scheme = "semver"')
# create commit and tag
@@ -1356,7 +1356,7 @@ def test_changelog_only_tag_matching_tag_format_included_prefix(
config_path: Path,
util: UtilFixture,
):
- with open(config_path, "a", encoding="utf-8") as f:
+ with config_path.open("a", encoding="utf-8") as f:
f.write('\ntag_format = "custom${version}"\n')
util.create_file_and_commit("feat: new file")
util.create_tag("v0.2.0")
@@ -1366,7 +1366,7 @@ def test_changelog_only_tag_matching_tag_format_included_prefix(
util.run_cli("bump", "--changelog", "--yes")
util.create_file_and_commit("feat: another new file")
util.run_cli("bump", "--changelog", "--yes")
- with open(changelog_path) as f:
+ with changelog_path.open() as f:
out = f.read()
assert out.startswith("## custom0.3.0 (2021-06-11)")
assert "## v0.2.0 (2021-06-11)" not in out
@@ -1379,7 +1379,7 @@ def test_changelog_only_tag_matching_tag_format_included_prefix_sep(
config_path: Path,
util: UtilFixture,
):
- with open(config_path, "a", encoding="utf-8") as f:
+ with config_path.open("a", encoding="utf-8") as f:
f.write('\ntag_format = "custom-${version}"\n')
util.create_file_and_commit("feat: new file")
util.create_tag("v0.2.0")
@@ -1387,12 +1387,12 @@ def test_changelog_only_tag_matching_tag_format_included_prefix_sep(
util.create_tag("0.2.0")
util.create_tag("random0.2.0")
util.run_cli("bump", "--changelog", "--yes")
- with open(changelog_path) as f:
+ with changelog_path.open() as f:
out = f.read()
util.create_file_and_commit("feat: new version another new file")
util.create_file_and_commit("feat: new version some new file")
util.run_cli("bump", "--changelog")
- with open(changelog_path) as f:
+ with changelog_path.open() as f:
out = f.read()
assert out.startswith("## custom-0.3.0")
assert "## v0.2.0" not in out
@@ -1406,7 +1406,7 @@ def test_changelog_only_tag_matching_tag_format_included_suffix(
config_path: Path,
util: UtilFixture,
):
- with open(config_path, "a", encoding="utf-8") as f:
+ with config_path.open("a", encoding="utf-8") as f:
f.write('\ntag_format = "${version}custom"\n')
util.create_file_and_commit("feat: new file")
util.create_tag("v0.2.0")
@@ -1419,7 +1419,7 @@ def test_changelog_only_tag_matching_tag_format_included_suffix(
util.create_file_and_commit("feat: another new file")
# bump to 0.3.0custom
util.run_cli("bump", "--changelog", "--yes")
- with open(changelog_path) as f:
+ with changelog_path.open() as f:
out = f.read()
assert out.startswith("## 0.3.0custom (2021-06-11)")
assert "## v0.2.0 (2021-06-11)" not in out
@@ -1433,7 +1433,7 @@ def test_changelog_only_tag_matching_tag_format_included_suffix_sep(
config_path: Path,
util: UtilFixture,
):
- with open(config_path, "a", encoding="utf-8") as f:
+ with config_path.open("a", encoding="utf-8") as f:
f.write('\ntag_format = "${version}-custom"\n')
util.create_file_and_commit("feat: new file")
util.create_tag("v0.2.0")
@@ -1443,7 +1443,7 @@ def test_changelog_only_tag_matching_tag_format_included_suffix_sep(
util.run_cli("bump", "--changelog", "--yes")
util.create_file_and_commit("feat: another new file")
util.run_cli("bump", "--changelog", "--yes")
- with open(changelog_path) as f:
+ with changelog_path.open() as f:
out = f.read()
assert out.startswith("## 0.3.0-custom (2021-06-11)")
assert "## v0.2.0 (2021-06-11)" not in out
@@ -1456,7 +1456,7 @@ def test_changelog_legacy_tags(
config_path: Path,
util: UtilFixture,
):
- with open(config_path, "a", encoding="utf-8") as f:
+ with config_path.open("a", encoding="utf-8") as f:
f.writelines(
[
'tag_format = "v${version}"\n',
@@ -1475,7 +1475,7 @@ def test_changelog_legacy_tags(
util.create_file_and_commit("feat: another new file")
util.create_tag("not-0.3.1")
util.run_cli("bump", "--changelog", "--yes")
- out = open(changelog_path).read()
+ out = changelog_path.open().read()
assert "## v0.3.0" in out
assert "## older-0.2.0" in out
assert "## oldest-0.1.0" in out
@@ -1520,7 +1520,7 @@ def test_changelog_incremental_change_tag_format(
util.create_file_and_commit("feat: another new file")
util.create_tag("v0.3.0")
util.run_cli("changelog", "--incremental")
- out = open(changelog_path).read()
+ out = changelog_path.open().read()
assert "## v0.3.0" in out
assert "## older-0.2.0" in out
assert "## older-0.1.0" in out
@@ -1534,7 +1534,7 @@ def test_changelog_ignored_tags(
capsys: pytest.CaptureFixture,
util: UtilFixture,
):
- with open(config_path, "a", encoding="utf-8") as f:
+ with config_path.open("a", encoding="utf-8") as f:
f.writelines(
[
'tag_format = "v${version}"\n',
@@ -1553,7 +1553,7 @@ def test_changelog_ignored_tags(
util.create_file_and_commit("feat: another new file")
util.create_tag("not-ignored")
util.run_cli("bump", "--changelog", "--yes")
- with open(changelog_path) as f:
+ with changelog_path.open() as f:
out = f.read()
assert "## ignore-0.1.0" not in out
assert "## ignored" not in out
diff --git a/tests/commands/test_commit_command.py b/tests/commands/test_commit_command.py
index c80a13823d..b3b3791153 100644
--- a/tests/commands/test_commit_command.py
+++ b/tests/commands/test_commit_command.py
@@ -50,7 +50,7 @@ def staging_is_clean(mocker: MockFixture, tmp_git_project):
@pytest.fixture
def backup_file(tmp_git_project):
- with open(get_backup_file_path(), "w") as backup_file:
+ with get_backup_file_path().open("w") as backup_file:
backup_file.write("backup commit")
diff --git a/tests/commands/test_init_command.py b/tests/commands/test_init_command.py
index ad4431bfd4..8675f7f9f3 100644
--- a/tests/commands/test_init_command.py
+++ b/tests/commands/test_init_command.py
@@ -9,7 +9,6 @@
from commitizen import cmd, commands
from commitizen.__version__ import __version__
-from commitizen.cz import registry
from commitizen.exceptions import InitFailedError, NoAnswersError
if TYPE_CHECKING:
@@ -465,20 +464,18 @@ def test_init_configuration_with_version_provider(
) # Version should not be set when using version_provider
-def test_construct_name_choice_with_description(
- config: BaseConfig, mocker: MockFixture
-):
+def test_construct_name_choice_from_registry(config: BaseConfig):
"""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 = commands.Init(config)._construct_name_choices_from_registry()
+ assert choices[0].title == "cz_conventional_commits"
+ assert choices[0].value == "cz_conventional_commits"
+ assert choices[0].description == "(): "
+ assert choices[1].title == "cz_customize"
+ assert choices[1].value == "cz_customize"
+ assert choices[1].description is None
+ assert choices[2].title == "cz_jira"
+ assert choices[2].value == "cz_jira"
+ assert (
+ choices[2].description
+ == " # "
)
- 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 == "(): "
diff --git a/tests/conftest.py b/tests/conftest.py
index b1690ccab8..06f1a30c97 100644
--- a/tests/conftest.py
+++ b/tests/conftest.py
@@ -165,11 +165,6 @@ def config():
return _config
-@pytest.fixture
-def config_path() -> str:
- return os.path.join(os.getcwd(), "pyproject.toml")
-
-
class SemverCommitizen(BaseCommitizen):
"""A minimal cz rules used to test changelog and bump.
diff --git a/tests/providers/conftest.py b/tests/providers/conftest.py
deleted file mode 100644
index 41b7bd02f1..0000000000
--- a/tests/providers/conftest.py
+++ /dev/null
@@ -1,18 +0,0 @@
-from __future__ import annotations
-
-import os
-from pathlib import Path
-from typing import TYPE_CHECKING
-
-import pytest
-
-if TYPE_CHECKING:
- from collections.abc import Iterator
-
-
-@pytest.fixture
-def chdir(tmp_path: Path) -> Iterator[Path]:
- cwd = Path()
- os.chdir(tmp_path)
- yield tmp_path
- os.chdir(cwd)
diff --git a/tests/test_bump_update_version_in_files.py b/tests/test_bump_update_version_in_files.py
index 8fd4c465b8..1a1afade0c 100644
--- a/tests/test_bump_update_version_in_files.py
+++ b/tests/test_bump_update_version_in_files.py
@@ -125,7 +125,7 @@ def test_partial_update_of_file(version_repeated_file, file_regression):
bump.update_version_in_files(
old_version, new_version, [location], check_consistency=False, encoding="utf-8"
)
- with open(version_repeated_file, encoding="utf-8") as f:
+ with version_repeated_file.open(encoding="utf-8") as f:
file_regression.check(f.read(), extension=".json")
@@ -137,7 +137,7 @@ def test_random_location(random_location_version_file, file_regression):
bump.update_version_in_files(
old_version, new_version, [location], check_consistency=False, encoding="utf-8"
)
- with open(random_location_version_file, encoding="utf-8") as f:
+ with random_location_version_file.open(encoding="utf-8") as f:
file_regression.check(f.read(), extension=".lock")
@@ -151,7 +151,7 @@ def test_duplicates_are_change_with_no_regex(
bump.update_version_in_files(
old_version, new_version, [location], check_consistency=False, encoding="utf-8"
)
- with open(random_location_version_file, encoding="utf-8") as f:
+ with random_location_version_file.open(encoding="utf-8") as f:
file_regression.check(f.read(), extension=".lock")
@@ -220,7 +220,7 @@ def test_multiple_versions_to_bump(
bump.update_version_in_files(
old_version, new_version, [location], check_consistency=False, encoding="utf-8"
)
- with open(multiple_versions_to_update_poetry_lock, encoding="utf-8") as f:
+ with multiple_versions_to_update_poetry_lock.open(encoding="utf-8") as f:
file_regression.check(f.read(), extension=".toml")
diff --git a/tests/test_conf.py b/tests/test_conf.py
index f1ff76ff88..923535e0c8 100644
--- a/tests/test_conf.py
+++ b/tests/test_conf.py
@@ -391,7 +391,7 @@ def test_init_empty_config_content(self, tmpdir, config_file):
toml_config = TomlConfig(data="", path=path)
toml_config.init_empty_config_content()
- with open(path, encoding="utf-8") as toml_file:
+ with path.open(encoding="utf-8") as toml_file:
assert toml_file.read() == "[tool.commitizen]\n"
def test_init_empty_config_content_with_existing_content(self, tmpdir, config_file):
@@ -402,7 +402,7 @@ def test_init_empty_config_content_with_existing_content(self, tmpdir, config_fi
toml_config = TomlConfig(data="", path=path)
toml_config.init_empty_config_content()
- with open(path, encoding="utf-8") as toml_file:
+ with path.open(encoding="utf-8") as toml_file:
assert toml_file.read() == existing_content + "\n[tool.commitizen]\n"
def test_init_with_invalid_config_content(self, tmpdir, config_file):
@@ -427,7 +427,7 @@ def test_init_empty_config_content(self, tmpdir, config_file):
json_config = JsonConfig(data="{}", path=path)
json_config.init_empty_config_content()
- with open(path, encoding="utf-8") as json_file:
+ with path.open(encoding="utf-8") as json_file:
assert json.load(json_file) == {"commitizen": {}}
def test_init_with_invalid_config_content(self, tmpdir, config_file):
@@ -452,7 +452,7 @@ def test_init_empty_config_content(self, tmpdir, config_file):
yaml_config = YAMLConfig(data="{}", path=path)
yaml_config.init_empty_config_content()
- with open(path) as yaml_file:
+ with path.open() as yaml_file:
assert yaml.safe_load(yaml_file) == {"commitizen": {}}
def test_init_with_invalid_content(self, tmpdir, config_file):
diff --git a/uv.lock b/uv.lock
index 885caecfd2..ee8ce5c6cd 100644
--- a/uv.lock
+++ b/uv.lock
@@ -195,7 +195,7 @@ wheels = [
[[package]]
name = "commitizen"
-version = "4.13.2"
+version = "4.13.4"
source = { editable = "." }
dependencies = [
{ name = "argcomplete" },