diff --git a/commitizen/changelog_formats/__init__.py b/commitizen/changelog_formats/__init__.py index c92a43087c..26e697cadd 100644 --- a/commitizen/changelog_formats/__init__.py +++ b/commitizen/changelog_formats/__init__.py @@ -1,5 +1,6 @@ from __future__ import annotations +import warnings from importlib import metadata from typing import TYPE_CHECKING, ClassVar, Protocol @@ -99,5 +100,11 @@ def _guess_changelog_format(filename: str | None) -> type[ChangelogFormat] | Non def __getattr__(name: str) -> Callable[[str], type[ChangelogFormat] | None]: if name == "guess_changelog_format": + warnings.warn( + "guess_changelog_format is deprecated and will be removed in v5. " + "Use _guess_changelog_format instead.", + DeprecationWarning, + stacklevel=2, + ) return _guess_changelog_format raise AttributeError(f"module {__name__} has no attribute {name}") diff --git a/commitizen/cli.py b/commitizen/cli.py index 364bc93f85..854238cc9b 100644 --- a/commitizen/cli.py +++ b/commitizen/cli.py @@ -13,6 +13,7 @@ from decli import cli from commitizen import commands, config, out, version_schemes +from commitizen.defaults import DEFAULT_SETTINGS from commitizen.exceptions import ( CommitizenException, ExitCode, @@ -67,7 +68,7 @@ def __call__( { "name": ["--template", "-t"], "help": ( - "changelog template file name (relative to the current working directory)" + "Changelog template file name (relative to the current working directory)." ), }, { @@ -75,7 +76,7 @@ def __call__( "action": ParseKwargs, "dest": "extras", "metavar": "EXTRA", - "help": "a changelog extra variable (in the form 'key=value')", + "help": "Changelog extra variables (in the form 'key=value').", }, ) @@ -89,18 +90,18 @@ def __call__( "arguments": [ { "name": "--config", - "help": "the path of configuration file", + "help": "The path to the configuration file.", }, - {"name": "--debug", "action": "store_true", "help": "use debug mode"}, + {"name": "--debug", "action": "store_true", "help": "Use debug mode."}, { "name": ["-n", "--name"], - "help": "use the given commitizen (default: cz_conventional_commits)", + "help": "Use the given commitizen (default: cz_conventional_commits).", }, { "name": ["-nr", "--no-raise"], "type": str, "required": False, - "help": "comma separated error codes that won't raise error, e.g: cz -nr 1,2,3 bump. See codes at https://commitizen-tools.github.io/commitizen/exit_codes/", + "help": "Comma-separated error codes that won't raise error, e.g., cz -nr 1,2,3 bump. See codes at https://commitizen-tools.github.io/commitizen/exit_codes/", }, ], "subcommands": { @@ -109,157 +110,157 @@ def __call__( "commands": [ { "name": ["init"], - "description": "init commitizen configuration", - "help": "init commitizen configuration", + "description": "Initialize commitizen configuration", + "help": "Initialize commitizen configuration.", "func": commands.Init, }, { "name": ["commit", "c"], - "description": "create new commit", - "help": "create new commit", + "description": "Create new commit", + "help": "Create new commit.", "func": commands.Commit, "arguments": [ { "name": ["--retry"], "action": "store_true", - "help": "retry last commit", + "help": "Retry the last commit.", }, { "name": ["--no-retry"], "action": "store_true", "default": False, - "help": "skip retry if retry_after_failure is set to true", + "help": "Skip retry if --retry or `retry_after_failure` is set to true.", }, { "name": "--dry-run", "action": "store_true", - "help": "show output to stdout, no commit, no modified files", + "help": "Perform a dry run, without committing or modifying files.", }, { "name": "--write-message-to-file", "type": Path, "metavar": "FILE_PATH", - "help": "write message to file before committing (can be combined with --dry-run)", + "help": "Write message to FILE_PATH before committing (can be used with --dry-run).", }, { "name": ["-s", "--signoff"], "action": "store_true", - "help": "Deprecated, use 'cz commit -- -s' instead", + "help": "Deprecated, use `cz commit -- -s` instead.", }, { "name": ["-a", "--all"], "action": "store_true", - "help": "Tell the command to automatically stage files that have been modified and deleted, but new files you have not told Git about are not affected.", + # The help text aligns with the description of git commit --all + "help": "Automatically stage files that have been modified and deleted, but new files you have not told Git about are not affected.", }, { "name": ["-e", "--edit"], "action": "store_true", "default": False, - "help": "edit the commit message before committing", + "help": "Edit the commit message before committing.", }, { "name": ["-l", "--message-length-limit"], "type": int, - "help": "length limit of the commit message; 0 for no limit", + "help": "Set the length limit of the commit message; 0 for no limit.", }, { "name": ["--"], "action": "store_true", "dest": "double_dash", - "help": "Positional arguments separator (recommended)", + "help": "Positional arguments separator (recommended).", }, ], }, { "name": "ls", - "description": "show available commitizens", - "help": "show available commitizens", + "description": "Show available Commitizens", + "help": "Show available Commitizens.", "func": commands.ListCz, }, { "name": "example", - "description": "show commit example", - "help": "show commit example", + "description": "Show commit example", + "help": "Show commit example.", "func": commands.Example, }, { "name": "info", - "description": "show information about the cz", - "help": "show information about the cz", + "description": "Show information about the cz", + "help": "Show information about the cz.", "func": commands.Info, }, { "name": "schema", - "description": "show commit schema", - "help": "show commit schema", + "description": "Show commit schema", + "help": "Show commit schema.", "func": commands.Schema, }, { "name": "bump", - "description": "bump semantic version based on the git log", - "help": "bump semantic version based on the git log", + "description": "Bump semantic version based on the git log", + "help": "Bump semantic version based on the git log.", "func": commands.Bump, "arguments": [ { "name": "--dry-run", "action": "store_true", - "help": "show output to stdout, no commit, no modified files", + "help": "Perform a dry run, without committing or modifying files.", }, { - "name": "--files-only", + "name": "--files-only", # TODO: rename to --version-files-only "action": "store_true", - "help": "bump version in the files from the config", + "help": "Bump version in the `version_files` specified in the configuration file only.", }, { "name": "--local-version", "action": "store_true", - "help": "bump only the local version portion", + "help": "Bump version only the local version portion (ignoring the public version).", }, { "name": ["--changelog", "-ch"], "action": "store_true", "default": False, - "help": "generate the changelog for the newest version", + "help": "Generate the changelog for the latest version.", }, { "name": ["--no-verify"], "action": "store_true", "default": False, - "help": "this option bypasses the pre-commit and commit-msg hooks", + # The help text aligns with the description of git commit --no-verify + "help": "Bypass the pre-commit and commit-msg hooks.", }, { "name": "--yes", "action": "store_true", - "help": "accept automatically questions done", + "help": "Accept automatically answered questions.", }, { "name": "--tag-format", "help": ( - "the format used to tag the commit and read it, " - "use it in existing projects, " - "wrap around simple quotes" + "The format used to tag the commit and read it. " + "Use it in existing projects, and wrap around simple quotes." ), }, { "name": "--bump-message", "help": ( - "template used to create the release commit, " - "useful when working with CI" + "Template used to create the release commit, useful when working with CI." ), }, { "name": ["--prerelease", "-pr"], - "help": "choose type of prerelease", + "help": "Type of prerelease.", "choices": ["alpha", "beta", "rc"], }, { "name": ["--devrelease", "-d"], - "help": "specify non-negative integer for dev. release", + "help": "Specify non-negative integer for dev release.", "type": int, }, { "name": ["--increment"], - "help": "manually specify the desired increment", + "help": "Specify the desired increment.", "choices": ["MAJOR", "MINOR", "PATCH"], "type": str.upper, }, @@ -268,35 +269,34 @@ def __call__( "choices": ["linear", "exact"], "default": "linear", "help": ( - "set the method by which the new version is chosen. " - "'linear' (default) guesses the next version based on typical linear version progression, " - "such that bumping of a pre-release with lower precedence than the current pre-release " + "Set the method by which the new version is chosen. " + "'linear' (default) resolves the next version based on typical linear version progression, " + "where bumping of a pre-release with lower precedence than the current pre-release " "phase maintains the current phase of higher precedence. " "'exact' applies the changes that have been specified (or determined from the commit log) " - "without interpretation, such that the increment and pre-release are always honored" + "without interpretation, ensuring the increment and pre-release are always honored." ), }, { "name": ["--check-consistency", "-cc"], "help": ( - "check consistency among versions defined in " - "commitizen configuration and version_files" + "Check consistency among versions defined in Commitizen configuration file and `version_files`." ), "action": "store_true", }, { "name": ["--annotated-tag", "-at"], - "help": "create annotated tag instead of lightweight one", + "help": "Create annotated tag instead of lightweight one.", "action": "store_true", }, { "name": ["--annotated-tag-message", "-atm"], - "help": "create annotated tag message", + "help": "Create annotated tag message.", "type": str, }, { "name": ["--gpg-sign", "-s"], - "help": "sign tag instead of lightweight one", + "help": "Sign tag instead of lightweight one.", "default": False, "action": "store_true", }, @@ -304,46 +304,46 @@ def __call__( "name": ["--changelog-to-stdout"], "action": "store_true", "default": False, - "help": "Output changelog to the stdout", + "help": "Output changelog to stdout.", }, { "name": ["--git-output-to-stderr"], "action": "store_true", "default": False, - "help": "Redirect git output to stderr", + "help": "Redirect git output to stderr.", }, { "name": ["--retry"], "action": "store_true", "default": False, - "help": "retry commit if it fails the 1st time", + "help": "Retry commit if it fails for the first time.", }, { "name": ["--major-version-zero"], "action": "store_true", "default": None, - "help": "keep major version at zero, even for breaking changes", + "help": "Keep major version at zero, even for breaking changes.", }, *deepcopy(tpl_arguments), { "name": "--file-name", - "help": "file name of changelog (default: 'CHANGELOG.md')", + "help": "File name of changelog (default: 'CHANGELOG.md').", }, { "name": ["--prerelease-offset"], "type": int, "default": None, - "help": "start pre-releases with this offset", + "help": "Start pre-releases with this offset.", }, { "name": ["--version-scheme"], - "help": "choose version scheme", + "help": "Choose version scheme.", "default": None, "choices": version_schemes.KNOWN_SCHEMES, }, { "name": ["--version-type"], - "help": "Deprecated, use --version-scheme instead", + "help": "Deprecated, use `--version-scheme` instead.", "default": None, "choices": version_schemes.KNOWN_SCHEMES, }, @@ -351,24 +351,24 @@ def __call__( "name": "manual_version", "type": str, "nargs": "?", - "help": "bump to the given version (e.g: 1.5.3)", + "help": "Bump to the given version (e.g., 1.5.3).", "metavar": "MANUAL_VERSION", }, { "name": ["--build-metadata"], - "help": "Add additional build-metadata to the version-number", + "help": "Add additional build-metadata to the version-number.", "default": None, }, { "name": ["--get-next"], "action": "store_true", - "help": "Determine the next version and write to stdout", + "help": "Determine the next version and write to stdout.", "default": False, }, { "name": ["--allow-no-commit"], "default": False, - "help": "bump version without eligible commits", + "help": "Bump version without eligible commits.", "action": "store_true", }, ], @@ -376,10 +376,10 @@ def __call__( { "name": ["changelog", "ch"], "description": ( - "generate changelog (note that it will overwrite existing file)" + "Generate changelog (note that it will overwrite existing files)" ), "help": ( - "generate changelog (note that it will overwrite existing file)" + "Generate changelog (note that it will overwrite existing files)." ), "func": commands.Changelog, "arguments": [ @@ -387,17 +387,17 @@ def __call__( "name": "--dry-run", "action": "store_true", "default": False, - "help": "show changelog to stdout", + "help": "Show changelog to stdout.", }, { "name": "--file-name", - "help": "file name of changelog (default: 'CHANGELOG.md')", + "help": "File name of changelog (default: 'CHANGELOG.md').", }, { "name": "--unreleased-version", "help": ( - "set the value for the new version (use the tag value), " - "instead of using unreleased" + "Set the value for the new version (use the tag value), " + "instead of using unreleased versions." ), }, { @@ -405,22 +405,22 @@ def __call__( "action": "store_true", "default": False, "help": ( - "generates changelog from last created version, " - "useful if the changelog has been manually modified" + "Generate changelog from the last created version, " + "useful if the changelog has been manually modified." ), }, { "name": "rev_range", "type": str, "nargs": "?", - "help": "generates changelog for the given version (e.g: 1.5.3) or version range (e.g: 1.5.3..1.7.9)", + "help": "Generate changelog for the given version (e.g., 1.5.3) or version range (e.g., 1.5.3..1.7.9).", }, { "name": "--start-rev", "default": None, "help": ( - "start rev of the changelog. " - "If not set, it will generate changelog from the start" + "Start rev of the changelog. " + "If not set, it will generate changelog from the beginning." ), }, { @@ -428,128 +428,128 @@ def __call__( "action": "store_true", "default": False, "help": ( - "collect all changes from prereleases into next non-prerelease. " - "If not set, it will include prereleases in the changelog" + "Collect all changes from prereleases into the next non-prerelease. " + "If not set, it will include prereleases in the changelog." ), }, { "name": ["--version-scheme"], - "help": "choose version scheme", + "help": "Choose version scheme.", "default": None, "choices": version_schemes.KNOWN_SCHEMES, }, { "name": "--export-template", "default": None, - "help": "Export the changelog template into this file instead of rendering it", + "help": "Export the changelog template into this file instead of rendering it.", }, *deepcopy(tpl_arguments), { "name": "--tag-format", - "help": "The format of the tag, wrap around simple quotes", + "help": "The format of the tag, wrap around simple quotes.", }, ], }, { "name": ["check"], - "description": "validates that a commit message matches the commitizen schema", - "help": "validates that a commit message matches the commitizen schema", + "description": "Validate that a commit message matches the commitizen schema", + "help": "Validate that a commit message matches the commitizen schema.", "func": commands.Check, "arguments": [ { "name": "--commit-msg-file", "help": ( - "ask for the name of the temporal file that contains " - "the commit message. " - "Using it in a git hook script: MSG_FILE=$1" + "Ask for the name of the temporary file that contains the commit message. " + "Use it in a git hook script: MSG_FILE=$1." ), "exclusive_group": "group1", }, { "name": "--rev-range", - "help": "a range of git rev to check. e.g, master..HEAD", + "help": "Validate the commits in the given range of git rev, e.g., master..HEAD.", "exclusive_group": "group1", }, { "name": ["-d", "--use-default-range"], "action": "store_true", "default": False, - "help": "check from the default branch to HEAD. e.g, refs/remotes/origin/master..HEAD", + "help": "Validate the commits from the default branch to HEAD, e.g., refs/remotes/origin/master..HEAD.", "exclusive_group": "group1", }, { "name": ["-m", "--message"], - "help": "commit message that needs to be checked", + "help": "Validate the given commit message.", "exclusive_group": "group1", }, { "name": ["--allow-abort"], "action": "store_true", "default": False, - "help": "allow empty commit messages, which typically abort a commit", + "help": "Allow empty commit messages, which typically abort a commit.", }, { "name": ["--allowed-prefixes"], "nargs": "*", - "help": "allowed commit message prefixes. " - "If the message starts by one of these prefixes, " - "the message won't be checked against the regex", + "help": "Skip validation for commit messages that start with the specified prefixes.", }, { "name": ["-l", "--message-length-limit"], "type": int, - "help": "length limit of the commit message; 0 for no limit", + "help": "Restrict the length of the **first line** of the commit message; 0 for no limit.", }, ], }, { "name": ["version"], "description": ( - "get the version of the installed commitizen or the current project" - " (default: installed commitizen)" + "Get the version of the installed commitizen or the current project (default: installed commitizen)" ), "help": ( - "get the version of the installed commitizen or the current project" - " (default: installed commitizen)" + "Get the version of the installed commitizen or the current project (default: installed commitizen)." ), "func": commands.Version, "arguments": [ { "name": ["-r", "--report"], - "help": "get system information for reporting bugs", + "help": "Output the system information for reporting bugs.", "action": "store_true", "exclusive_group": "group1", }, { "name": ["-p", "--project"], - "help": "get the version of the current project", + "help": "Output the version of the current project.", "action": "store_true", "exclusive_group": "group1", }, { "name": ["-c", "--commitizen"], - "help": "get the version of the installed commitizen", + "help": "Output the version of the installed commitizen.", "action": "store_true", "exclusive_group": "group1", }, { "name": ["-v", "--verbose"], "help": ( - "get the version of both the installed commitizen " - "and the current project" + "Output the version of both the installed commitizen and the current project." ), "action": "store_true", "exclusive_group": "group1", }, { "name": ["--major"], - "help": "get just the major version. Need to be used with --project or --verbose.", + "help": "Output just the major version. Must be used with --project or --verbose.", "action": "store_true", "exclusive_group": "group2", }, { "name": ["--minor"], - "help": "get just the minor version. Need to be used with --project or --verbose.", + "help": "Output just the minor version. Must be used with --project or --verbose.", + "action": "store_true", + "exclusive_group": "group2", + }, + { + "name": ["--tag"], + "help": "get the version with tag prefix. Need to be used with --project or --verbose.", "action": "store_true", "exclusive_group": "group2", }, @@ -673,7 +673,7 @@ def main() -> None: if args.name: conf.update({"name": args.name}) elif not conf.path: - conf.update({"name": "cz_conventional_commits"}) + conf.update({"name": DEFAULT_SETTINGS["name"]}) if args.debug: logging.getLogger("commitizen").setLevel(logging.DEBUG) diff --git a/commitizen/commands/bump.py b/commitizen/commands/bump.py index f6637b5c74..affe2bd358 100644 --- a/commitizen/commands/bump.py +++ b/commitizen/commands/bump.py @@ -306,6 +306,7 @@ def __call__(self) -> None: ) updated_files: list[str] = [] + changelog_file_name = None dry_run = self.arguments["dry_run"] if self.changelog_flag: changelog_args = { @@ -318,12 +319,11 @@ def __call__(self) -> None: "during_version_bump": self.arguments["prerelease"] is None, } if self.changelog_to_stdout: - changelog_cmd = Changelog( - self.config, - {**changelog_args, "dry_run": True}, # type: ignore[typeddict-item] - ) try: - changelog_cmd() + Changelog( + self.config, + {**changelog_args, "dry_run": True}, # type: ignore[typeddict-item] + )() except DryRunExit: pass @@ -332,7 +332,8 @@ def __call__(self) -> None: {**changelog_args, "file_name": self.file_name}, # type: ignore[typeddict-item] ) changelog_cmd() - updated_files.append(changelog_cmd.file_name) + changelog_file_name = changelog_cmd.file_name + updated_files.append(changelog_file_name) # Do not perform operations over files or git. if dry_run: @@ -361,9 +362,7 @@ def __call__(self) -> None: new_tag_version=new_tag_version, message=message, increment=increment, - changelog_file_name=changelog_cmd.file_name - if self.changelog_flag - else None, + changelog_file_name=changelog_file_name, ) if self.arguments["files_only"]: @@ -419,9 +418,7 @@ def __call__(self) -> None: current_tag_version=new_tag_version, message=message, increment=increment, - changelog_file_name=changelog_cmd.file_name - if self.changelog_flag - else None, + changelog_file_name=changelog_file_name, ) # TODO: For v3 output this only as diagnostic and remove this if diff --git a/commitizen/commands/check.py b/commitizen/commands/check.py index 8ec5b47f8d..182839910d 100644 --- a/commitizen/commands/check.py +++ b/commitizen/commands/check.py @@ -20,7 +20,7 @@ class CheckArgs(TypedDict, total=False): commit_msg: str rev_range: str allow_abort: bool - message_length_limit: int | None + message_length_limit: int allowed_prefixes: list[str] message: str use_default_range: bool @@ -46,7 +46,7 @@ def __init__(self, config: BaseConfig, arguments: CheckArgs, *args: object) -> N self.use_default_range = bool(arguments.get("use_default_range")) self.max_msg_length = arguments.get( - "message_length_limit", config.settings.get("message_length_limit", None) + "message_length_limit", config.settings.get("message_length_limit", 0) ) # we need to distinguish between None and [], which is a valid value diff --git a/commitizen/commands/commit.py b/commitizen/commands/commit.py index 3894d0b77e..5776af4201 100644 --- a/commitizen/commands/commit.py +++ b/commitizen/commands/commit.py @@ -36,7 +36,7 @@ class CommitArgs(TypedDict, total=False): dry_run: bool edit: bool extra_cli_args: str - message_length_limit: int | None + message_length_limit: int no_retry: bool signoff: bool write_message_to_file: Path | None @@ -83,19 +83,23 @@ def _get_message_by_prompt_commit_questions(self) -> str: raise NoAnswersError() message = self.cz.message(answers) - if limit := self.arguments.get( - "message_length_limit", self.config.settings.get("message_length_limit", 0) - ): - self._validate_subject_length(message=message, length_limit=limit) - + self._validate_subject_length(message) return message - def _validate_subject_length(self, *, message: str, length_limit: int) -> None: + def _validate_subject_length(self, message: str) -> None: + message_length_limit = self.arguments.get( + "message_length_limit", self.config.settings.get("message_length_limit", 0) + ) # By the contract, message_length_limit is set to 0 for no limit + if ( + message_length_limit is None or message_length_limit <= 0 + ): # do nothing for no limit + return + subject = message.partition("\n")[0].strip() - if len(subject) > length_limit: + if len(subject) > message_length_limit: raise CommitMessageLengthExceededError( - f"Length of commit message exceeds limit ({len(subject)}/{length_limit}), subject: '{subject}'" + f"Length of commit message exceeds limit ({len(subject)}/{message_length_limit}), subject: '{subject}'" ) def manual_edit(self, message: str) -> str: diff --git a/commitizen/commands/init.py b/commitizen/commands/init.py index 62678a2244..9d33e7081a 100644 --- a/commitizen/commands/init.py +++ b/commitizen/commands/init.py @@ -11,7 +11,11 @@ from commitizen.config.factory import create_config from commitizen.cz import registry from commitizen.defaults import CONFIG_FILES, DEFAULT_SETTINGS -from commitizen.exceptions import InitFailedError, NoAnswersError +from commitizen.exceptions import ( + InitFailedError, + MissingCzCustomizeConfigError, + NoAnswersError, +) from commitizen.git import get_latest_tag_name, get_tag_names, smart_open from commitizen.version_schemes import KNOWN_SCHEMES, Version, get_version_scheme @@ -166,13 +170,29 @@ def _ask_config_path(self) -> Path: def _ask_name(self) -> str: name: str = questionary.select( - "Please choose a cz (commit rule): (default: cz_conventional_commits)", - choices=list(registry.keys()), - default="cz_conventional_commits", + f"Please choose a cz (commit rule): (default: {DEFAULT_SETTINGS['name']})", + choices=self._construct_name_choice_with_description(), + default=DEFAULT_SETTINGS["name"], style=self.cz.style, ).unsafe_ask() return name + def _construct_name_choice_with_description(self) -> list[questionary.Choice]: + choices = [] + for cz_name, cz_class in registry.items(): + try: + cz_obj = cz_class(self.config) + except MissingCzCustomizeConfigError: + choices.append(questionary.Choice(title=cz_name, value=cz_name)) + continue + first_example = cz_obj.schema().partition("\n")[0] + choices.append( + questionary.Choice( + title=cz_name, value=cz_name, description=first_example + ) + ) + return choices + def _ask_tag(self) -> str: latest_tag = get_latest_tag_name() if not latest_tag: diff --git a/commitizen/commands/version.py b/commitizen/commands/version.py index 9290e80b8f..c8a76fe27f 100644 --- a/commitizen/commands/version.py +++ b/commitizen/commands/version.py @@ -7,6 +7,7 @@ from commitizen.config import BaseConfig from commitizen.exceptions import NoVersionSpecifiedError, VersionSchemeUnknown from commitizen.providers import get_provider +from commitizen.tags import TagRules from commitizen.version_schemes import get_version_scheme @@ -17,6 +18,7 @@ class VersionArgs(TypedDict, total=False): verbose: bool major: bool minor: bool + tag: bool class Version: @@ -59,6 +61,9 @@ def __call__(self) -> None: version = f"{version_scheme.major}" elif self.arguments.get("minor"): version = f"{version_scheme.minor}" + elif self.arguments.get("tag"): + tag_rules = TagRules.from_settings(self.config.settings) + version = tag_rules.normalize_tag(version_scheme) out.write( f"Project Version: {version}" @@ -73,5 +78,9 @@ def __call__(self) -> None: ) return + if self.arguments.get("tag"): + out.error("Tag can only be used with --project or --verbose.") + return + # If no arguments are provided, just show the installed commitizen version out.write(__version__) diff --git a/commitizen/config/__init__.py b/commitizen/config/__init__.py index cce3a266cd..ae980af9c0 100644 --- a/commitizen/config/__init__.py +++ b/commitizen/config/__init__.py @@ -9,7 +9,7 @@ from .base_config import BaseConfig -def _resolve_config_paths() -> list[Path]: +def _resolve_config_candidates() -> list[BaseConfig]: git_project_root = git.find_git_project_root() cfg_search_paths = [Path(".")] @@ -18,12 +18,18 @@ def _resolve_config_paths() -> list[Path]: # The following algorithm is ugly, but we need to ensure that the order of the candidates are preserved before v5. # Also, the number of possible config files is limited, so the complexity is not a problem. - candidates: list[Path] = [] + candidates: list[BaseConfig] = [] for dir in cfg_search_paths: for filename in defaults.CONFIG_FILES: out_path = dir / Path(filename) - if out_path.exists() and all(not out_path.samefile(p) for p in candidates): - candidates.append(out_path) + if ( + out_path.exists() + and not any( + out_path.samefile(candidate.path) for candidate in candidates + ) + and not (conf := _create_config_from_path(out_path)).is_empty_config + ): + candidates.append(conf) return candidates @@ -44,21 +50,11 @@ def read_cfg(filepath: str | None = None) -> BaseConfig: raise ConfigFileIsEmpty() return conf - config_candidate_paths = _resolve_config_paths() - - # Check for multiple config files and warn the user - config_candidates_exclude_pyproject = [ - path for path in config_candidate_paths if path.name != "pyproject.toml" - ] - - for config_candidate_path in config_candidate_paths: - conf = _create_config_from_path(config_candidate_path) - if not conf.is_empty_config: - if len(config_candidates_exclude_pyproject) > 1: - out.warn( - f"Multiple config files detected: {', '.join(map(str, config_candidates_exclude_pyproject))}. " - f"Using config file: '{config_candidate_path}'." - ) - return conf + config_candidates = _resolve_config_candidates() + if len(config_candidates) > 1: + out.warn( + f"Multiple config files detected: {', '.join(str(conf.path) for conf in config_candidates)}. " + f"Using config file: '{config_candidates[0].path}'." + ) - return BaseConfig() + return config_candidates[0] if config_candidates else BaseConfig() diff --git a/commitizen/cz/base.py b/commitizen/cz/base.py index 90633c42e6..5e7f2663ca 100644 --- a/commitizen/cz/base.py +++ b/commitizen/cz/base.py @@ -130,7 +130,7 @@ def validate_commit_message( if any(map(commit_msg.startswith, allowed_prefixes)): return ValidationResult(True, []) - if max_msg_length is not None: + if max_msg_length is not None and max_msg_length > 0: msg_len = len(commit_msg.partition("\n")[0].strip()) if msg_len > max_msg_length: # TODO: capitalize the first letter of the error message for consistency in v5 diff --git a/commitizen/defaults.py b/commitizen/defaults.py index 6de41f63d1..4865ccc188 100644 --- a/commitizen/defaults.py +++ b/commitizen/defaults.py @@ -48,7 +48,7 @@ class Settings(TypedDict, total=False): ignored_tag_formats: Sequence[str] legacy_tag_formats: Sequence[str] major_version_zero: bool - message_length_limit: int | None + message_length_limit: int name: str post_bump_hooks: list[str] | None pre_bump_hooks: list[str] | None @@ -114,7 +114,7 @@ class Settings(TypedDict, total=False): "template": None, # default provided by plugin "extras": {}, "breaking_change_exclamation_in_title": False, - "message_length_limit": None, # None for no limit + "message_length_limit": 0, # 0 for no limit } MAJOR = "MAJOR" diff --git a/commitizen/tags.py b/commitizen/tags.py index 68c74a72e6..dcddbd335f 100644 --- a/commitizen/tags.py +++ b/commitizen/tags.py @@ -228,7 +228,7 @@ def normalize_tag( version = self.scheme(version) if isinstance(version, str) else version tag_format = tag_format or self.tag_format - major, minor, patch = version.release + major, minor, patch = (list(version.release) + [0, 0, 0])[:3] prerelease = version.prerelease or "" t = Template(tag_format) @@ -245,6 +245,25 @@ def find_tag_for( ) -> GitTag | None: """Find the first matching tag for a given version.""" version = self.scheme(version) if isinstance(version, str) else version + release = version.release + + # If the requested version is incomplete (e.g., "1.2"), try to find the latest + # matching tag that shares the provided prefix. + if len(release) < 3: + matching_versions: list[tuple[Version, GitTag]] = [] + for tag in tags: + try: + tag_version = self.extract_version(tag) + except InvalidVersion: + continue + if tag_version.release[: len(release)] != release: + continue + matching_versions.append((tag_version, tag)) + + if matching_versions: + _, latest_tag = max(matching_versions, key=lambda vt: vt[0]) + return latest_tag + possible_tags = set(self.normalize_tag(version, f) for f in self.tag_formats) candidates = [t for t in tags if t.name in possible_tags] if len(candidates) > 1: diff --git a/docs/commands/bump.md b/docs/commands/bump.md index e7a7c04030..03fc83402c 100644 --- a/docs/commands/bump.md +++ b/docs/commands/bump.md @@ -65,6 +65,19 @@ You can also set this in the configuration file with `version_scheme = "semver"` | Devrelease | `0.1.1.dev1` | `0.1.1-dev1` | | Dev and pre | `1.0.0a3.dev1` | `1.0.0-a3-dev1` | + +!!! note "Incomplete Version Handling" + Commitizen treats a three-part version (major.minor.patch) as complete. + If your configured version is incomplete (for example, `1` or `1.2`), Commitizen pads missing parts with zeros when it needs `major/minor/patch` for tag formatting. + The tag output depends on your `tag_format`: formats using `${version}` keep `1`/`1.2`, while formats using `${major}.${minor}.${patch}` will render `1.0.0`/`1.2.0`. + + When bumping from an incomplete version, Commitizen looks for the latest existing tag that matches the provided release prefix. + For example, if the current version is `1.2` and the latest `1.2.x` tag is `1.2.3`, then a patch bump yields `1.2.4` and a minor bump yields `1.3.0`. + +!!! tip + To control the behaviour of bumping and version parsing, you may implement your own `version_scheme` by inheriting from `commitizen.version_schemes.BaseVersion` or use an existing plugin package. + + ### PEP440 Version Examples Commitizen supports the [PEP 440][pep440] version format, which includes several version types. Here are examples of each: diff --git a/pyproject.toml b/pyproject.toml index 855bfb6c72..38cf5da23c 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -223,6 +223,8 @@ select = [ "RUF022", # unused-noqa "RUF100", + # flake8-pytest-style + "PT", # Checks for uses of the assert keyword. "S101", # flake8-type-checking (TC) @@ -233,7 +235,15 @@ select = [ "TC005", "TC006", ] -ignore = ["E501", "D1", "D415"] +ignore = [ + "E501", + "D1", + "D415", + "PT006", # TODO(bearomorphism): enable this rule + "PT007", # TODO(bearomorphism): enable this rule + "PT011", # TODO(bearomorphism): enable this rule + "PT022", # TODO(bearomorphism): enable this rule +] extend-safe-fixes = [ "TC", # Move imports inside/outside TYPE_CHECKING blocks "UP", # Update syntaxes for current Python version recommendations diff --git a/tests/commands/test_bump_command.py b/tests/commands/test_bump_command.py index a1c70b9480..2c4bd269bc 100644 --- a/tests/commands/test_bump_command.py +++ b/tests/commands/test_bump_command.py @@ -755,6 +755,8 @@ def test_bump_invalid_manual_version_raises_exception( "0.1.1", "0.2.0", "1.0.0", + "1.2", + "1", ], ) def test_bump_manual_version(util: UtilFixture, manual_version): @@ -775,6 +777,33 @@ def test_bump_manual_version_disallows_major_version_zero(util: UtilFixture): ) +@pytest.mark.parametrize( + "initial_version, expected_version_after_bump", + [ + ("1", "1.1.0"), + ("1.2", "1.3.0"), + ], +) +def test_bump_version_with_less_components_in_config( + tmp_commitizen_project_initial, + initial_version, + expected_version_after_bump, + util: UtilFixture, +): + tmp_commitizen_project = tmp_commitizen_project_initial(version=initial_version) + util.run_cli("bump", "--yes") + + tag_exists = git.tag_exist(expected_version_after_bump) + assert tag_exists is True + + for version_file in [ + tmp_commitizen_project.join("__version__.py"), + tmp_commitizen_project.join("pyproject.toml"), + ]: + with open(version_file) as f: + assert expected_version_after_bump in f.read() + + @pytest.mark.parametrize("commit_msg", ("feat: new file", "feat(user): new file")) def test_bump_with_pre_bump_hooks( commit_msg, mocker: MockFixture, tmp_commitizen_project, util: UtilFixture @@ -998,7 +1027,7 @@ def test_bump_with_major_version_zero_with_plugin( def test_bump_command_version_type_deprecation(util: UtilFixture): util.create_file_and_commit("feat: check deprecation on --version-type") - with pytest.warns(DeprecationWarning): + with pytest.warns(DeprecationWarning, match=r".*--version-type.*deprecated"): util.run_cli( "bump", "--prerelease", @@ -1015,7 +1044,7 @@ def test_bump_command_version_type_deprecation(util: UtilFixture): def test_bump_command_version_scheme_priority_over_version_type(util: UtilFixture): util.create_file_and_commit("feat: check deprecation on --version-type") - with pytest.warns(DeprecationWarning): + with pytest.warns(DeprecationWarning, match=r".*--version-type.*deprecated"): util.run_cli( "bump", "--prerelease", diff --git a/tests/commands/test_check_command.py b/tests/commands/test_check_command.py index b5e3fd2b08..f225e912ea 100644 --- a/tests/commands/test_check_command.py +++ b/tests/commands/test_check_command.py @@ -7,7 +7,7 @@ from commitizen import commands, git from commitizen.cz import registry -from commitizen.cz.base import BaseCommitizen, ValidationResult +from commitizen.cz.base import BaseCommitizen from commitizen.exceptions import ( CommitMessageLengthExceededError, InvalidCommandArgumentError, @@ -16,7 +16,6 @@ ) if TYPE_CHECKING: - import re from collections.abc import Mapping from pytest_mock import MockFixture, MockType @@ -385,7 +384,7 @@ def test_check_command_cli_overrides_config_message_length_limit( ): message = "fix(scope): some commit message" config.settings["message_length_limit"] = len(message) - 1 - for message_length_limit in [len(message) + 1, None]: + for message_length_limit in [len(message) + 1, 0]: success_mock.reset_mock() commands.Check( config=config, @@ -419,60 +418,6 @@ def example(self) -> str: def info(self) -> str: return "Commit message must start with an issue number like ABC-123" - def validate_commit_message( - self, - *, - commit_msg: str, - pattern: re.Pattern[str], - allow_abort: bool, - allowed_prefixes: list[str], - max_msg_length: int | None, - commit_hash: str, - ) -> ValidationResult: - """Validate commit message against the pattern.""" - if not commit_msg: - return ValidationResult( - allow_abort, [] if allow_abort else ["commit message is empty"] - ) - - if any(map(commit_msg.startswith, allowed_prefixes)): - return ValidationResult(True, []) - - if max_msg_length: - msg_len = len(commit_msg.partition("\n")[0].strip()) - if msg_len > max_msg_length: - # TODO: capitalize the first letter of the error message for consistency in v5 - raise CommitMessageLengthExceededError( - f"commit validation: failed!\n" - f"commit message length exceeds the limit.\n" - f'commit "{commit_hash}": "{commit_msg}"\n' - f"message length limit: {max_msg_length} (actual: {msg_len})" - ) - - return ValidationResult( - bool(pattern.match(commit_msg)), [f"pattern: {pattern.pattern}"] - ) - - def format_exception_message( - self, invalid_commits: list[tuple[git.GitCommit, list]] - ) -> str: - """Format commit errors.""" - displayed_msgs_content = "\n".join( - [ - ( - f'commit "{commit.rev}": "{commit.message}"\nerrors:\n\n'.join( - f"- {error}" for error in errors - ) - ) - for (commit, errors) in invalid_commits - ] - ) - return ( - "commit validation: failed!\n" - "please enter a commit message in the commitizen format.\n" - f"{displayed_msgs_content}" - ) - @pytest.fixture def use_cz_custom_validator(mocker): diff --git a/tests/commands/test_commit_command.py b/tests/commands/test_commit_command.py index 87c7aca42c..89a9224b85 100644 --- a/tests/commands/test_commit_command.py +++ b/tests/commands/test_commit_command.py @@ -363,5 +363,5 @@ def test_commit_command_with_config_message_length_limit( success_mock.assert_called_once() success_mock.reset_mock() - commands.Commit(config, {"message_length_limit": None})() + commands.Commit(config, {"message_length_limit": 0})() success_mock.assert_called_once() diff --git a/tests/commands/test_common_command/test_command_shows_description_when_use_help_option_py_3_10_bump_.txt b/tests/commands/test_common_command/test_command_shows_description_when_use_help_option_py_3_10_bump_.txt index ad0a693278..d56e739277 100644 --- a/tests/commands/test_common_command/test_command_shows_description_when_use_help_option_py_3_10_bump_.txt +++ b/tests/commands/test_common_command/test_command_shows_description_when_use_help_option_py_3_10_bump_.txt @@ -14,69 +14,71 @@ usage: cz bump [-h] [--dry-run] [--files-only] [--local-version] [--changelog] [--allow-no-commit] [MANUAL_VERSION] -bump semantic version based on the git log +Bump semantic version based on the git log positional arguments: - MANUAL_VERSION bump to the given version (e.g: 1.5.3) + MANUAL_VERSION Bump to the given version (e.g., 1.5.3). options: -h, --help show this help message and exit - --dry-run show output to stdout, no commit, no modified files - --files-only bump version in the files from the config - --local-version bump only the local version portion - --changelog, -ch generate the changelog for the newest version - --no-verify this option bypasses the pre-commit and commit-msg - hooks - --yes accept automatically questions done + --dry-run Perform a dry run, without committing or modifying + files. + --files-only Bump version in the `version_files` specified in the + configuration file only. + --local-version Bump version only the local version portion (ignoring + the public version). + --changelog, -ch Generate the changelog for the latest version. + --no-verify Bypass the pre-commit and commit-msg hooks. + --yes Accept automatically answered questions. --tag-format TAG_FORMAT - the format used to tag the commit and read it, use it - in existing projects, wrap around simple quotes + The format used to tag the commit and read it. Use it + in existing projects, and wrap around simple quotes. --bump-message BUMP_MESSAGE - template used to create the release commit, useful - when working with CI + Template used to create the release commit, useful + when working with CI. --prerelease {alpha,beta,rc}, -pr {alpha,beta,rc} - choose type of prerelease + Type of prerelease. --devrelease DEVRELEASE, -d DEVRELEASE - specify non-negative integer for dev. release + Specify non-negative integer for dev release. --increment {MAJOR,MINOR,PATCH} - manually specify the desired increment + Specify the desired increment. --increment-mode {linear,exact} - set the method by which the new version is chosen. - 'linear' (default) guesses the next version based on - typical linear version progression, such that bumping - of a pre-release with lower precedence than the - current pre-release phase maintains the current phase - of higher precedence. 'exact' applies the changes that + Set the method by which the new version is chosen. + 'linear' (default) resolves the next version based on + typical linear version progression, where bumping of a + pre-release with lower precedence than the current + pre-release phase maintains the current phase of + higher precedence. 'exact' applies the changes that have been specified (or determined from the commit - log) without interpretation, such that the increment - and pre-release are always honored + log) without interpretation, ensuring the increment + and pre-release are always honored. --check-consistency, -cc - check consistency among versions defined in commitizen - configuration and version_files - --annotated-tag, -at create annotated tag instead of lightweight one + Check consistency among versions defined in Commitizen + configuration file and `version_files`. + --annotated-tag, -at Create annotated tag instead of lightweight one. --annotated-tag-message ANNOTATED_TAG_MESSAGE, -atm ANNOTATED_TAG_MESSAGE - create annotated tag message - --gpg-sign, -s sign tag instead of lightweight one + Create annotated tag message. + --gpg-sign, -s Sign tag instead of lightweight one. --changelog-to-stdout - Output changelog to the stdout + Output changelog to stdout. --git-output-to-stderr - Redirect git output to stderr - --retry retry commit if it fails the 1st time - --major-version-zero keep major version at zero, even for breaking changes + Redirect git output to stderr. + --retry Retry commit if it fails for the first time. + --major-version-zero Keep major version at zero, even for breaking changes. --template TEMPLATE, -t TEMPLATE - changelog template file name (relative to the current - working directory) + Changelog template file name (relative to the current + working directory). --extra EXTRA, -e EXTRA - a changelog extra variable (in the form 'key=value') + Changelog extra variables (in the form 'key=value'). --file-name FILE_NAME - file name of changelog (default: 'CHANGELOG.md') + File name of changelog (default: 'CHANGELOG.md'). --prerelease-offset PRERELEASE_OFFSET - start pre-releases with this offset + Start pre-releases with this offset. --version-scheme {pep440,semver,semver2} - choose version scheme + Choose version scheme. --version-type {pep440,semver,semver2} - Deprecated, use --version-scheme instead + Deprecated, use `--version-scheme` instead. --build-metadata BUILD_METADATA - Add additional build-metadata to the version-number - --get-next Determine the next version and write to stdout - --allow-no-commit bump version without eligible commits + Add additional build-metadata to the version-number. + --get-next Determine the next version and write to stdout. + --allow-no-commit Bump version without eligible commits. diff --git a/tests/commands/test_common_command/test_command_shows_description_when_use_help_option_py_3_10_changelog_.txt b/tests/commands/test_common_command/test_command_shows_description_when_use_help_option_py_3_10_changelog_.txt index f4aa1ca2a6..2d1135af74 100644 --- a/tests/commands/test_common_command/test_command_shows_description_when_use_help_option_py_3_10_changelog_.txt +++ b/tests/commands/test_common_command/test_command_shows_description_when_use_help_option_py_3_10_changelog_.txt @@ -6,37 +6,37 @@ usage: cz changelog [-h] [--dry-run] [--file-name FILE_NAME] [--extra EXTRA] [--tag-format TAG_FORMAT] [rev_range] -generate changelog (note that it will overwrite existing file) +Generate changelog (note that it will overwrite existing files) positional arguments: - rev_range generates changelog for the given version (e.g: 1.5.3) - or version range (e.g: 1.5.3..1.7.9) + rev_range Generate changelog for the given version (e.g., 1.5.3) + or version range (e.g., 1.5.3..1.7.9). options: -h, --help show this help message and exit - --dry-run show changelog to stdout + --dry-run Show changelog to stdout. --file-name FILE_NAME - file name of changelog (default: 'CHANGELOG.md') + File name of changelog (default: 'CHANGELOG.md'). --unreleased-version UNRELEASED_VERSION - set the value for the new version (use the tag value), - instead of using unreleased - --incremental generates changelog from last created version, useful - if the changelog has been manually modified + Set the value for the new version (use the tag value), + instead of using unreleased versions. + --incremental Generate changelog from the last created version, + useful if the changelog has been manually modified. --start-rev START_REV - start rev of the changelog. If not set, it will - generate changelog from the start - --merge-prerelease collect all changes from prereleases into next non- - prerelease. If not set, it will include prereleases in - the changelog + Start rev of the changelog. If not set, it will + generate changelog from the beginning. + --merge-prerelease Collect all changes from prereleases into the next + non-prerelease. If not set, it will include + prereleases in the changelog. --version-scheme {pep440,semver,semver2} - choose version scheme + Choose version scheme. --export-template EXPORT_TEMPLATE Export the changelog template into this file instead - of rendering it + of rendering it. --template TEMPLATE, -t TEMPLATE - changelog template file name (relative to the current - working directory) + Changelog template file name (relative to the current + working directory). --extra EXTRA, -e EXTRA - a changelog extra variable (in the form 'key=value') + Changelog extra variables (in the form 'key=value'). --tag-format TAG_FORMAT - The format of the tag, wrap around simple quotes + The format of the tag, wrap around simple quotes. diff --git a/tests/commands/test_common_command/test_command_shows_description_when_use_help_option_py_3_10_check_.txt b/tests/commands/test_common_command/test_command_shows_description_when_use_help_option_py_3_10_check_.txt index 53c4e7ed10..144e91b61a 100644 --- a/tests/commands/test_common_command/test_command_shows_description_when_use_help_option_py_3_10_check_.txt +++ b/tests/commands/test_common_command/test_command_shows_description_when_use_help_option_py_3_10_check_.txt @@ -3,26 +3,27 @@ usage: cz check [-h] [--allow-abort] [--allowed-prefixes [ALLOWED_PREFIXES ...]] [-l MESSAGE_LENGTH_LIMIT] -validates that a commit message matches the commitizen schema +Validate that a commit message matches the commitizen schema options: -h, --help show this help message and exit --commit-msg-file COMMIT_MSG_FILE - ask for the name of the temporal file that contains - the commit message. Using it in a git hook script: - MSG_FILE=$1 + Ask for the name of the temporary file that contains + the commit message. Use it in a git hook script: + MSG_FILE=$1. --rev-range REV_RANGE - a range of git rev to check. e.g, master..HEAD + Validate the commits in the given range of git rev, + e.g., master..HEAD. -d, --use-default-range - check from the default branch to HEAD. e.g, - refs/remotes/origin/master..HEAD + Validate the commits from the default branch to HEAD, + e.g., refs/remotes/origin/master..HEAD. -m MESSAGE, --message MESSAGE - commit message that needs to be checked - --allow-abort allow empty commit messages, which typically abort a - commit + Validate the given commit message. + --allow-abort Allow empty commit messages, which typically abort a + commit. --allowed-prefixes [ALLOWED_PREFIXES ...] - allowed commit message prefixes. If the message starts - by one of these prefixes, the message won't be checked - against the regex + Skip validation for commit messages that start with + the specified prefixes. -l MESSAGE_LENGTH_LIMIT, --message-length-limit MESSAGE_LENGTH_LIMIT - length limit of the commit message; 0 for no limit + Restrict the length of the **first line** of the + commit message; 0 for no limit. diff --git a/tests/commands/test_common_command/test_command_shows_description_when_use_help_option_py_3_10_commit_.txt b/tests/commands/test_common_command/test_command_shows_description_when_use_help_option_py_3_10_commit_.txt index c842433427..bd256ccf8c 100644 --- a/tests/commands/test_common_command/test_command_shows_description_when_use_help_option_py_3_10_commit_.txt +++ b/tests/commands/test_common_command/test_command_shows_description_when_use_help_option_py_3_10_commit_.txt @@ -2,21 +2,24 @@ usage: cz commit [-h] [--retry] [--no-retry] [--dry-run] [--write-message-to-file FILE_PATH] [-s] [-a] [-e] [-l MESSAGE_LENGTH_LIMIT] [--] -create new commit +Create new commit options: -h, --help show this help message and exit - --retry retry last commit - --no-retry skip retry if retry_after_failure is set to true - --dry-run show output to stdout, no commit, no modified files + --retry Retry the last commit. + --no-retry Skip retry if --retry or `retry_after_failure` is set + to true. + --dry-run Perform a dry run, without committing or modifying + files. --write-message-to-file FILE_PATH - write message to file before committing (can be - combined with --dry-run) - -s, --signoff Deprecated, use 'cz commit -- -s' instead - -a, --all Tell the command to automatically stage files that - have been modified and deleted, but new files you have - not told Git about are not affected. - -e, --edit edit the commit message before committing + Write message to FILE_PATH before committing (can be + used with --dry-run). + -s, --signoff Deprecated, use `cz commit -- -s` instead. + -a, --all Automatically stage files that have been modified and + deleted, but new files you have not told Git about are + not affected. + -e, --edit Edit the commit message before committing. -l MESSAGE_LENGTH_LIMIT, --message-length-limit MESSAGE_LENGTH_LIMIT - length limit of the commit message; 0 for no limit - -- Positional arguments separator (recommended) + Set the length limit of the commit message; 0 for no + limit. + -- Positional arguments separator (recommended). diff --git a/tests/commands/test_common_command/test_command_shows_description_when_use_help_option_py_3_10_example_.txt b/tests/commands/test_common_command/test_command_shows_description_when_use_help_option_py_3_10_example_.txt index b9bf7f84fc..8a0f1c9d94 100644 --- a/tests/commands/test_common_command/test_command_shows_description_when_use_help_option_py_3_10_example_.txt +++ b/tests/commands/test_common_command/test_command_shows_description_when_use_help_option_py_3_10_example_.txt @@ -1,6 +1,6 @@ usage: cz example [-h] -show commit example +Show commit example options: -h, --help show this help message and exit diff --git a/tests/commands/test_common_command/test_command_shows_description_when_use_help_option_py_3_10_info_.txt b/tests/commands/test_common_command/test_command_shows_description_when_use_help_option_py_3_10_info_.txt index 99b1ba8a4a..ed5ae2522e 100644 --- a/tests/commands/test_common_command/test_command_shows_description_when_use_help_option_py_3_10_info_.txt +++ b/tests/commands/test_common_command/test_command_shows_description_when_use_help_option_py_3_10_info_.txt @@ -1,6 +1,6 @@ usage: cz info [-h] -show information about the cz +Show information about the cz options: -h, --help show this help message and exit diff --git a/tests/commands/test_common_command/test_command_shows_description_when_use_help_option_py_3_10_init_.txt b/tests/commands/test_common_command/test_command_shows_description_when_use_help_option_py_3_10_init_.txt index 0f72042f88..546ab51cb3 100644 --- a/tests/commands/test_common_command/test_command_shows_description_when_use_help_option_py_3_10_init_.txt +++ b/tests/commands/test_common_command/test_command_shows_description_when_use_help_option_py_3_10_init_.txt @@ -1,6 +1,6 @@ usage: cz init [-h] -init commitizen configuration +Initialize commitizen configuration options: -h, --help show this help message and exit diff --git a/tests/commands/test_common_command/test_command_shows_description_when_use_help_option_py_3_10_ls_.txt b/tests/commands/test_common_command/test_command_shows_description_when_use_help_option_py_3_10_ls_.txt index 5fa8fe1f79..253da1722c 100644 --- a/tests/commands/test_common_command/test_command_shows_description_when_use_help_option_py_3_10_ls_.txt +++ b/tests/commands/test_common_command/test_command_shows_description_when_use_help_option_py_3_10_ls_.txt @@ -1,6 +1,6 @@ usage: cz ls [-h] -show available commitizens +Show available Commitizens options: -h, --help show this help message and exit diff --git a/tests/commands/test_common_command/test_command_shows_description_when_use_help_option_py_3_10_schema_.txt b/tests/commands/test_common_command/test_command_shows_description_when_use_help_option_py_3_10_schema_.txt index 6666db4d41..dd05ead81b 100644 --- a/tests/commands/test_common_command/test_command_shows_description_when_use_help_option_py_3_10_schema_.txt +++ b/tests/commands/test_common_command/test_command_shows_description_when_use_help_option_py_3_10_schema_.txt @@ -1,6 +1,6 @@ usage: cz schema [-h] -show commit schema +Show commit schema options: -h, --help show this help message and exit diff --git a/tests/commands/test_common_command/test_command_shows_description_when_use_help_option_py_3_10_version_.txt b/tests/commands/test_common_command/test_command_shows_description_when_use_help_option_py_3_10_version_.txt index a194615a98..5085d0fd3c 100644 --- a/tests/commands/test_common_command/test_command_shows_description_when_use_help_option_py_3_10_version_.txt +++ b/tests/commands/test_common_command/test_command_shows_description_when_use_help_option_py_3_10_version_.txt @@ -1,16 +1,18 @@ -usage: cz version [-h] [-r | -p | -c | -v] [--major | --minor] +usage: cz version [-h] [-r | -p | -c | -v] [--major | --minor | --tag] -get the version of the installed commitizen or the current project (default: +Get the version of the installed commitizen or the current project (default: installed commitizen) options: -h, --help show this help message and exit - -r, --report get system information for reporting bugs - -p, --project get the version of the current project - -c, --commitizen get the version of the installed commitizen - -v, --verbose get the version of both the installed commitizen and the - current project - --major get just the major version. Need to be used with --project + -r, --report Output the system information for reporting bugs. + -p, --project Output the version of the current project. + -c, --commitizen Output the version of the installed commitizen. + -v, --verbose Output the version of both the installed commitizen and + the current project. + --major Output just the major version. Must be used with --project or --verbose. - --minor get just the minor version. Need to be used with --project + --minor Output just the minor version. Must be used with --project or --verbose. + --tag get the version with tag prefix. Need to be used with + --project or --verbose. diff --git a/tests/commands/test_common_command/test_command_shows_description_when_use_help_option_py_3_11_bump_.txt b/tests/commands/test_common_command/test_command_shows_description_when_use_help_option_py_3_11_bump_.txt index ad0a693278..d56e739277 100644 --- a/tests/commands/test_common_command/test_command_shows_description_when_use_help_option_py_3_11_bump_.txt +++ b/tests/commands/test_common_command/test_command_shows_description_when_use_help_option_py_3_11_bump_.txt @@ -14,69 +14,71 @@ usage: cz bump [-h] [--dry-run] [--files-only] [--local-version] [--changelog] [--allow-no-commit] [MANUAL_VERSION] -bump semantic version based on the git log +Bump semantic version based on the git log positional arguments: - MANUAL_VERSION bump to the given version (e.g: 1.5.3) + MANUAL_VERSION Bump to the given version (e.g., 1.5.3). options: -h, --help show this help message and exit - --dry-run show output to stdout, no commit, no modified files - --files-only bump version in the files from the config - --local-version bump only the local version portion - --changelog, -ch generate the changelog for the newest version - --no-verify this option bypasses the pre-commit and commit-msg - hooks - --yes accept automatically questions done + --dry-run Perform a dry run, without committing or modifying + files. + --files-only Bump version in the `version_files` specified in the + configuration file only. + --local-version Bump version only the local version portion (ignoring + the public version). + --changelog, -ch Generate the changelog for the latest version. + --no-verify Bypass the pre-commit and commit-msg hooks. + --yes Accept automatically answered questions. --tag-format TAG_FORMAT - the format used to tag the commit and read it, use it - in existing projects, wrap around simple quotes + The format used to tag the commit and read it. Use it + in existing projects, and wrap around simple quotes. --bump-message BUMP_MESSAGE - template used to create the release commit, useful - when working with CI + Template used to create the release commit, useful + when working with CI. --prerelease {alpha,beta,rc}, -pr {alpha,beta,rc} - choose type of prerelease + Type of prerelease. --devrelease DEVRELEASE, -d DEVRELEASE - specify non-negative integer for dev. release + Specify non-negative integer for dev release. --increment {MAJOR,MINOR,PATCH} - manually specify the desired increment + Specify the desired increment. --increment-mode {linear,exact} - set the method by which the new version is chosen. - 'linear' (default) guesses the next version based on - typical linear version progression, such that bumping - of a pre-release with lower precedence than the - current pre-release phase maintains the current phase - of higher precedence. 'exact' applies the changes that + Set the method by which the new version is chosen. + 'linear' (default) resolves the next version based on + typical linear version progression, where bumping of a + pre-release with lower precedence than the current + pre-release phase maintains the current phase of + higher precedence. 'exact' applies the changes that have been specified (or determined from the commit - log) without interpretation, such that the increment - and pre-release are always honored + log) without interpretation, ensuring the increment + and pre-release are always honored. --check-consistency, -cc - check consistency among versions defined in commitizen - configuration and version_files - --annotated-tag, -at create annotated tag instead of lightweight one + Check consistency among versions defined in Commitizen + configuration file and `version_files`. + --annotated-tag, -at Create annotated tag instead of lightweight one. --annotated-tag-message ANNOTATED_TAG_MESSAGE, -atm ANNOTATED_TAG_MESSAGE - create annotated tag message - --gpg-sign, -s sign tag instead of lightweight one + Create annotated tag message. + --gpg-sign, -s Sign tag instead of lightweight one. --changelog-to-stdout - Output changelog to the stdout + Output changelog to stdout. --git-output-to-stderr - Redirect git output to stderr - --retry retry commit if it fails the 1st time - --major-version-zero keep major version at zero, even for breaking changes + Redirect git output to stderr. + --retry Retry commit if it fails for the first time. + --major-version-zero Keep major version at zero, even for breaking changes. --template TEMPLATE, -t TEMPLATE - changelog template file name (relative to the current - working directory) + Changelog template file name (relative to the current + working directory). --extra EXTRA, -e EXTRA - a changelog extra variable (in the form 'key=value') + Changelog extra variables (in the form 'key=value'). --file-name FILE_NAME - file name of changelog (default: 'CHANGELOG.md') + File name of changelog (default: 'CHANGELOG.md'). --prerelease-offset PRERELEASE_OFFSET - start pre-releases with this offset + Start pre-releases with this offset. --version-scheme {pep440,semver,semver2} - choose version scheme + Choose version scheme. --version-type {pep440,semver,semver2} - Deprecated, use --version-scheme instead + Deprecated, use `--version-scheme` instead. --build-metadata BUILD_METADATA - Add additional build-metadata to the version-number - --get-next Determine the next version and write to stdout - --allow-no-commit bump version without eligible commits + Add additional build-metadata to the version-number. + --get-next Determine the next version and write to stdout. + --allow-no-commit Bump version without eligible commits. diff --git a/tests/commands/test_common_command/test_command_shows_description_when_use_help_option_py_3_11_changelog_.txt b/tests/commands/test_common_command/test_command_shows_description_when_use_help_option_py_3_11_changelog_.txt index f4aa1ca2a6..2d1135af74 100644 --- a/tests/commands/test_common_command/test_command_shows_description_when_use_help_option_py_3_11_changelog_.txt +++ b/tests/commands/test_common_command/test_command_shows_description_when_use_help_option_py_3_11_changelog_.txt @@ -6,37 +6,37 @@ usage: cz changelog [-h] [--dry-run] [--file-name FILE_NAME] [--extra EXTRA] [--tag-format TAG_FORMAT] [rev_range] -generate changelog (note that it will overwrite existing file) +Generate changelog (note that it will overwrite existing files) positional arguments: - rev_range generates changelog for the given version (e.g: 1.5.3) - or version range (e.g: 1.5.3..1.7.9) + rev_range Generate changelog for the given version (e.g., 1.5.3) + or version range (e.g., 1.5.3..1.7.9). options: -h, --help show this help message and exit - --dry-run show changelog to stdout + --dry-run Show changelog to stdout. --file-name FILE_NAME - file name of changelog (default: 'CHANGELOG.md') + File name of changelog (default: 'CHANGELOG.md'). --unreleased-version UNRELEASED_VERSION - set the value for the new version (use the tag value), - instead of using unreleased - --incremental generates changelog from last created version, useful - if the changelog has been manually modified + Set the value for the new version (use the tag value), + instead of using unreleased versions. + --incremental Generate changelog from the last created version, + useful if the changelog has been manually modified. --start-rev START_REV - start rev of the changelog. If not set, it will - generate changelog from the start - --merge-prerelease collect all changes from prereleases into next non- - prerelease. If not set, it will include prereleases in - the changelog + Start rev of the changelog. If not set, it will + generate changelog from the beginning. + --merge-prerelease Collect all changes from prereleases into the next + non-prerelease. If not set, it will include + prereleases in the changelog. --version-scheme {pep440,semver,semver2} - choose version scheme + Choose version scheme. --export-template EXPORT_TEMPLATE Export the changelog template into this file instead - of rendering it + of rendering it. --template TEMPLATE, -t TEMPLATE - changelog template file name (relative to the current - working directory) + Changelog template file name (relative to the current + working directory). --extra EXTRA, -e EXTRA - a changelog extra variable (in the form 'key=value') + Changelog extra variables (in the form 'key=value'). --tag-format TAG_FORMAT - The format of the tag, wrap around simple quotes + The format of the tag, wrap around simple quotes. diff --git a/tests/commands/test_common_command/test_command_shows_description_when_use_help_option_py_3_11_check_.txt b/tests/commands/test_common_command/test_command_shows_description_when_use_help_option_py_3_11_check_.txt index 53c4e7ed10..144e91b61a 100644 --- a/tests/commands/test_common_command/test_command_shows_description_when_use_help_option_py_3_11_check_.txt +++ b/tests/commands/test_common_command/test_command_shows_description_when_use_help_option_py_3_11_check_.txt @@ -3,26 +3,27 @@ usage: cz check [-h] [--allow-abort] [--allowed-prefixes [ALLOWED_PREFIXES ...]] [-l MESSAGE_LENGTH_LIMIT] -validates that a commit message matches the commitizen schema +Validate that a commit message matches the commitizen schema options: -h, --help show this help message and exit --commit-msg-file COMMIT_MSG_FILE - ask for the name of the temporal file that contains - the commit message. Using it in a git hook script: - MSG_FILE=$1 + Ask for the name of the temporary file that contains + the commit message. Use it in a git hook script: + MSG_FILE=$1. --rev-range REV_RANGE - a range of git rev to check. e.g, master..HEAD + Validate the commits in the given range of git rev, + e.g., master..HEAD. -d, --use-default-range - check from the default branch to HEAD. e.g, - refs/remotes/origin/master..HEAD + Validate the commits from the default branch to HEAD, + e.g., refs/remotes/origin/master..HEAD. -m MESSAGE, --message MESSAGE - commit message that needs to be checked - --allow-abort allow empty commit messages, which typically abort a - commit + Validate the given commit message. + --allow-abort Allow empty commit messages, which typically abort a + commit. --allowed-prefixes [ALLOWED_PREFIXES ...] - allowed commit message prefixes. If the message starts - by one of these prefixes, the message won't be checked - against the regex + Skip validation for commit messages that start with + the specified prefixes. -l MESSAGE_LENGTH_LIMIT, --message-length-limit MESSAGE_LENGTH_LIMIT - length limit of the commit message; 0 for no limit + Restrict the length of the **first line** of the + commit message; 0 for no limit. diff --git a/tests/commands/test_common_command/test_command_shows_description_when_use_help_option_py_3_11_commit_.txt b/tests/commands/test_common_command/test_command_shows_description_when_use_help_option_py_3_11_commit_.txt index c842433427..bd256ccf8c 100644 --- a/tests/commands/test_common_command/test_command_shows_description_when_use_help_option_py_3_11_commit_.txt +++ b/tests/commands/test_common_command/test_command_shows_description_when_use_help_option_py_3_11_commit_.txt @@ -2,21 +2,24 @@ usage: cz commit [-h] [--retry] [--no-retry] [--dry-run] [--write-message-to-file FILE_PATH] [-s] [-a] [-e] [-l MESSAGE_LENGTH_LIMIT] [--] -create new commit +Create new commit options: -h, --help show this help message and exit - --retry retry last commit - --no-retry skip retry if retry_after_failure is set to true - --dry-run show output to stdout, no commit, no modified files + --retry Retry the last commit. + --no-retry Skip retry if --retry or `retry_after_failure` is set + to true. + --dry-run Perform a dry run, without committing or modifying + files. --write-message-to-file FILE_PATH - write message to file before committing (can be - combined with --dry-run) - -s, --signoff Deprecated, use 'cz commit -- -s' instead - -a, --all Tell the command to automatically stage files that - have been modified and deleted, but new files you have - not told Git about are not affected. - -e, --edit edit the commit message before committing + Write message to FILE_PATH before committing (can be + used with --dry-run). + -s, --signoff Deprecated, use `cz commit -- -s` instead. + -a, --all Automatically stage files that have been modified and + deleted, but new files you have not told Git about are + not affected. + -e, --edit Edit the commit message before committing. -l MESSAGE_LENGTH_LIMIT, --message-length-limit MESSAGE_LENGTH_LIMIT - length limit of the commit message; 0 for no limit - -- Positional arguments separator (recommended) + Set the length limit of the commit message; 0 for no + limit. + -- Positional arguments separator (recommended). diff --git a/tests/commands/test_common_command/test_command_shows_description_when_use_help_option_py_3_11_example_.txt b/tests/commands/test_common_command/test_command_shows_description_when_use_help_option_py_3_11_example_.txt index b9bf7f84fc..8a0f1c9d94 100644 --- a/tests/commands/test_common_command/test_command_shows_description_when_use_help_option_py_3_11_example_.txt +++ b/tests/commands/test_common_command/test_command_shows_description_when_use_help_option_py_3_11_example_.txt @@ -1,6 +1,6 @@ usage: cz example [-h] -show commit example +Show commit example options: -h, --help show this help message and exit diff --git a/tests/commands/test_common_command/test_command_shows_description_when_use_help_option_py_3_11_info_.txt b/tests/commands/test_common_command/test_command_shows_description_when_use_help_option_py_3_11_info_.txt index 99b1ba8a4a..ed5ae2522e 100644 --- a/tests/commands/test_common_command/test_command_shows_description_when_use_help_option_py_3_11_info_.txt +++ b/tests/commands/test_common_command/test_command_shows_description_when_use_help_option_py_3_11_info_.txt @@ -1,6 +1,6 @@ usage: cz info [-h] -show information about the cz +Show information about the cz options: -h, --help show this help message and exit diff --git a/tests/commands/test_common_command/test_command_shows_description_when_use_help_option_py_3_11_init_.txt b/tests/commands/test_common_command/test_command_shows_description_when_use_help_option_py_3_11_init_.txt index 0f72042f88..546ab51cb3 100644 --- a/tests/commands/test_common_command/test_command_shows_description_when_use_help_option_py_3_11_init_.txt +++ b/tests/commands/test_common_command/test_command_shows_description_when_use_help_option_py_3_11_init_.txt @@ -1,6 +1,6 @@ usage: cz init [-h] -init commitizen configuration +Initialize commitizen configuration options: -h, --help show this help message and exit diff --git a/tests/commands/test_common_command/test_command_shows_description_when_use_help_option_py_3_11_ls_.txt b/tests/commands/test_common_command/test_command_shows_description_when_use_help_option_py_3_11_ls_.txt index 5fa8fe1f79..253da1722c 100644 --- a/tests/commands/test_common_command/test_command_shows_description_when_use_help_option_py_3_11_ls_.txt +++ b/tests/commands/test_common_command/test_command_shows_description_when_use_help_option_py_3_11_ls_.txt @@ -1,6 +1,6 @@ usage: cz ls [-h] -show available commitizens +Show available Commitizens options: -h, --help show this help message and exit diff --git a/tests/commands/test_common_command/test_command_shows_description_when_use_help_option_py_3_11_schema_.txt b/tests/commands/test_common_command/test_command_shows_description_when_use_help_option_py_3_11_schema_.txt index 6666db4d41..dd05ead81b 100644 --- a/tests/commands/test_common_command/test_command_shows_description_when_use_help_option_py_3_11_schema_.txt +++ b/tests/commands/test_common_command/test_command_shows_description_when_use_help_option_py_3_11_schema_.txt @@ -1,6 +1,6 @@ usage: cz schema [-h] -show commit schema +Show commit schema options: -h, --help show this help message and exit diff --git a/tests/commands/test_common_command/test_command_shows_description_when_use_help_option_py_3_11_version_.txt b/tests/commands/test_common_command/test_command_shows_description_when_use_help_option_py_3_11_version_.txt index a194615a98..5085d0fd3c 100644 --- a/tests/commands/test_common_command/test_command_shows_description_when_use_help_option_py_3_11_version_.txt +++ b/tests/commands/test_common_command/test_command_shows_description_when_use_help_option_py_3_11_version_.txt @@ -1,16 +1,18 @@ -usage: cz version [-h] [-r | -p | -c | -v] [--major | --minor] +usage: cz version [-h] [-r | -p | -c | -v] [--major | --minor | --tag] -get the version of the installed commitizen or the current project (default: +Get the version of the installed commitizen or the current project (default: installed commitizen) options: -h, --help show this help message and exit - -r, --report get system information for reporting bugs - -p, --project get the version of the current project - -c, --commitizen get the version of the installed commitizen - -v, --verbose get the version of both the installed commitizen and the - current project - --major get just the major version. Need to be used with --project + -r, --report Output the system information for reporting bugs. + -p, --project Output the version of the current project. + -c, --commitizen Output the version of the installed commitizen. + -v, --verbose Output the version of both the installed commitizen and + the current project. + --major Output just the major version. Must be used with --project or --verbose. - --minor get just the minor version. Need to be used with --project + --minor Output just the minor version. Must be used with --project or --verbose. + --tag get the version with tag prefix. Need to be used with + --project or --verbose. diff --git a/tests/commands/test_common_command/test_command_shows_description_when_use_help_option_py_3_12_bump_.txt b/tests/commands/test_common_command/test_command_shows_description_when_use_help_option_py_3_12_bump_.txt index ad0a693278..d56e739277 100644 --- a/tests/commands/test_common_command/test_command_shows_description_when_use_help_option_py_3_12_bump_.txt +++ b/tests/commands/test_common_command/test_command_shows_description_when_use_help_option_py_3_12_bump_.txt @@ -14,69 +14,71 @@ usage: cz bump [-h] [--dry-run] [--files-only] [--local-version] [--changelog] [--allow-no-commit] [MANUAL_VERSION] -bump semantic version based on the git log +Bump semantic version based on the git log positional arguments: - MANUAL_VERSION bump to the given version (e.g: 1.5.3) + MANUAL_VERSION Bump to the given version (e.g., 1.5.3). options: -h, --help show this help message and exit - --dry-run show output to stdout, no commit, no modified files - --files-only bump version in the files from the config - --local-version bump only the local version portion - --changelog, -ch generate the changelog for the newest version - --no-verify this option bypasses the pre-commit and commit-msg - hooks - --yes accept automatically questions done + --dry-run Perform a dry run, without committing or modifying + files. + --files-only Bump version in the `version_files` specified in the + configuration file only. + --local-version Bump version only the local version portion (ignoring + the public version). + --changelog, -ch Generate the changelog for the latest version. + --no-verify Bypass the pre-commit and commit-msg hooks. + --yes Accept automatically answered questions. --tag-format TAG_FORMAT - the format used to tag the commit and read it, use it - in existing projects, wrap around simple quotes + The format used to tag the commit and read it. Use it + in existing projects, and wrap around simple quotes. --bump-message BUMP_MESSAGE - template used to create the release commit, useful - when working with CI + Template used to create the release commit, useful + when working with CI. --prerelease {alpha,beta,rc}, -pr {alpha,beta,rc} - choose type of prerelease + Type of prerelease. --devrelease DEVRELEASE, -d DEVRELEASE - specify non-negative integer for dev. release + Specify non-negative integer for dev release. --increment {MAJOR,MINOR,PATCH} - manually specify the desired increment + Specify the desired increment. --increment-mode {linear,exact} - set the method by which the new version is chosen. - 'linear' (default) guesses the next version based on - typical linear version progression, such that bumping - of a pre-release with lower precedence than the - current pre-release phase maintains the current phase - of higher precedence. 'exact' applies the changes that + Set the method by which the new version is chosen. + 'linear' (default) resolves the next version based on + typical linear version progression, where bumping of a + pre-release with lower precedence than the current + pre-release phase maintains the current phase of + higher precedence. 'exact' applies the changes that have been specified (or determined from the commit - log) without interpretation, such that the increment - and pre-release are always honored + log) without interpretation, ensuring the increment + and pre-release are always honored. --check-consistency, -cc - check consistency among versions defined in commitizen - configuration and version_files - --annotated-tag, -at create annotated tag instead of lightweight one + Check consistency among versions defined in Commitizen + configuration file and `version_files`. + --annotated-tag, -at Create annotated tag instead of lightweight one. --annotated-tag-message ANNOTATED_TAG_MESSAGE, -atm ANNOTATED_TAG_MESSAGE - create annotated tag message - --gpg-sign, -s sign tag instead of lightweight one + Create annotated tag message. + --gpg-sign, -s Sign tag instead of lightweight one. --changelog-to-stdout - Output changelog to the stdout + Output changelog to stdout. --git-output-to-stderr - Redirect git output to stderr - --retry retry commit if it fails the 1st time - --major-version-zero keep major version at zero, even for breaking changes + Redirect git output to stderr. + --retry Retry commit if it fails for the first time. + --major-version-zero Keep major version at zero, even for breaking changes. --template TEMPLATE, -t TEMPLATE - changelog template file name (relative to the current - working directory) + Changelog template file name (relative to the current + working directory). --extra EXTRA, -e EXTRA - a changelog extra variable (in the form 'key=value') + Changelog extra variables (in the form 'key=value'). --file-name FILE_NAME - file name of changelog (default: 'CHANGELOG.md') + File name of changelog (default: 'CHANGELOG.md'). --prerelease-offset PRERELEASE_OFFSET - start pre-releases with this offset + Start pre-releases with this offset. --version-scheme {pep440,semver,semver2} - choose version scheme + Choose version scheme. --version-type {pep440,semver,semver2} - Deprecated, use --version-scheme instead + Deprecated, use `--version-scheme` instead. --build-metadata BUILD_METADATA - Add additional build-metadata to the version-number - --get-next Determine the next version and write to stdout - --allow-no-commit bump version without eligible commits + Add additional build-metadata to the version-number. + --get-next Determine the next version and write to stdout. + --allow-no-commit Bump version without eligible commits. diff --git a/tests/commands/test_common_command/test_command_shows_description_when_use_help_option_py_3_12_changelog_.txt b/tests/commands/test_common_command/test_command_shows_description_when_use_help_option_py_3_12_changelog_.txt index f4aa1ca2a6..2d1135af74 100644 --- a/tests/commands/test_common_command/test_command_shows_description_when_use_help_option_py_3_12_changelog_.txt +++ b/tests/commands/test_common_command/test_command_shows_description_when_use_help_option_py_3_12_changelog_.txt @@ -6,37 +6,37 @@ usage: cz changelog [-h] [--dry-run] [--file-name FILE_NAME] [--extra EXTRA] [--tag-format TAG_FORMAT] [rev_range] -generate changelog (note that it will overwrite existing file) +Generate changelog (note that it will overwrite existing files) positional arguments: - rev_range generates changelog for the given version (e.g: 1.5.3) - or version range (e.g: 1.5.3..1.7.9) + rev_range Generate changelog for the given version (e.g., 1.5.3) + or version range (e.g., 1.5.3..1.7.9). options: -h, --help show this help message and exit - --dry-run show changelog to stdout + --dry-run Show changelog to stdout. --file-name FILE_NAME - file name of changelog (default: 'CHANGELOG.md') + File name of changelog (default: 'CHANGELOG.md'). --unreleased-version UNRELEASED_VERSION - set the value for the new version (use the tag value), - instead of using unreleased - --incremental generates changelog from last created version, useful - if the changelog has been manually modified + Set the value for the new version (use the tag value), + instead of using unreleased versions. + --incremental Generate changelog from the last created version, + useful if the changelog has been manually modified. --start-rev START_REV - start rev of the changelog. If not set, it will - generate changelog from the start - --merge-prerelease collect all changes from prereleases into next non- - prerelease. If not set, it will include prereleases in - the changelog + Start rev of the changelog. If not set, it will + generate changelog from the beginning. + --merge-prerelease Collect all changes from prereleases into the next + non-prerelease. If not set, it will include + prereleases in the changelog. --version-scheme {pep440,semver,semver2} - choose version scheme + Choose version scheme. --export-template EXPORT_TEMPLATE Export the changelog template into this file instead - of rendering it + of rendering it. --template TEMPLATE, -t TEMPLATE - changelog template file name (relative to the current - working directory) + Changelog template file name (relative to the current + working directory). --extra EXTRA, -e EXTRA - a changelog extra variable (in the form 'key=value') + Changelog extra variables (in the form 'key=value'). --tag-format TAG_FORMAT - The format of the tag, wrap around simple quotes + The format of the tag, wrap around simple quotes. diff --git a/tests/commands/test_common_command/test_command_shows_description_when_use_help_option_py_3_12_check_.txt b/tests/commands/test_common_command/test_command_shows_description_when_use_help_option_py_3_12_check_.txt index 53c4e7ed10..144e91b61a 100644 --- a/tests/commands/test_common_command/test_command_shows_description_when_use_help_option_py_3_12_check_.txt +++ b/tests/commands/test_common_command/test_command_shows_description_when_use_help_option_py_3_12_check_.txt @@ -3,26 +3,27 @@ usage: cz check [-h] [--allow-abort] [--allowed-prefixes [ALLOWED_PREFIXES ...]] [-l MESSAGE_LENGTH_LIMIT] -validates that a commit message matches the commitizen schema +Validate that a commit message matches the commitizen schema options: -h, --help show this help message and exit --commit-msg-file COMMIT_MSG_FILE - ask for the name of the temporal file that contains - the commit message. Using it in a git hook script: - MSG_FILE=$1 + Ask for the name of the temporary file that contains + the commit message. Use it in a git hook script: + MSG_FILE=$1. --rev-range REV_RANGE - a range of git rev to check. e.g, master..HEAD + Validate the commits in the given range of git rev, + e.g., master..HEAD. -d, --use-default-range - check from the default branch to HEAD. e.g, - refs/remotes/origin/master..HEAD + Validate the commits from the default branch to HEAD, + e.g., refs/remotes/origin/master..HEAD. -m MESSAGE, --message MESSAGE - commit message that needs to be checked - --allow-abort allow empty commit messages, which typically abort a - commit + Validate the given commit message. + --allow-abort Allow empty commit messages, which typically abort a + commit. --allowed-prefixes [ALLOWED_PREFIXES ...] - allowed commit message prefixes. If the message starts - by one of these prefixes, the message won't be checked - against the regex + Skip validation for commit messages that start with + the specified prefixes. -l MESSAGE_LENGTH_LIMIT, --message-length-limit MESSAGE_LENGTH_LIMIT - length limit of the commit message; 0 for no limit + Restrict the length of the **first line** of the + commit message; 0 for no limit. diff --git a/tests/commands/test_common_command/test_command_shows_description_when_use_help_option_py_3_12_commit_.txt b/tests/commands/test_common_command/test_command_shows_description_when_use_help_option_py_3_12_commit_.txt index c842433427..bd256ccf8c 100644 --- a/tests/commands/test_common_command/test_command_shows_description_when_use_help_option_py_3_12_commit_.txt +++ b/tests/commands/test_common_command/test_command_shows_description_when_use_help_option_py_3_12_commit_.txt @@ -2,21 +2,24 @@ usage: cz commit [-h] [--retry] [--no-retry] [--dry-run] [--write-message-to-file FILE_PATH] [-s] [-a] [-e] [-l MESSAGE_LENGTH_LIMIT] [--] -create new commit +Create new commit options: -h, --help show this help message and exit - --retry retry last commit - --no-retry skip retry if retry_after_failure is set to true - --dry-run show output to stdout, no commit, no modified files + --retry Retry the last commit. + --no-retry Skip retry if --retry or `retry_after_failure` is set + to true. + --dry-run Perform a dry run, without committing or modifying + files. --write-message-to-file FILE_PATH - write message to file before committing (can be - combined with --dry-run) - -s, --signoff Deprecated, use 'cz commit -- -s' instead - -a, --all Tell the command to automatically stage files that - have been modified and deleted, but new files you have - not told Git about are not affected. - -e, --edit edit the commit message before committing + Write message to FILE_PATH before committing (can be + used with --dry-run). + -s, --signoff Deprecated, use `cz commit -- -s` instead. + -a, --all Automatically stage files that have been modified and + deleted, but new files you have not told Git about are + not affected. + -e, --edit Edit the commit message before committing. -l MESSAGE_LENGTH_LIMIT, --message-length-limit MESSAGE_LENGTH_LIMIT - length limit of the commit message; 0 for no limit - -- Positional arguments separator (recommended) + Set the length limit of the commit message; 0 for no + limit. + -- Positional arguments separator (recommended). diff --git a/tests/commands/test_common_command/test_command_shows_description_when_use_help_option_py_3_12_example_.txt b/tests/commands/test_common_command/test_command_shows_description_when_use_help_option_py_3_12_example_.txt index b9bf7f84fc..8a0f1c9d94 100644 --- a/tests/commands/test_common_command/test_command_shows_description_when_use_help_option_py_3_12_example_.txt +++ b/tests/commands/test_common_command/test_command_shows_description_when_use_help_option_py_3_12_example_.txt @@ -1,6 +1,6 @@ usage: cz example [-h] -show commit example +Show commit example options: -h, --help show this help message and exit diff --git a/tests/commands/test_common_command/test_command_shows_description_when_use_help_option_py_3_12_info_.txt b/tests/commands/test_common_command/test_command_shows_description_when_use_help_option_py_3_12_info_.txt index 99b1ba8a4a..ed5ae2522e 100644 --- a/tests/commands/test_common_command/test_command_shows_description_when_use_help_option_py_3_12_info_.txt +++ b/tests/commands/test_common_command/test_command_shows_description_when_use_help_option_py_3_12_info_.txt @@ -1,6 +1,6 @@ usage: cz info [-h] -show information about the cz +Show information about the cz options: -h, --help show this help message and exit diff --git a/tests/commands/test_common_command/test_command_shows_description_when_use_help_option_py_3_12_init_.txt b/tests/commands/test_common_command/test_command_shows_description_when_use_help_option_py_3_12_init_.txt index 0f72042f88..546ab51cb3 100644 --- a/tests/commands/test_common_command/test_command_shows_description_when_use_help_option_py_3_12_init_.txt +++ b/tests/commands/test_common_command/test_command_shows_description_when_use_help_option_py_3_12_init_.txt @@ -1,6 +1,6 @@ usage: cz init [-h] -init commitizen configuration +Initialize commitizen configuration options: -h, --help show this help message and exit diff --git a/tests/commands/test_common_command/test_command_shows_description_when_use_help_option_py_3_12_ls_.txt b/tests/commands/test_common_command/test_command_shows_description_when_use_help_option_py_3_12_ls_.txt index 5fa8fe1f79..253da1722c 100644 --- a/tests/commands/test_common_command/test_command_shows_description_when_use_help_option_py_3_12_ls_.txt +++ b/tests/commands/test_common_command/test_command_shows_description_when_use_help_option_py_3_12_ls_.txt @@ -1,6 +1,6 @@ usage: cz ls [-h] -show available commitizens +Show available Commitizens options: -h, --help show this help message and exit diff --git a/tests/commands/test_common_command/test_command_shows_description_when_use_help_option_py_3_12_schema_.txt b/tests/commands/test_common_command/test_command_shows_description_when_use_help_option_py_3_12_schema_.txt index 6666db4d41..dd05ead81b 100644 --- a/tests/commands/test_common_command/test_command_shows_description_when_use_help_option_py_3_12_schema_.txt +++ b/tests/commands/test_common_command/test_command_shows_description_when_use_help_option_py_3_12_schema_.txt @@ -1,6 +1,6 @@ usage: cz schema [-h] -show commit schema +Show commit schema options: -h, --help show this help message and exit diff --git a/tests/commands/test_common_command/test_command_shows_description_when_use_help_option_py_3_12_version_.txt b/tests/commands/test_common_command/test_command_shows_description_when_use_help_option_py_3_12_version_.txt index a194615a98..5085d0fd3c 100644 --- a/tests/commands/test_common_command/test_command_shows_description_when_use_help_option_py_3_12_version_.txt +++ b/tests/commands/test_common_command/test_command_shows_description_when_use_help_option_py_3_12_version_.txt @@ -1,16 +1,18 @@ -usage: cz version [-h] [-r | -p | -c | -v] [--major | --minor] +usage: cz version [-h] [-r | -p | -c | -v] [--major | --minor | --tag] -get the version of the installed commitizen or the current project (default: +Get the version of the installed commitizen or the current project (default: installed commitizen) options: -h, --help show this help message and exit - -r, --report get system information for reporting bugs - -p, --project get the version of the current project - -c, --commitizen get the version of the installed commitizen - -v, --verbose get the version of both the installed commitizen and the - current project - --major get just the major version. Need to be used with --project + -r, --report Output the system information for reporting bugs. + -p, --project Output the version of the current project. + -c, --commitizen Output the version of the installed commitizen. + -v, --verbose Output the version of both the installed commitizen and + the current project. + --major Output just the major version. Must be used with --project or --verbose. - --minor get just the minor version. Need to be used with --project + --minor Output just the minor version. Must be used with --project or --verbose. + --tag get the version with tag prefix. Need to be used with + --project or --verbose. diff --git a/tests/commands/test_common_command/test_command_shows_description_when_use_help_option_py_3_13_bump_.txt b/tests/commands/test_common_command/test_command_shows_description_when_use_help_option_py_3_13_bump_.txt index 4cf8e6c91b..c472a040e9 100644 --- a/tests/commands/test_common_command/test_command_shows_description_when_use_help_option_py_3_13_bump_.txt +++ b/tests/commands/test_common_command/test_command_shows_description_when_use_help_option_py_3_13_bump_.txt @@ -14,68 +14,70 @@ usage: cz bump [-h] [--dry-run] [--files-only] [--local-version] [--changelog] [--allow-no-commit] [MANUAL_VERSION] -bump semantic version based on the git log +Bump semantic version based on the git log positional arguments: - MANUAL_VERSION bump to the given version (e.g: 1.5.3) + MANUAL_VERSION Bump to the given version (e.g., 1.5.3). options: -h, --help show this help message and exit - --dry-run show output to stdout, no commit, no modified files - --files-only bump version in the files from the config - --local-version bump only the local version portion - --changelog, -ch generate the changelog for the newest version - --no-verify this option bypasses the pre-commit and commit-msg - hooks - --yes accept automatically questions done + --dry-run Perform a dry run, without committing or modifying + files. + --files-only Bump version in the `version_files` specified in the + configuration file only. + --local-version Bump version only the local version portion (ignoring + the public version). + --changelog, -ch Generate the changelog for the latest version. + --no-verify Bypass the pre-commit and commit-msg hooks. + --yes Accept automatically answered questions. --tag-format TAG_FORMAT - the format used to tag the commit and read it, use it - in existing projects, wrap around simple quotes + The format used to tag the commit and read it. Use it + in existing projects, and wrap around simple quotes. --bump-message BUMP_MESSAGE - template used to create the release commit, useful - when working with CI + Template used to create the release commit, useful + when working with CI. --prerelease, -pr {alpha,beta,rc} - choose type of prerelease + Type of prerelease. --devrelease, -d DEVRELEASE - specify non-negative integer for dev. release + Specify non-negative integer for dev release. --increment {MAJOR,MINOR,PATCH} - manually specify the desired increment + Specify the desired increment. --increment-mode {linear,exact} - set the method by which the new version is chosen. - 'linear' (default) guesses the next version based on - typical linear version progression, such that bumping - of a pre-release with lower precedence than the - current pre-release phase maintains the current phase - of higher precedence. 'exact' applies the changes that + Set the method by which the new version is chosen. + 'linear' (default) resolves the next version based on + typical linear version progression, where bumping of a + pre-release with lower precedence than the current + pre-release phase maintains the current phase of + higher precedence. 'exact' applies the changes that have been specified (or determined from the commit - log) without interpretation, such that the increment - and pre-release are always honored + log) without interpretation, ensuring the increment + and pre-release are always honored. --check-consistency, -cc - check consistency among versions defined in commitizen - configuration and version_files - --annotated-tag, -at create annotated tag instead of lightweight one + Check consistency among versions defined in Commitizen + configuration file and `version_files`. + --annotated-tag, -at Create annotated tag instead of lightweight one. --annotated-tag-message, -atm ANNOTATED_TAG_MESSAGE - create annotated tag message - --gpg-sign, -s sign tag instead of lightweight one + Create annotated tag message. + --gpg-sign, -s Sign tag instead of lightweight one. --changelog-to-stdout - Output changelog to the stdout + Output changelog to stdout. --git-output-to-stderr - Redirect git output to stderr - --retry retry commit if it fails the 1st time - --major-version-zero keep major version at zero, even for breaking changes + Redirect git output to stderr. + --retry Retry commit if it fails for the first time. + --major-version-zero Keep major version at zero, even for breaking changes. --template, -t TEMPLATE - changelog template file name (relative to the current - working directory) - --extra, -e EXTRA a changelog extra variable (in the form 'key=value') + Changelog template file name (relative to the current + working directory). + --extra, -e EXTRA Changelog extra variables (in the form 'key=value'). --file-name FILE_NAME - file name of changelog (default: 'CHANGELOG.md') + File name of changelog (default: 'CHANGELOG.md'). --prerelease-offset PRERELEASE_OFFSET - start pre-releases with this offset + Start pre-releases with this offset. --version-scheme {pep440,semver,semver2} - choose version scheme + Choose version scheme. --version-type {pep440,semver,semver2} - Deprecated, use --version-scheme instead + Deprecated, use `--version-scheme` instead. --build-metadata BUILD_METADATA - Add additional build-metadata to the version-number - --get-next Determine the next version and write to stdout - --allow-no-commit bump version without eligible commits + Add additional build-metadata to the version-number. + --get-next Determine the next version and write to stdout. + --allow-no-commit Bump version without eligible commits. diff --git a/tests/commands/test_common_command/test_command_shows_description_when_use_help_option_py_3_13_changelog_.txt b/tests/commands/test_common_command/test_command_shows_description_when_use_help_option_py_3_13_changelog_.txt index 91b7f389b5..50ab468d64 100644 --- a/tests/commands/test_common_command/test_command_shows_description_when_use_help_option_py_3_13_changelog_.txt +++ b/tests/commands/test_common_command/test_command_shows_description_when_use_help_option_py_3_13_changelog_.txt @@ -6,36 +6,36 @@ usage: cz changelog [-h] [--dry-run] [--file-name FILE_NAME] [--extra EXTRA] [--tag-format TAG_FORMAT] [rev_range] -generate changelog (note that it will overwrite existing file) +Generate changelog (note that it will overwrite existing files) positional arguments: - rev_range generates changelog for the given version (e.g: 1.5.3) - or version range (e.g: 1.5.3..1.7.9) + rev_range Generate changelog for the given version (e.g., 1.5.3) + or version range (e.g., 1.5.3..1.7.9). options: -h, --help show this help message and exit - --dry-run show changelog to stdout + --dry-run Show changelog to stdout. --file-name FILE_NAME - file name of changelog (default: 'CHANGELOG.md') + File name of changelog (default: 'CHANGELOG.md'). --unreleased-version UNRELEASED_VERSION - set the value for the new version (use the tag value), - instead of using unreleased - --incremental generates changelog from last created version, useful - if the changelog has been manually modified + Set the value for the new version (use the tag value), + instead of using unreleased versions. + --incremental Generate changelog from the last created version, + useful if the changelog has been manually modified. --start-rev START_REV - start rev of the changelog. If not set, it will - generate changelog from the start - --merge-prerelease collect all changes from prereleases into next non- - prerelease. If not set, it will include prereleases in - the changelog + Start rev of the changelog. If not set, it will + generate changelog from the beginning. + --merge-prerelease Collect all changes from prereleases into the next + non-prerelease. If not set, it will include + prereleases in the changelog. --version-scheme {pep440,semver,semver2} - choose version scheme + Choose version scheme. --export-template EXPORT_TEMPLATE Export the changelog template into this file instead - of rendering it + of rendering it. --template, -t TEMPLATE - changelog template file name (relative to the current - working directory) - --extra, -e EXTRA a changelog extra variable (in the form 'key=value') + Changelog template file name (relative to the current + working directory). + --extra, -e EXTRA Changelog extra variables (in the form 'key=value'). --tag-format TAG_FORMAT - The format of the tag, wrap around simple quotes + The format of the tag, wrap around simple quotes. diff --git a/tests/commands/test_common_command/test_command_shows_description_when_use_help_option_py_3_13_check_.txt b/tests/commands/test_common_command/test_command_shows_description_when_use_help_option_py_3_13_check_.txt index 4066748557..6f8297e1ee 100644 --- a/tests/commands/test_common_command/test_command_shows_description_when_use_help_option_py_3_13_check_.txt +++ b/tests/commands/test_common_command/test_command_shows_description_when_use_help_option_py_3_13_check_.txt @@ -3,26 +3,27 @@ usage: cz check [-h] [--commit-msg-file COMMIT_MSG_FILE | [--allowed-prefixes [ALLOWED_PREFIXES ...]] [-l MESSAGE_LENGTH_LIMIT] -validates that a commit message matches the commitizen schema +Validate that a commit message matches the commitizen schema options: -h, --help show this help message and exit --commit-msg-file COMMIT_MSG_FILE - ask for the name of the temporal file that contains - the commit message. Using it in a git hook script: - MSG_FILE=$1 + Ask for the name of the temporary file that contains + the commit message. Use it in a git hook script: + MSG_FILE=$1. --rev-range REV_RANGE - a range of git rev to check. e.g, master..HEAD + Validate the commits in the given range of git rev, + e.g., master..HEAD. -d, --use-default-range - check from the default branch to HEAD. e.g, - refs/remotes/origin/master..HEAD + Validate the commits from the default branch to HEAD, + e.g., refs/remotes/origin/master..HEAD. -m, --message MESSAGE - commit message that needs to be checked - --allow-abort allow empty commit messages, which typically abort a - commit + Validate the given commit message. + --allow-abort Allow empty commit messages, which typically abort a + commit. --allowed-prefixes [ALLOWED_PREFIXES ...] - allowed commit message prefixes. If the message starts - by one of these prefixes, the message won't be checked - against the regex + Skip validation for commit messages that start with + the specified prefixes. -l, --message-length-limit MESSAGE_LENGTH_LIMIT - length limit of the commit message; 0 for no limit + Restrict the length of the **first line** of the + commit message; 0 for no limit. diff --git a/tests/commands/test_common_command/test_command_shows_description_when_use_help_option_py_3_13_commit_.txt b/tests/commands/test_common_command/test_command_shows_description_when_use_help_option_py_3_13_commit_.txt index ba531042aa..cbd5780f6d 100644 --- a/tests/commands/test_common_command/test_command_shows_description_when_use_help_option_py_3_13_commit_.txt +++ b/tests/commands/test_common_command/test_command_shows_description_when_use_help_option_py_3_13_commit_.txt @@ -2,21 +2,24 @@ usage: cz commit [-h] [--retry] [--no-retry] [--dry-run] [--write-message-to-file FILE_PATH] [-s] [-a] [-e] [-l MESSAGE_LENGTH_LIMIT] [--] -create new commit +Create new commit options: -h, --help show this help message and exit - --retry retry last commit - --no-retry skip retry if retry_after_failure is set to true - --dry-run show output to stdout, no commit, no modified files + --retry Retry the last commit. + --no-retry Skip retry if --retry or `retry_after_failure` is set + to true. + --dry-run Perform a dry run, without committing or modifying + files. --write-message-to-file FILE_PATH - write message to file before committing (can be - combined with --dry-run) - -s, --signoff Deprecated, use 'cz commit -- -s' instead - -a, --all Tell the command to automatically stage files that - have been modified and deleted, but new files you have - not told Git about are not affected. - -e, --edit edit the commit message before committing + Write message to FILE_PATH before committing (can be + used with --dry-run). + -s, --signoff Deprecated, use `cz commit -- -s` instead. + -a, --all Automatically stage files that have been modified and + deleted, but new files you have not told Git about are + not affected. + -e, --edit Edit the commit message before committing. -l, --message-length-limit MESSAGE_LENGTH_LIMIT - length limit of the commit message; 0 for no limit - -- Positional arguments separator (recommended) + Set the length limit of the commit message; 0 for no + limit. + -- Positional arguments separator (recommended). diff --git a/tests/commands/test_common_command/test_command_shows_description_when_use_help_option_py_3_13_example_.txt b/tests/commands/test_common_command/test_command_shows_description_when_use_help_option_py_3_13_example_.txt index b9bf7f84fc..8a0f1c9d94 100644 --- a/tests/commands/test_common_command/test_command_shows_description_when_use_help_option_py_3_13_example_.txt +++ b/tests/commands/test_common_command/test_command_shows_description_when_use_help_option_py_3_13_example_.txt @@ -1,6 +1,6 @@ usage: cz example [-h] -show commit example +Show commit example options: -h, --help show this help message and exit diff --git a/tests/commands/test_common_command/test_command_shows_description_when_use_help_option_py_3_13_info_.txt b/tests/commands/test_common_command/test_command_shows_description_when_use_help_option_py_3_13_info_.txt index 99b1ba8a4a..ed5ae2522e 100644 --- a/tests/commands/test_common_command/test_command_shows_description_when_use_help_option_py_3_13_info_.txt +++ b/tests/commands/test_common_command/test_command_shows_description_when_use_help_option_py_3_13_info_.txt @@ -1,6 +1,6 @@ usage: cz info [-h] -show information about the cz +Show information about the cz options: -h, --help show this help message and exit diff --git a/tests/commands/test_common_command/test_command_shows_description_when_use_help_option_py_3_13_init_.txt b/tests/commands/test_common_command/test_command_shows_description_when_use_help_option_py_3_13_init_.txt index 0f72042f88..546ab51cb3 100644 --- a/tests/commands/test_common_command/test_command_shows_description_when_use_help_option_py_3_13_init_.txt +++ b/tests/commands/test_common_command/test_command_shows_description_when_use_help_option_py_3_13_init_.txt @@ -1,6 +1,6 @@ usage: cz init [-h] -init commitizen configuration +Initialize commitizen configuration options: -h, --help show this help message and exit diff --git a/tests/commands/test_common_command/test_command_shows_description_when_use_help_option_py_3_13_ls_.txt b/tests/commands/test_common_command/test_command_shows_description_when_use_help_option_py_3_13_ls_.txt index 5fa8fe1f79..253da1722c 100644 --- a/tests/commands/test_common_command/test_command_shows_description_when_use_help_option_py_3_13_ls_.txt +++ b/tests/commands/test_common_command/test_command_shows_description_when_use_help_option_py_3_13_ls_.txt @@ -1,6 +1,6 @@ usage: cz ls [-h] -show available commitizens +Show available Commitizens options: -h, --help show this help message and exit diff --git a/tests/commands/test_common_command/test_command_shows_description_when_use_help_option_py_3_13_schema_.txt b/tests/commands/test_common_command/test_command_shows_description_when_use_help_option_py_3_13_schema_.txt index 6666db4d41..dd05ead81b 100644 --- a/tests/commands/test_common_command/test_command_shows_description_when_use_help_option_py_3_13_schema_.txt +++ b/tests/commands/test_common_command/test_command_shows_description_when_use_help_option_py_3_13_schema_.txt @@ -1,6 +1,6 @@ usage: cz schema [-h] -show commit schema +Show commit schema options: -h, --help show this help message and exit diff --git a/tests/commands/test_common_command/test_command_shows_description_when_use_help_option_py_3_13_version_.txt b/tests/commands/test_common_command/test_command_shows_description_when_use_help_option_py_3_13_version_.txt index a194615a98..5085d0fd3c 100644 --- a/tests/commands/test_common_command/test_command_shows_description_when_use_help_option_py_3_13_version_.txt +++ b/tests/commands/test_common_command/test_command_shows_description_when_use_help_option_py_3_13_version_.txt @@ -1,16 +1,18 @@ -usage: cz version [-h] [-r | -p | -c | -v] [--major | --minor] +usage: cz version [-h] [-r | -p | -c | -v] [--major | --minor | --tag] -get the version of the installed commitizen or the current project (default: +Get the version of the installed commitizen or the current project (default: installed commitizen) options: -h, --help show this help message and exit - -r, --report get system information for reporting bugs - -p, --project get the version of the current project - -c, --commitizen get the version of the installed commitizen - -v, --verbose get the version of both the installed commitizen and the - current project - --major get just the major version. Need to be used with --project + -r, --report Output the system information for reporting bugs. + -p, --project Output the version of the current project. + -c, --commitizen Output the version of the installed commitizen. + -v, --verbose Output the version of both the installed commitizen and + the current project. + --major Output just the major version. Must be used with --project or --verbose. - --minor get just the minor version. Need to be used with --project + --minor Output just the minor version. Must be used with --project or --verbose. + --tag get the version with tag prefix. Need to be used with + --project or --verbose. diff --git a/tests/commands/test_common_command/test_command_shows_description_when_use_help_option_py_3_14_bump_.txt b/tests/commands/test_common_command/test_command_shows_description_when_use_help_option_py_3_14_bump_.txt index 4cf8e6c91b..c472a040e9 100644 --- a/tests/commands/test_common_command/test_command_shows_description_when_use_help_option_py_3_14_bump_.txt +++ b/tests/commands/test_common_command/test_command_shows_description_when_use_help_option_py_3_14_bump_.txt @@ -14,68 +14,70 @@ usage: cz bump [-h] [--dry-run] [--files-only] [--local-version] [--changelog] [--allow-no-commit] [MANUAL_VERSION] -bump semantic version based on the git log +Bump semantic version based on the git log positional arguments: - MANUAL_VERSION bump to the given version (e.g: 1.5.3) + MANUAL_VERSION Bump to the given version (e.g., 1.5.3). options: -h, --help show this help message and exit - --dry-run show output to stdout, no commit, no modified files - --files-only bump version in the files from the config - --local-version bump only the local version portion - --changelog, -ch generate the changelog for the newest version - --no-verify this option bypasses the pre-commit and commit-msg - hooks - --yes accept automatically questions done + --dry-run Perform a dry run, without committing or modifying + files. + --files-only Bump version in the `version_files` specified in the + configuration file only. + --local-version Bump version only the local version portion (ignoring + the public version). + --changelog, -ch Generate the changelog for the latest version. + --no-verify Bypass the pre-commit and commit-msg hooks. + --yes Accept automatically answered questions. --tag-format TAG_FORMAT - the format used to tag the commit and read it, use it - in existing projects, wrap around simple quotes + The format used to tag the commit and read it. Use it + in existing projects, and wrap around simple quotes. --bump-message BUMP_MESSAGE - template used to create the release commit, useful - when working with CI + Template used to create the release commit, useful + when working with CI. --prerelease, -pr {alpha,beta,rc} - choose type of prerelease + Type of prerelease. --devrelease, -d DEVRELEASE - specify non-negative integer for dev. release + Specify non-negative integer for dev release. --increment {MAJOR,MINOR,PATCH} - manually specify the desired increment + Specify the desired increment. --increment-mode {linear,exact} - set the method by which the new version is chosen. - 'linear' (default) guesses the next version based on - typical linear version progression, such that bumping - of a pre-release with lower precedence than the - current pre-release phase maintains the current phase - of higher precedence. 'exact' applies the changes that + Set the method by which the new version is chosen. + 'linear' (default) resolves the next version based on + typical linear version progression, where bumping of a + pre-release with lower precedence than the current + pre-release phase maintains the current phase of + higher precedence. 'exact' applies the changes that have been specified (or determined from the commit - log) without interpretation, such that the increment - and pre-release are always honored + log) without interpretation, ensuring the increment + and pre-release are always honored. --check-consistency, -cc - check consistency among versions defined in commitizen - configuration and version_files - --annotated-tag, -at create annotated tag instead of lightweight one + Check consistency among versions defined in Commitizen + configuration file and `version_files`. + --annotated-tag, -at Create annotated tag instead of lightweight one. --annotated-tag-message, -atm ANNOTATED_TAG_MESSAGE - create annotated tag message - --gpg-sign, -s sign tag instead of lightweight one + Create annotated tag message. + --gpg-sign, -s Sign tag instead of lightweight one. --changelog-to-stdout - Output changelog to the stdout + Output changelog to stdout. --git-output-to-stderr - Redirect git output to stderr - --retry retry commit if it fails the 1st time - --major-version-zero keep major version at zero, even for breaking changes + Redirect git output to stderr. + --retry Retry commit if it fails for the first time. + --major-version-zero Keep major version at zero, even for breaking changes. --template, -t TEMPLATE - changelog template file name (relative to the current - working directory) - --extra, -e EXTRA a changelog extra variable (in the form 'key=value') + Changelog template file name (relative to the current + working directory). + --extra, -e EXTRA Changelog extra variables (in the form 'key=value'). --file-name FILE_NAME - file name of changelog (default: 'CHANGELOG.md') + File name of changelog (default: 'CHANGELOG.md'). --prerelease-offset PRERELEASE_OFFSET - start pre-releases with this offset + Start pre-releases with this offset. --version-scheme {pep440,semver,semver2} - choose version scheme + Choose version scheme. --version-type {pep440,semver,semver2} - Deprecated, use --version-scheme instead + Deprecated, use `--version-scheme` instead. --build-metadata BUILD_METADATA - Add additional build-metadata to the version-number - --get-next Determine the next version and write to stdout - --allow-no-commit bump version without eligible commits + Add additional build-metadata to the version-number. + --get-next Determine the next version and write to stdout. + --allow-no-commit Bump version without eligible commits. diff --git a/tests/commands/test_common_command/test_command_shows_description_when_use_help_option_py_3_14_changelog_.txt b/tests/commands/test_common_command/test_command_shows_description_when_use_help_option_py_3_14_changelog_.txt index 91b7f389b5..50ab468d64 100644 --- a/tests/commands/test_common_command/test_command_shows_description_when_use_help_option_py_3_14_changelog_.txt +++ b/tests/commands/test_common_command/test_command_shows_description_when_use_help_option_py_3_14_changelog_.txt @@ -6,36 +6,36 @@ usage: cz changelog [-h] [--dry-run] [--file-name FILE_NAME] [--extra EXTRA] [--tag-format TAG_FORMAT] [rev_range] -generate changelog (note that it will overwrite existing file) +Generate changelog (note that it will overwrite existing files) positional arguments: - rev_range generates changelog for the given version (e.g: 1.5.3) - or version range (e.g: 1.5.3..1.7.9) + rev_range Generate changelog for the given version (e.g., 1.5.3) + or version range (e.g., 1.5.3..1.7.9). options: -h, --help show this help message and exit - --dry-run show changelog to stdout + --dry-run Show changelog to stdout. --file-name FILE_NAME - file name of changelog (default: 'CHANGELOG.md') + File name of changelog (default: 'CHANGELOG.md'). --unreleased-version UNRELEASED_VERSION - set the value for the new version (use the tag value), - instead of using unreleased - --incremental generates changelog from last created version, useful - if the changelog has been manually modified + Set the value for the new version (use the tag value), + instead of using unreleased versions. + --incremental Generate changelog from the last created version, + useful if the changelog has been manually modified. --start-rev START_REV - start rev of the changelog. If not set, it will - generate changelog from the start - --merge-prerelease collect all changes from prereleases into next non- - prerelease. If not set, it will include prereleases in - the changelog + Start rev of the changelog. If not set, it will + generate changelog from the beginning. + --merge-prerelease Collect all changes from prereleases into the next + non-prerelease. If not set, it will include + prereleases in the changelog. --version-scheme {pep440,semver,semver2} - choose version scheme + Choose version scheme. --export-template EXPORT_TEMPLATE Export the changelog template into this file instead - of rendering it + of rendering it. --template, -t TEMPLATE - changelog template file name (relative to the current - working directory) - --extra, -e EXTRA a changelog extra variable (in the form 'key=value') + Changelog template file name (relative to the current + working directory). + --extra, -e EXTRA Changelog extra variables (in the form 'key=value'). --tag-format TAG_FORMAT - The format of the tag, wrap around simple quotes + The format of the tag, wrap around simple quotes. diff --git a/tests/commands/test_common_command/test_command_shows_description_when_use_help_option_py_3_14_check_.txt b/tests/commands/test_common_command/test_command_shows_description_when_use_help_option_py_3_14_check_.txt index 4066748557..6f8297e1ee 100644 --- a/tests/commands/test_common_command/test_command_shows_description_when_use_help_option_py_3_14_check_.txt +++ b/tests/commands/test_common_command/test_command_shows_description_when_use_help_option_py_3_14_check_.txt @@ -3,26 +3,27 @@ usage: cz check [-h] [--commit-msg-file COMMIT_MSG_FILE | [--allowed-prefixes [ALLOWED_PREFIXES ...]] [-l MESSAGE_LENGTH_LIMIT] -validates that a commit message matches the commitizen schema +Validate that a commit message matches the commitizen schema options: -h, --help show this help message and exit --commit-msg-file COMMIT_MSG_FILE - ask for the name of the temporal file that contains - the commit message. Using it in a git hook script: - MSG_FILE=$1 + Ask for the name of the temporary file that contains + the commit message. Use it in a git hook script: + MSG_FILE=$1. --rev-range REV_RANGE - a range of git rev to check. e.g, master..HEAD + Validate the commits in the given range of git rev, + e.g., master..HEAD. -d, --use-default-range - check from the default branch to HEAD. e.g, - refs/remotes/origin/master..HEAD + Validate the commits from the default branch to HEAD, + e.g., refs/remotes/origin/master..HEAD. -m, --message MESSAGE - commit message that needs to be checked - --allow-abort allow empty commit messages, which typically abort a - commit + Validate the given commit message. + --allow-abort Allow empty commit messages, which typically abort a + commit. --allowed-prefixes [ALLOWED_PREFIXES ...] - allowed commit message prefixes. If the message starts - by one of these prefixes, the message won't be checked - against the regex + Skip validation for commit messages that start with + the specified prefixes. -l, --message-length-limit MESSAGE_LENGTH_LIMIT - length limit of the commit message; 0 for no limit + Restrict the length of the **first line** of the + commit message; 0 for no limit. diff --git a/tests/commands/test_common_command/test_command_shows_description_when_use_help_option_py_3_14_commit_.txt b/tests/commands/test_common_command/test_command_shows_description_when_use_help_option_py_3_14_commit_.txt index ba531042aa..cbd5780f6d 100644 --- a/tests/commands/test_common_command/test_command_shows_description_when_use_help_option_py_3_14_commit_.txt +++ b/tests/commands/test_common_command/test_command_shows_description_when_use_help_option_py_3_14_commit_.txt @@ -2,21 +2,24 @@ usage: cz commit [-h] [--retry] [--no-retry] [--dry-run] [--write-message-to-file FILE_PATH] [-s] [-a] [-e] [-l MESSAGE_LENGTH_LIMIT] [--] -create new commit +Create new commit options: -h, --help show this help message and exit - --retry retry last commit - --no-retry skip retry if retry_after_failure is set to true - --dry-run show output to stdout, no commit, no modified files + --retry Retry the last commit. + --no-retry Skip retry if --retry or `retry_after_failure` is set + to true. + --dry-run Perform a dry run, without committing or modifying + files. --write-message-to-file FILE_PATH - write message to file before committing (can be - combined with --dry-run) - -s, --signoff Deprecated, use 'cz commit -- -s' instead - -a, --all Tell the command to automatically stage files that - have been modified and deleted, but new files you have - not told Git about are not affected. - -e, --edit edit the commit message before committing + Write message to FILE_PATH before committing (can be + used with --dry-run). + -s, --signoff Deprecated, use `cz commit -- -s` instead. + -a, --all Automatically stage files that have been modified and + deleted, but new files you have not told Git about are + not affected. + -e, --edit Edit the commit message before committing. -l, --message-length-limit MESSAGE_LENGTH_LIMIT - length limit of the commit message; 0 for no limit - -- Positional arguments separator (recommended) + Set the length limit of the commit message; 0 for no + limit. + -- Positional arguments separator (recommended). diff --git a/tests/commands/test_common_command/test_command_shows_description_when_use_help_option_py_3_14_example_.txt b/tests/commands/test_common_command/test_command_shows_description_when_use_help_option_py_3_14_example_.txt index b9bf7f84fc..8a0f1c9d94 100644 --- a/tests/commands/test_common_command/test_command_shows_description_when_use_help_option_py_3_14_example_.txt +++ b/tests/commands/test_common_command/test_command_shows_description_when_use_help_option_py_3_14_example_.txt @@ -1,6 +1,6 @@ usage: cz example [-h] -show commit example +Show commit example options: -h, --help show this help message and exit diff --git a/tests/commands/test_common_command/test_command_shows_description_when_use_help_option_py_3_14_info_.txt b/tests/commands/test_common_command/test_command_shows_description_when_use_help_option_py_3_14_info_.txt index 99b1ba8a4a..ed5ae2522e 100644 --- a/tests/commands/test_common_command/test_command_shows_description_when_use_help_option_py_3_14_info_.txt +++ b/tests/commands/test_common_command/test_command_shows_description_when_use_help_option_py_3_14_info_.txt @@ -1,6 +1,6 @@ usage: cz info [-h] -show information about the cz +Show information about the cz options: -h, --help show this help message and exit diff --git a/tests/commands/test_common_command/test_command_shows_description_when_use_help_option_py_3_14_init_.txt b/tests/commands/test_common_command/test_command_shows_description_when_use_help_option_py_3_14_init_.txt index 0f72042f88..546ab51cb3 100644 --- a/tests/commands/test_common_command/test_command_shows_description_when_use_help_option_py_3_14_init_.txt +++ b/tests/commands/test_common_command/test_command_shows_description_when_use_help_option_py_3_14_init_.txt @@ -1,6 +1,6 @@ usage: cz init [-h] -init commitizen configuration +Initialize commitizen configuration options: -h, --help show this help message and exit diff --git a/tests/commands/test_common_command/test_command_shows_description_when_use_help_option_py_3_14_ls_.txt b/tests/commands/test_common_command/test_command_shows_description_when_use_help_option_py_3_14_ls_.txt index 5fa8fe1f79..253da1722c 100644 --- a/tests/commands/test_common_command/test_command_shows_description_when_use_help_option_py_3_14_ls_.txt +++ b/tests/commands/test_common_command/test_command_shows_description_when_use_help_option_py_3_14_ls_.txt @@ -1,6 +1,6 @@ usage: cz ls [-h] -show available commitizens +Show available Commitizens options: -h, --help show this help message and exit diff --git a/tests/commands/test_common_command/test_command_shows_description_when_use_help_option_py_3_14_schema_.txt b/tests/commands/test_common_command/test_command_shows_description_when_use_help_option_py_3_14_schema_.txt index 6666db4d41..dd05ead81b 100644 --- a/tests/commands/test_common_command/test_command_shows_description_when_use_help_option_py_3_14_schema_.txt +++ b/tests/commands/test_common_command/test_command_shows_description_when_use_help_option_py_3_14_schema_.txt @@ -1,6 +1,6 @@ usage: cz schema [-h] -show commit schema +Show commit schema options: -h, --help show this help message and exit diff --git a/tests/commands/test_common_command/test_command_shows_description_when_use_help_option_py_3_14_version_.txt b/tests/commands/test_common_command/test_command_shows_description_when_use_help_option_py_3_14_version_.txt index a194615a98..5085d0fd3c 100644 --- a/tests/commands/test_common_command/test_command_shows_description_when_use_help_option_py_3_14_version_.txt +++ b/tests/commands/test_common_command/test_command_shows_description_when_use_help_option_py_3_14_version_.txt @@ -1,16 +1,18 @@ -usage: cz version [-h] [-r | -p | -c | -v] [--major | --minor] +usage: cz version [-h] [-r | -p | -c | -v] [--major | --minor | --tag] -get the version of the installed commitizen or the current project (default: +Get the version of the installed commitizen or the current project (default: installed commitizen) options: -h, --help show this help message and exit - -r, --report get system information for reporting bugs - -p, --project get the version of the current project - -c, --commitizen get the version of the installed commitizen - -v, --verbose get the version of both the installed commitizen and the - current project - --major get just the major version. Need to be used with --project + -r, --report Output the system information for reporting bugs. + -p, --project Output the version of the current project. + -c, --commitizen Output the version of the installed commitizen. + -v, --verbose Output the version of both the installed commitizen and + the current project. + --major Output just the major version. Must be used with --project or --verbose. - --minor get just the minor version. Need to be used with --project + --minor Output just the minor version. Must be used with --project or --verbose. + --tag get the version with tag prefix. Need to be used with + --project or --verbose. diff --git a/tests/commands/test_init_command.py b/tests/commands/test_init_command.py index 8398e784bc..0cf6377ead 100644 --- a/tests/commands/test_init_command.py +++ b/tests/commands/test_init_command.py @@ -10,6 +10,7 @@ from commitizen import cmd, commands from commitizen.__version__ import __version__ +from commitizen.cz import registry from commitizen.exceptions import InitFailedError, NoAnswersError if TYPE_CHECKING: @@ -133,7 +134,7 @@ def pre_commit_installed(mocker: MockFixture): ) -@pytest.fixture(scope="function", params=["pyproject.toml", ".cz.json", ".cz.yaml"]) +@pytest.fixture(params=["pyproject.toml", ".cz.json", ".cz.yaml"]) def default_choice(request, mocker: MockFixture): mocker.patch( "questionary.select", @@ -150,7 +151,7 @@ def default_choice(request, mocker: MockFixture): "questionary.checkbox", return_value=FakeQuestion(["commit-msg", "pre-push"]), ) - yield request.param + return request.param def check_cz_config(config_filepath: str): @@ -179,7 +180,7 @@ def check_pre_commit_config(expected: list[dict[str, Any]]): @pytest.mark.usefixtures("pre_commit_installed") class TestPreCommitCases: def test_no_existing_pre_commit_config( - _, default_choice: str, tmpdir, config: BaseConfig + self, default_choice: str, tmpdir, config: BaseConfig ): with tmpdir.as_cwd(): commands.Init(config)() @@ -187,7 +188,7 @@ def test_no_existing_pre_commit_config( check_pre_commit_config([cz_hook_config]) def test_empty_pre_commit_config( - _, default_choice: str, tmpdir, config: BaseConfig + self, default_choice: str, tmpdir, config: BaseConfig ): with tmpdir.as_cwd(): p = tmpdir.join(pre_commit_config_filename) @@ -198,7 +199,7 @@ def test_empty_pre_commit_config( check_pre_commit_config([cz_hook_config]) def test_pre_commit_config_without_cz_hook( - _, default_choice: str, tmpdir, config: BaseConfig + self, default_choice: str, tmpdir, config: BaseConfig ): existing_hook_config = { "repo": "https://github.com/pre-commit/pre-commit-hooks", @@ -215,7 +216,7 @@ def test_pre_commit_config_without_cz_hook( check_pre_commit_config([existing_hook_config, cz_hook_config]) def test_cz_hook_exists_in_pre_commit_config( - _, default_choice: str, tmpdir, config: BaseConfig + self, default_choice: str, tmpdir, config: BaseConfig ): with tmpdir.as_cwd(): p = tmpdir.join(pre_commit_config_filename) @@ -228,8 +229,9 @@ def test_cz_hook_exists_in_pre_commit_config( class TestNoPreCommitInstalled: + @pytest.mark.usefixtures("default_choice") def test_pre_commit_not_installed( - _, mocker: MockFixture, config: BaseConfig, default_choice: str, tmpdir + self, mocker: MockFixture, config: BaseConfig, tmpdir ): # Assume `pre-commit` is not installed mocker.patch( @@ -462,3 +464,22 @@ def test_init_configuration_with_version_provider( assert ( "version = " not in config_data ) # Version should not be set when using version_provider + + +def test_construct_name_choice_with_description( + config: BaseConfig, mocker: MockFixture +): + """Test the construction of cz name choices with descriptions.""" + init = commands.Init(config) + # mock the registry to have only one cz for testing + mocker.patch.dict( + "commitizen.cz.registry", + {"cz_conventional_commits": registry["cz_conventional_commits"]}, + clear=True, + ) + choices = init._construct_name_choice_with_description() + assert len(choices) == 1 + choice = choices[0] + assert choice.title == "cz_conventional_commits" + assert choice.value == "cz_conventional_commits" + assert choice.description == "(): " diff --git a/tests/commands/test_version_command.py b/tests/commands/test_version_command.py index 17f7238403..af22ba7ad2 100644 --- a/tests/commands/test_version_command.py +++ b/tests/commands/test_version_command.py @@ -161,3 +161,42 @@ def test_version_just_major_error_no_project(config, capsys, argument: str): "Major or minor version can only be used with --project or --verbose." in captured.err ) + + +@pytest.mark.parametrize( + "version, tag_format, expected_output", + [ + ("1.2.3", "v$version", "v1.2.3\n"), + ("1.2.3", "$version", "1.2.3\n"), + ("2.0.0", "release-$version", "release-2.0.0\n"), + ("0.1.0", "ver$version", "ver0.1.0\n"), + ], +) +def test_version_with_tag_format( + config, capsys, version: str, tag_format: str, expected_output: str +): + """Test --tag option applies tag_format to version""" + config.settings["version"] = version + config.settings["tag_format"] = tag_format + commands.Version( + config, + { + "project": True, + "tag": True, + }, + )() + captured = capsys.readouterr() + assert captured.out == expected_output + + +def test_version_tag_without_project_error(config, capsys): + """Test --tag requires --project or --verbose""" + commands.Version( + config, + { + "tag": True, + }, + )() + captured = capsys.readouterr() + assert not captured.out + assert "Tag can only be used with --project or --verbose." in captured.err diff --git a/tests/test_bump_hooks.py b/tests/test_bump_hooks.py index 70ed7fe0b1..739d1ce6ad 100644 --- a/tests/test_bump_hooks.py +++ b/tests/test_bump_hooks.py @@ -38,5 +38,5 @@ def test_run_error(mocker: MockFixture): def test_format_env(): result = hooks._format_env("TEST_", {"foo": "bar", "bar": "baz"}) - assert "TEST_FOO" in result and result["TEST_FOO"] == "bar" - assert "TEST_BAR" in result and result["TEST_BAR"] == "baz" + assert result["TEST_FOO"] == "bar" + assert result["TEST_BAR"] == "baz" diff --git a/tests/test_bump_update_version_in_files.py b/tests/test_bump_update_version_in_files.py index 2cc464e8f1..8fd4c465b8 100644 --- a/tests/test_bump_update_version_in_files.py +++ b/tests/test_bump_update_version_in_files.py @@ -57,7 +57,6 @@ def docker_compose_file(sample_file: SampleFileFixture) -> Path: @pytest.fixture( - scope="function", params=( "multiple_versions_to_update_pyproject.toml", "multiple_versions_to_update_pyproject_wo_eol.toml", diff --git a/tests/test_cli/test_no_argv_py_3_10_.txt b/tests/test_cli/test_no_argv_py_3_10_.txt index 691c75a86f..69f410e96d 100644 --- a/tests/test_cli/test_no_argv_py_3_10_.txt +++ b/tests/test_cli/test_no_argv_py_3_10_.txt @@ -7,28 +7,28 @@ For more information, please visit https://commitizen-tools.github.io/commitizen options: -h, --help show this help message and exit - --config CONFIG the path of configuration file - --debug use debug mode - -n NAME, --name NAME use the given commitizen (default: - cz_conventional_commits) + --config CONFIG The path to the configuration file. + --debug Use debug mode. + -n NAME, --name NAME Use the given commitizen (default: + cz_conventional_commits). -nr NO_RAISE, --no-raise NO_RAISE - comma separated error codes that won't raise error, - e.g: cz -nr 1,2,3 bump. See codes at + Comma-separated error codes that won't raise error, + e.g., cz -nr 1,2,3 bump. See codes at https://commitizen- tools.github.io/commitizen/exit_codes/ commands: {init,commit,c,ls,example,info,schema,bump,changelog,ch,check,version} - init init commitizen configuration - commit (c) create new commit - ls show available commitizens - example show commit example - info show information about the cz - schema show commit schema - bump bump semantic version based on the git log - changelog (ch) generate changelog (note that it will overwrite - existing file) - check validates that a commit message matches the commitizen - schema - version get the version of the installed commitizen or the - current project (default: installed commitizen) + init Initialize commitizen configuration. + commit (c) Create new commit. + ls Show available Commitizens. + example Show commit example. + info Show information about the cz. + schema Show commit schema. + bump Bump semantic version based on the git log. + changelog (ch) Generate changelog (note that it will overwrite + existing files). + check Validate that a commit message matches the commitizen + schema. + version Get the version of the installed commitizen or the + current project (default: installed commitizen). diff --git a/tests/test_cli/test_no_argv_py_3_11_.txt b/tests/test_cli/test_no_argv_py_3_11_.txt index 691c75a86f..69f410e96d 100644 --- a/tests/test_cli/test_no_argv_py_3_11_.txt +++ b/tests/test_cli/test_no_argv_py_3_11_.txt @@ -7,28 +7,28 @@ For more information, please visit https://commitizen-tools.github.io/commitizen options: -h, --help show this help message and exit - --config CONFIG the path of configuration file - --debug use debug mode - -n NAME, --name NAME use the given commitizen (default: - cz_conventional_commits) + --config CONFIG The path to the configuration file. + --debug Use debug mode. + -n NAME, --name NAME Use the given commitizen (default: + cz_conventional_commits). -nr NO_RAISE, --no-raise NO_RAISE - comma separated error codes that won't raise error, - e.g: cz -nr 1,2,3 bump. See codes at + Comma-separated error codes that won't raise error, + e.g., cz -nr 1,2,3 bump. See codes at https://commitizen- tools.github.io/commitizen/exit_codes/ commands: {init,commit,c,ls,example,info,schema,bump,changelog,ch,check,version} - init init commitizen configuration - commit (c) create new commit - ls show available commitizens - example show commit example - info show information about the cz - schema show commit schema - bump bump semantic version based on the git log - changelog (ch) generate changelog (note that it will overwrite - existing file) - check validates that a commit message matches the commitizen - schema - version get the version of the installed commitizen or the - current project (default: installed commitizen) + init Initialize commitizen configuration. + commit (c) Create new commit. + ls Show available Commitizens. + example Show commit example. + info Show information about the cz. + schema Show commit schema. + bump Bump semantic version based on the git log. + changelog (ch) Generate changelog (note that it will overwrite + existing files). + check Validate that a commit message matches the commitizen + schema. + version Get the version of the installed commitizen or the + current project (default: installed commitizen). diff --git a/tests/test_cli/test_no_argv_py_3_12_.txt b/tests/test_cli/test_no_argv_py_3_12_.txt index 691c75a86f..69f410e96d 100644 --- a/tests/test_cli/test_no_argv_py_3_12_.txt +++ b/tests/test_cli/test_no_argv_py_3_12_.txt @@ -7,28 +7,28 @@ For more information, please visit https://commitizen-tools.github.io/commitizen options: -h, --help show this help message and exit - --config CONFIG the path of configuration file - --debug use debug mode - -n NAME, --name NAME use the given commitizen (default: - cz_conventional_commits) + --config CONFIG The path to the configuration file. + --debug Use debug mode. + -n NAME, --name NAME Use the given commitizen (default: + cz_conventional_commits). -nr NO_RAISE, --no-raise NO_RAISE - comma separated error codes that won't raise error, - e.g: cz -nr 1,2,3 bump. See codes at + Comma-separated error codes that won't raise error, + e.g., cz -nr 1,2,3 bump. See codes at https://commitizen- tools.github.io/commitizen/exit_codes/ commands: {init,commit,c,ls,example,info,schema,bump,changelog,ch,check,version} - init init commitizen configuration - commit (c) create new commit - ls show available commitizens - example show commit example - info show information about the cz - schema show commit schema - bump bump semantic version based on the git log - changelog (ch) generate changelog (note that it will overwrite - existing file) - check validates that a commit message matches the commitizen - schema - version get the version of the installed commitizen or the - current project (default: installed commitizen) + init Initialize commitizen configuration. + commit (c) Create new commit. + ls Show available Commitizens. + example Show commit example. + info Show information about the cz. + schema Show commit schema. + bump Bump semantic version based on the git log. + changelog (ch) Generate changelog (note that it will overwrite + existing files). + check Validate that a commit message matches the commitizen + schema. + version Get the version of the installed commitizen or the + current project (default: installed commitizen). diff --git a/tests/test_cli/test_no_argv_py_3_13_.txt b/tests/test_cli/test_no_argv_py_3_13_.txt index f880f99772..b47528ec3e 100644 --- a/tests/test_cli/test_no_argv_py_3_13_.txt +++ b/tests/test_cli/test_no_argv_py_3_13_.txt @@ -6,28 +6,28 @@ For more information, please visit https://commitizen-tools.github.io/commitizen options: -h, --help show this help message and exit - --config CONFIG the path of configuration file - --debug use debug mode - -n, --name NAME use the given commitizen (default: - cz_conventional_commits) + --config CONFIG The path to the configuration file. + --debug Use debug mode. + -n, --name NAME Use the given commitizen (default: + cz_conventional_commits). -nr, --no-raise NO_RAISE - comma separated error codes that won't raise error, - e.g: cz -nr 1,2,3 bump. See codes at + Comma-separated error codes that won't raise error, + e.g., cz -nr 1,2,3 bump. See codes at https://commitizen- tools.github.io/commitizen/exit_codes/ commands: {init,commit,c,ls,example,info,schema,bump,changelog,ch,check,version} - init init commitizen configuration - commit (c) create new commit - ls show available commitizens - example show commit example - info show information about the cz - schema show commit schema - bump bump semantic version based on the git log - changelog (ch) generate changelog (note that it will overwrite - existing file) - check validates that a commit message matches the commitizen - schema - version get the version of the installed commitizen or the - current project (default: installed commitizen) + init Initialize commitizen configuration. + commit (c) Create new commit. + ls Show available Commitizens. + example Show commit example. + info Show information about the cz. + schema Show commit schema. + bump Bump semantic version based on the git log. + changelog (ch) Generate changelog (note that it will overwrite + existing files). + check Validate that a commit message matches the commitizen + schema. + version Get the version of the installed commitizen or the + current project (default: installed commitizen). diff --git a/tests/test_cli/test_no_argv_py_3_14_.txt b/tests/test_cli/test_no_argv_py_3_14_.txt index f880f99772..b47528ec3e 100644 --- a/tests/test_cli/test_no_argv_py_3_14_.txt +++ b/tests/test_cli/test_no_argv_py_3_14_.txt @@ -6,28 +6,28 @@ For more information, please visit https://commitizen-tools.github.io/commitizen options: -h, --help show this help message and exit - --config CONFIG the path of configuration file - --debug use debug mode - -n, --name NAME use the given commitizen (default: - cz_conventional_commits) + --config CONFIG The path to the configuration file. + --debug Use debug mode. + -n, --name NAME Use the given commitizen (default: + cz_conventional_commits). -nr, --no-raise NO_RAISE - comma separated error codes that won't raise error, - e.g: cz -nr 1,2,3 bump. See codes at + Comma-separated error codes that won't raise error, + e.g., cz -nr 1,2,3 bump. See codes at https://commitizen- tools.github.io/commitizen/exit_codes/ commands: {init,commit,c,ls,example,info,schema,bump,changelog,ch,check,version} - init init commitizen configuration - commit (c) create new commit - ls show available commitizens - example show commit example - info show information about the cz - schema show commit schema - bump bump semantic version based on the git log - changelog (ch) generate changelog (note that it will overwrite - existing file) - check validates that a commit message matches the commitizen - schema - version get the version of the installed commitizen or the - current project (default: installed commitizen) + init Initialize commitizen configuration. + commit (c) Create new commit. + ls Show available Commitizens. + example Show commit example. + info Show information about the cz. + schema Show commit schema. + bump Bump semantic version based on the git log. + changelog (ch) Generate changelog (note that it will overwrite + existing files). + check Validate that a commit message matches the commitizen + schema. + version Get the version of the installed commitizen or the + current project (default: installed commitizen). diff --git a/tests/test_conf.py b/tests/test_conf.py index 6e4256f162..f1ff76ff88 100644 --- a/tests/test_conf.py +++ b/tests/test_conf.py @@ -14,7 +14,7 @@ from commitizen.config.yaml_config import YAMLConfig from commitizen.exceptions import ConfigFileIsEmpty, InvalidConfigurationError -PYPROJECT = """ +TOML_STR = """ [tool.commitizen] name = "cz_jira" version = "1.0.0" @@ -30,12 +30,17 @@ "scripts/generate_documentation.sh" ] post_bump_hooks = ["scripts/slack_notification.sh"] +""" + +PYPROJECT = f""" +{TOML_STR} [tool.black] line-length = 88 target-version = ['py36', 'py37', 'py38'] """ + DICT_CONFIG = { "commitizen": { "name": "cz_jira", @@ -106,7 +111,7 @@ "template": None, "extras": {}, "breaking_change_exclamation_in_title": False, - "message_length_limit": None, + "message_length_limit": 0, } _new_settings: dict[str, Any] = { @@ -146,7 +151,7 @@ "template": None, "extras": {}, "breaking_change_exclamation_in_title": False, - "message_length_limit": None, + "message_length_limit": 0, } @@ -184,26 +189,26 @@ class TestReadCfg: @pytest.mark.parametrize( "config_files_manager", defaults.CONFIG_FILES, indirect=True ) - def test_load_conf(_, config_files_manager): + def test_load_conf(self, config_files_manager): cfg = config.read_cfg() assert cfg.settings == _settings - def test_conf_returns_default_when_no_files(_, tmpdir): + def test_conf_returns_default_when_no_files(self, tmpdir): with tmpdir.as_cwd(): cfg = config.read_cfg() assert cfg.settings == defaults.DEFAULT_SETTINGS - def test_load_empty_pyproject_toml_and_cz_toml_with_config(_, tmpdir): + def test_load_empty_pyproject_toml_and_cz_toml_with_config(self, tmpdir): with tmpdir.as_cwd(): p = tmpdir.join("pyproject.toml") p.write("") p = tmpdir.join(".cz.toml") - p.write(PYPROJECT) + p.write(TOML_STR) cfg = config.read_cfg() assert cfg.settings == _settings - def test_load_pyproject_toml_from_config_argument(_, tmpdir): + def test_load_pyproject_toml_from_config_argument(self, tmpdir): with tmpdir.as_cwd(): _not_root_path = tmpdir.mkdir("not_in_root").join("pyproject.toml") _not_root_path.write(PYPROJECT) @@ -211,7 +216,7 @@ def test_load_pyproject_toml_from_config_argument(_, tmpdir): cfg = config.read_cfg(filepath="./not_in_root/pyproject.toml") assert cfg.settings == _settings - def test_load_cz_json_not_from_config_argument(_, tmpdir): + def test_load_cz_json_not_from_config_argument(self, tmpdir): with tmpdir.as_cwd(): _not_root_path = tmpdir.mkdir("not_in_root").join(".cz.json") _not_root_path.write(JSON_STR) @@ -220,7 +225,7 @@ def test_load_cz_json_not_from_config_argument(_, tmpdir): json_cfg_by_class = JsonConfig(data=JSON_STR, path=_not_root_path) assert cfg.settings == json_cfg_by_class.settings - def test_load_cz_yaml_not_from_config_argument(_, tmpdir): + def test_load_cz_yaml_not_from_config_argument(self, tmpdir): with tmpdir.as_cwd(): _not_root_path = tmpdir.mkdir("not_in_root").join(".cz.yaml") _not_root_path.write(YAML_STR) @@ -229,7 +234,7 @@ def test_load_cz_yaml_not_from_config_argument(_, tmpdir): yaml_cfg_by_class = YAMLConfig(data=YAML_STR, path=_not_root_path) assert cfg.settings == yaml_cfg_by_class._settings - def test_load_empty_pyproject_toml_from_config_argument(_, tmpdir): + def test_load_empty_pyproject_toml_from_config_argument(self, tmpdir): with tmpdir.as_cwd(): _not_root_path = tmpdir.mkdir("not_in_root").join("pyproject.toml") _not_root_path.write("") @@ -240,27 +245,25 @@ def test_load_empty_pyproject_toml_from_config_argument(_, tmpdir): class TestWarnMultipleConfigFiles: @pytest.mark.parametrize( - "files,expected_path,should_warn", + "files,expected_path", [ # Same directory, different file types - ([(".cz.toml", PYPROJECT), (".cz.json", JSON_STR)], ".cz.toml", True), - ([(".cz.json", JSON_STR), (".cz.yaml", YAML_STR)], ".cz.json", True), - ([(".cz.toml", PYPROJECT), (".cz.yaml", YAML_STR)], ".cz.toml", True), - # With pyproject.toml (excluded from warning) + ([(".cz.toml", TOML_STR), (".cz.json", JSON_STR)], ".cz.toml"), + ([(".cz.json", JSON_STR), (".cz.yaml", YAML_STR)], ".cz.json"), + ([(".cz.toml", TOML_STR), (".cz.yaml", YAML_STR)], ".cz.toml"), + # With pyproject.toml ( [("pyproject.toml", PYPROJECT), (".cz.json", JSON_STR)], ".cz.json", - False, ), ( - [("pyproject.toml", PYPROJECT), (".cz.toml", PYPROJECT)], + [("pyproject.toml", PYPROJECT), (".cz.toml", TOML_STR)], ".cz.toml", - False, ), ], ) def test_warn_multiple_config_files_same_dir( - _, tmpdir, capsys, files, expected_path, should_warn + self, tmpdir, capsys, files, expected_path ): """Test warning when multiple config files exist in same directory.""" with tmpdir.as_cwd(): @@ -270,33 +273,26 @@ def test_warn_multiple_config_files_same_dir( cfg = config.read_cfg() captured = capsys.readouterr() - if should_warn: - assert "Multiple config files detected" in captured.err - assert "Using" in captured.err - for filename, _ in files: - if filename != "pyproject.toml": - assert filename in captured.err - else: - assert "Multiple config files detected" not in captured.err + assert "Multiple config files detected" in captured.err + for filename, _ in files: + assert filename in captured.err + assert f"Using config file: '{expected_path}'" in captured.err assert cfg.path == Path(expected_path) - # Verify config loaded correctly (name and version match expected) - assert cfg.settings["name"] == "cz_jira" - assert cfg.settings["version"] == "1.0.0" @pytest.mark.parametrize( "config_file,content", [ (".cz.json", JSON_STR), - (".cz.toml", PYPROJECT), + (".cz.toml", TOML_STR), (".cz.yaml", YAML_STR), - ("cz.toml", PYPROJECT), + ("cz.toml", TOML_STR), ("cz.json", JSON_STR), ("cz.yaml", YAML_STR), ], ) def test_warn_same_filename_different_directories_with_git( - _, tmpdir, capsys, config_file, content + self, tmpdir, capsys, config_file, content ): """Test warning when same config filename exists in the current directory and in the git root.""" with tmpdir.as_cwd(): @@ -317,7 +313,7 @@ def test_warn_same_filename_different_directories_with_git( assert f"Using config file: '{config_file}'" in captured.err assert cfg.path == Path(config_file) - def test_no_warn_with_explicit_config_path(_, tmpdir, capsys): + def test_no_warn_with_explicit_config_path(self, tmpdir, capsys): """Test that no warning is issued when user explicitly specifies config.""" with tmpdir.as_cwd(): # Create multiple config files @@ -340,11 +336,11 @@ def test_no_warn_with_explicit_config_path(_, tmpdir, capsys): [ (file, content, with_git) for file, content in [ - (".cz.toml", PYPROJECT), + (".cz.toml", TOML_STR), (".cz.json", JSON_STR), (".cz.yaml", YAML_STR), ("pyproject.toml", PYPROJECT), - ("cz.toml", PYPROJECT), + ("cz.toml", TOML_STR), ("cz.json", JSON_STR), ("cz.yaml", YAML_STR), ] @@ -352,7 +348,7 @@ def test_no_warn_with_explicit_config_path(_, tmpdir, capsys): ], ) def test_no_warn_with_single_config_file( - _, tmpdir, capsys, config_file, content, with_git + self, tmpdir, capsys, config_file, content, with_git ): """Test that no warning is issued when user explicitly specifies config.""" with tmpdir.as_cwd(): @@ -368,6 +364,18 @@ def test_no_warn_with_single_config_file( assert "Multiple config files detected" not in captured.err assert cfg.path == Path(config_file) + def test_no_warn_with_no_commitizen_section_in_pyproject_toml_and_cz_toml( + self, tmpdir, capsys + ): + with tmpdir.as_cwd(): + tmpdir.join("pyproject.toml").write("[tool.foo]\nbar = 'baz'") + tmpdir.join(".cz.toml").write(TOML_STR) + + cfg = config.read_cfg() + captured = capsys.readouterr() + assert "Multiple config files detected" not in captured.err + assert cfg.path == Path(".cz.toml") + @pytest.mark.parametrize( "config_file", diff --git a/tests/test_deprecated.py b/tests/test_deprecated.py index 41bea81a73..6e695c300c 100644 --- a/tests/test_deprecated.py +++ b/tests/test_deprecated.py @@ -5,26 +5,28 @@ def test_getattr_deprecated_vars(): # Test each deprecated variable - with pytest.warns(DeprecationWarning) as record: + with pytest.warns(DeprecationWarning, match="is deprecated and will be removed"): assert defaults.bump_pattern == defaults.BUMP_PATTERN + with pytest.warns(DeprecationWarning, match="is deprecated and will be removed"): assert defaults.bump_map == defaults.BUMP_MAP + with pytest.warns(DeprecationWarning, match="is deprecated and will be removed"): assert ( defaults.bump_map_major_version_zero == defaults.BUMP_MAP_MAJOR_VERSION_ZERO ) + with pytest.warns(DeprecationWarning, match="is deprecated and will be removed"): assert defaults.bump_message == defaults.BUMP_MESSAGE + with pytest.warns(DeprecationWarning, match="is deprecated and will be removed"): assert defaults.change_type_order == defaults.CHANGE_TYPE_ORDER + with pytest.warns(DeprecationWarning, match="is deprecated and will be removed"): assert defaults.encoding == defaults.ENCODING + with pytest.warns(DeprecationWarning, match="is deprecated and will be removed"): assert defaults.name == defaults.DEFAULT_SETTINGS["name"] + with pytest.warns(DeprecationWarning, match="is deprecated and will be removed"): assert ( changelog_formats._guess_changelog_format == changelog_formats.guess_changelog_format ) - # Verify warning messages - assert len(record) == 7 - for warning in record: - assert "is deprecated and will be removed" in str(warning.message) - def test_getattr_non_existent(): # Test non-existent attribute diff --git a/tests/test_factory.py b/tests/test_factory.py index 20ce49d781..303ae4e728 100644 --- a/tests/test_factory.py +++ b/tests/test_factory.py @@ -52,14 +52,13 @@ class Plugin: pass ) sys.path.append(tmp_path.as_posix()) - with pytest.warns(UserWarning) as record: + with pytest.warns( + UserWarning, + match="Legacy plugin 'cz_legacy' has been ignored: please expose it the 'commitizen.plugin' entrypoint", + ): discovered_plugins = discover_plugins([tmp_path.as_posix()]) sys.path.pop() - assert ( - record[0].message.args[0] - == "Legacy plugin 'cz_legacy' has been ignored: please expose it the 'commitizen.plugin' entrypoint" - ) assert "cz_legacy" not in discovered_plugins diff --git a/tests/test_tags.py b/tests/test_tags.py new file mode 100644 index 0000000000..2471b8461b --- /dev/null +++ b/tests/test_tags.py @@ -0,0 +1,101 @@ +from commitizen.git import GitTag +from commitizen.tags import TagRules + + +def _git_tag(name: str) -> GitTag: + return GitTag(name, "rev", "2024-01-01") + + +def test_find_tag_for_partial_version_returns_latest_match(): + tags = [ + _git_tag("1.2.0"), + _git_tag("1.2.2"), + _git_tag("1.2.1"), + _git_tag("1.3.0"), + ] + + rules = TagRules() + + found = rules.find_tag_for(tags, "1.2") + + assert found is not None + assert found.name == "1.2.2" + + +def test_find_tag_for_full_version_remains_exact(): + tags = [ + _git_tag("1.2.0"), + _git_tag("1.2.2"), + _git_tag("1.2.1"), + ] + + rules = TagRules() + + found = rules.find_tag_for(tags, "1.2.1") + + assert found is not None + assert found.name == "1.2.1" + + +def test_find_tag_for_partial_version_with_prereleases_prefers_latest_version(): + tags = [ + _git_tag("1.2.0b1"), + _git_tag("1.2.0"), + _git_tag("1.2.1b1"), + ] + + rules = TagRules() + + found = rules.find_tag_for(tags, "1.2") + + assert found is not None + # 1.2.1b1 > 1.2.0 so it should be selected + assert found.name == "1.2.1b1" + + +def test_find_tag_for_partial_version_respects_tag_format(): + tags = [ + _git_tag("v1.2.0"), + _git_tag("v1.2.1"), + _git_tag("v1.3.0"), + ] + + rules = TagRules(tag_format="v$version") + + found = rules.find_tag_for(tags, "1.2") + + assert found is not None + assert found.name == "v1.2.1" + + found = rules.find_tag_for(tags, "1") + + assert found is not None + assert found.name == "v1.3.0" + + +def test_find_tag_for_partial_version_returns_none_when_no_match(): + tags = [ + _git_tag("2.0.0"), + _git_tag("2.1.0"), + ] + + rules = TagRules() + + found = rules.find_tag_for(tags, "1.2") + + assert found is None + + +def test_find_tag_for_partial_version_ignores_invalid_tags(): + tags = [ + _git_tag("not-a-version"), + _git_tag("1.2.0"), + _git_tag("1.2.1"), + ] + + rules = TagRules() + + found = rules.find_tag_for(tags, "1.2") + + assert found is not None + assert found.name == "1.2.1" diff --git a/tests/test_version_scheme_pep440.py b/tests/test_version_scheme_pep440.py index 0ce4f81545..3c15eeb4a9 100644 --- a/tests/test_version_scheme_pep440.py +++ b/tests/test_version_scheme_pep440.py @@ -249,16 +249,6 @@ ), "0.1.1.dev1", ), - ( - VersionSchemeTestArgs( - current_version="0.1.1", - increment="MINOR", - prerelease=None, - prerelease_offset=0, - devrelease=None, - ), - "0.2.0", - ), ( VersionSchemeTestArgs( current_version="0.2.0", @@ -733,26 +723,6 @@ ), "1.1.0a0", ), - ( - VersionSchemeTestArgs( - current_version="1.1.0a0", - increment="PATCH", - prerelease="alpha", - prerelease_offset=0, - devrelease=None, - ), - "1.1.0a1", - ), - ( - VersionSchemeTestArgs( - current_version="1.1.0a1", - increment="MINOR", - prerelease="alpha", - prerelease_offset=0, - devrelease=None, - ), - "1.1.0a2", - ), ( VersionSchemeTestArgs( current_version="1.1.0a2", @@ -1020,17 +990,6 @@ ), "3.1.4rc0", ), - # - ( - VersionSchemeTestArgs( - current_version="3.1.4", - increment=None, - prerelease="alpha", - prerelease_offset=0, - devrelease=None, - ), - "3.1.4a0", - ), ( VersionSchemeTestArgs( current_version="3.1.4a0", diff --git a/tests/test_version_scheme_semver.py b/tests/test_version_scheme_semver.py index 8a163d4f6b..1a75cd3eae 100644 --- a/tests/test_version_scheme_semver.py +++ b/tests/test_version_scheme_semver.py @@ -271,16 +271,6 @@ ), "0.1.1-dev1", ), - ( - VersionSchemeTestArgs( - current_version="0.1.1", - increment="MINOR", - prerelease=None, - prerelease_offset=0, - devrelease=None, - ), - "0.2.0", - ), ( VersionSchemeTestArgs( current_version="0.2.0", diff --git a/tests/test_version_scheme_semver2.py b/tests/test_version_scheme_semver2.py index 4a35e6470a..6ce00e06ed 100644 --- a/tests/test_version_scheme_semver2.py +++ b/tests/test_version_scheme_semver2.py @@ -220,16 +220,6 @@ ), "1.0.0-beta.1", ), - ( - VersionSchemeTestArgs( - current_version="1.0.0-alpha.1", - increment=None, - prerelease="alpha", - prerelease_offset=0, - devrelease=None, - ), - "1.0.0-alpha.2", - ), ( VersionSchemeTestArgs( current_version="1", @@ -271,16 +261,6 @@ ), "0.1.1-dev.1", ), - ( - VersionSchemeTestArgs( - current_version="0.1.1", - increment="MINOR", - prerelease=None, - prerelease_offset=0, - devrelease=None, - ), - "0.2.0", - ), ( VersionSchemeTestArgs( current_version="0.2.0", @@ -391,16 +371,6 @@ ), "1.0.0-alpha.1", ), - ( - VersionSchemeTestArgs( - current_version="1.0.0-alpha.1", - increment=None, - prerelease="alpha", - prerelease_offset=0, - devrelease=None, - ), - "1.0.0-alpha.2", - ), ( VersionSchemeTestArgs( current_version="1.0.0-alpha.1", @@ -451,16 +421,6 @@ ), "1.0.0-beta.1", ), - ( - VersionSchemeTestArgs( - current_version="1.0.0-beta.1", - increment=None, - prerelease="rc", - prerelease_offset=0, - devrelease=None, - ), - "1.0.0-rc.0", - ), ( VersionSchemeTestArgs( current_version="1.0.0-rc.0", diff --git a/tests/test_version_schemes.py b/tests/test_version_schemes.py index 7b1ec7579a..0f38f90d80 100644 --- a/tests/test_version_schemes.py +++ b/tests/test_version_schemes.py @@ -38,7 +38,7 @@ def test_raise_for_unknown_version_scheme(config: BaseConfig): def test_version_scheme_from_deprecated_config(config: BaseConfig): config.settings["version_type"] = "semver" - with pytest.warns(DeprecationWarning): + with pytest.warns(DeprecationWarning, match="Please use `version_scheme` instead"): scheme = get_version_scheme(config.settings) assert scheme is SemVer @@ -46,7 +46,7 @@ def test_version_scheme_from_deprecated_config(config: BaseConfig): def test_version_scheme_from_config_priority(config: BaseConfig): config.settings["version_scheme"] = "pep440" config.settings["version_type"] = "semver" - with pytest.warns(DeprecationWarning): + with pytest.warns(DeprecationWarning, match="Please use `version_scheme` instead"): scheme = get_version_scheme(config.settings) assert scheme is Pep440