CtrlK
BlogDocsLog inGet started
Tessl Logo

tessl/pypi-commitizen

Python commitizen client tool for standardized commit conventions and automated version management

Pending

Quality

Pending

Does it follow best practices?

Impact

Pending

No eval scenarios have been run

Overview
Eval results
Files

commands.mddocs/

CLI Commands

Comprehensive command-line interface for interactive commit creation, version management, changelog generation, and project configuration. All commands are available through the cz or git-cz CLI tools.

Capabilities

Main Entry Point

The primary CLI entry point that handles argument parsing, command dispatch, and exception handling.

def main() -> None:
    """
    Main CLI entry point.
    
    Handles command-line argument parsing, command dispatch, and exception handling.
    Sets up logging, processes global options, and invokes the appropriate command.
    """

CLI Utilities

Utility classes and functions for command-line argument parsing and exception handling.

class ParseKwargs:
    """
    Argparse action for parsing key=value arguments.
    
    Handles quoted strings and multiple key-value pairs for CLI options.
    """
    def __call__(
        self,
        parser: argparse.ArgumentParser,
        namespace: argparse.Namespace,
        kwarg: str | Sequence[Any] | None,
        option_string: str | None = None
    ) -> None: ...

def commitizen_excepthook(
    exc_type: type[BaseException],
    exc_value: BaseException,
    traceback: TracebackType | None
) -> None:
    """
    Custom exception handler for commitizen CLI.
    
    Provides user-friendly error messages and proper exit codes.
    """

def parse_no_raise(value: str) -> list[int]:
    """
    Parse comma-separated exit codes without raising exceptions.
    
    Parameters:
    - value: Comma-separated string of exit codes
    
    Returns:
    List of integer exit codes
    """

Version Bumping

Automatically increments project version based on commit history using semantic versioning rules, with support for changelog generation and file updates.

class Bump:
    """
    Command for automatically bumping project version based on commit history.
    
    Supports semantic versioning, changelog generation, file updates, and hooks.
    """
    def __init__(self, config: BaseConfig, arguments: dict[str, Any]):
        """
        Initialize bump command.
        
        Parameters:
        - config: Configuration object
        - arguments: Command arguments dictionary containing:
            - increment: Version increment type (MAJOR, MINOR, PATCH)
            - prerelease: Prerelease identifier (alpha, beta, rc)
            - changelog: Generate changelog during bump
            - changelog_to_stdout: Output changelog to stdout
            - dry_run: Show what would be changed without making changes
            - files_only: Only update version files, skip git operations
            - local_version: Use local version format
            - manual_version: Manually specify version
            - yes: Skip confirmation prompts
            - major_version_zero: Allow 0.x version handling
            - retry_after_failure: Retry after failed operations
        """
    
    def __call__(self) -> None:
        """
        Execute version bump operation.
        
        Raises:
        DryRunExit: When dry_run is True
        NotAGitProjectError: When not in a git repository
        NoCommitsFoundError: When no commits found for increment
        """

Interactive Commit Creation

Provides interactive prompts for creating standardized commit messages following configured commit conventions.

class Commit:
    """
    Command for creating commits interactively using configured rules.
    
    Prompts user with questions defined by the active commitizen plugin.
    """
    def __init__(self, config: BaseConfig, arguments: dict[str, Any]):
        """
        Initialize commit command.
        
        Parameters:
        - config: Configuration object
        - arguments: Command arguments dictionary containing:
            - retry: Retry using previous commit message
            - no_retry: Disable retry functionality
            - dry_run: Show commit message without creating commit
            - write_message_to_file: Write message to file instead of committing
            - signoff: Add Signed-off-by trailer
            - all: Automatically stage all modified files
            - edit: Open editor for commit message
            - message_length_limit: Maximum commit message length
            - extra_cli_args: Additional git commit arguments
        """
    
    def __call__(self) -> None:
        """
        Execute interactive commit creation.
        
        Raises:
        DryRunExit: When dry_run is True
        NotAGitProjectError: When not in a git repository
        NoneIncrementExit: When no changes to commit
        """

Commit Message Validation

Validates commit messages against configured rules, useful for git hooks and CI/CD pipelines.

class Check:
    """
    Command for validating commit messages against configured rules.
    
    Can check single commits, commit ranges, or commit message files.
    """
    def __init__(self, config: BaseConfig, arguments: dict[str, Any], cwd: str = None):
        """
        Initialize check command.
        
        Parameters:
        - config: Configuration object
        - arguments: Command arguments dictionary containing:
            - commit_msg_file: Path to commit message file
            - rev_range: Git revision range to check
            - message: Direct commit message to validate
            - allow_abort: Allow abort messages
            - allowed_prefixes: Additional allowed commit prefixes
            - message_length_limit: Maximum message length
        - cwd: Working directory (optional)
        """
    
    def __call__(self) -> None:
        """
        Execute commit message validation.
        
        Raises:
        CommitMessageLengthExceededError: When message too long
        InvalidMessageTypeError: When commit type invalid
        """

Changelog Generation

Generates and maintains changelogs in various formats based on commit history and configured templates.

class Changelog:
    """
    Command for generating and maintaining project changelogs.
    
    Supports multiple formats and incremental updates.
    """
    def __init__(self, config: BaseConfig, args: dict[str, Any]):
        """
        Initialize changelog command.
        
        Parameters:
        - config: Configuration object
        - args: Command arguments dictionary containing:
            - file_name: Output changelog file path
            - incremental: Generate only new entries since last version
            - dry_run: Output changelog to stdout without writing file
            - start_rev: Starting revision for changelog generation
            - rev_range: Git revision range for changelog
            - unreleased_version: Version for unreleased changes
            - merge_prerelease: Merge prerelease entries into final release
            - format: Changelog format (markdown, asciidoc, textile, rst)
            - template: Custom Jinja2 template path
            - extras: Additional template variables
            - version_scheme: Version scheme to use
            - current_version: Current version override
            - tag_format: Git tag format
            - export_template: Export template to file
        """
    
    def __call__(self) -> None:
        """
        Execute changelog generation.
        
        Raises:
        NotAGitProjectError: When not in a git repository
        NoCommitsFoundError: When no commits found
        """

Project Initialization

Initializes commitizen configuration in existing projects with interactive setup.

class Init:
    """
    Command for initializing commitizen configuration in projects.
    
    Creates configuration files with user-selected options.
    """
    def __init__(self, config: BaseConfig, *args):
        """
        Initialize init command.
        
        Parameters:
        - config: Configuration object
        - args: Variable arguments (config path determined interactively)
        """
    
    def __call__(self) -> None:
        """
        Execute project initialization.
        
        Prompts user for configuration options and creates config file.
        """

Version Information

Displays version information for the commitizen tool and current project.

class Version:
    """
    Command for displaying version information.
    
    Shows commitizen version and optionally project version.
    """
    def __init__(self, config: BaseConfig, *args):
        """
        Initialize version command.
        
        Parameters:
        - config: Configuration object
        - args: Parameter dictionary containing:
            - report: Show detailed version report
            - project: Show project version instead of commitizen version
            - verbose: Show additional version details
        """
    
    def __call__(self) -> None:
        """
        Execute version display.
        
        Prints version information to stdout.
        """

Information Display

Shows information about the currently configured commitizen plugin including rules and patterns.

class Info:
    """
    Command for displaying information about configured commitizen plugin.
    
    Shows plugin details, rules, and configuration.
    """
    def __init__(self, config: BaseConfig, *args):
        """
        Initialize info command.
        
        Parameters:
        - config: Configuration object
        """
    
    def __call__(self) -> None:
        """
        Execute information display.
        
        Prints plugin information to stdout.
        """

Commit Examples

Displays example commit messages following the configured commit rules.

class Example:
    """
    Command for displaying example commit messages.
    
    Shows examples based on configured commit rules.
    """
    def __init__(self, config: BaseConfig, *args):
        """
        Initialize example command.
        
        Parameters:
        - config: Configuration object
        """
    
    def __call__(self) -> None:
        """
        Execute example display.
        
        Prints example commit messages to stdout.
        """

Schema Display

Shows the commit message schema and validation patterns for the configured plugin.

class Schema:
    """
    Command for displaying commit message schema.
    
    Shows validation patterns and structure requirements.
    """
    def __init__(self, config: BaseConfig, *args):
        """
        Initialize schema command.
        
        Parameters:
        - config: Configuration object
        """
    
    def __call__(self) -> None:
        """
        Execute schema display.
        
        Prints commit message schema to stdout.
        """

Plugin Listing

Lists all available commitizen plugins installed on the system.

class ListCz:
    """
    Command for listing available commitizen plugins.
    
    Shows installed plugins and their sources.
    """
    def __init__(self, config: BaseConfig, *args):
        """
        Initialize list command.
        
        Parameters:
        - config: Configuration object
        """
    
    def __call__(self) -> None:
        """
        Execute plugin listing.
        
        Prints available plugins to stdout.
        """

Usage Examples

Basic CLI Usage

# Interactive commit creation
cz commit
cz c  # shortcut

# Version bumping with changelog
cz bump --changelog

# Validate commit messages
cz check --commit-msg-file .git/COMMIT_EDITMSG
cz check --rev-range origin/main..HEAD

# Generate changelog
cz changelog --incremental
cz changelog --dry-run

# Initialize configuration
cz init

# Show information
cz version --project
cz info
cz example
cz schema
cz list-cz

Programmatic Usage

from commitizen.commands import Bump, Check, Commit
from commitizen.config import BaseConfig

# Configure
config = BaseConfig()
config.set_key("name", "cz_conventional_commits")
config.set_key("version", "1.0.0")

# Create commit
commit_args = {"dry_run": True, "retry": False}
commit_cmd = Commit(config, commit_args)
commit_cmd()

# Bump version
bump_args = {
    "increment": "MINOR",
    "changelog": True,
    "dry_run": False
}
bump_cmd = Bump(config, bump_args)
bump_cmd()

# Validate commits
check_args = {"rev_range": "origin/main..HEAD"}
check_cmd = Check(config, check_args)
check_cmd()

Install with Tessl CLI

npx tessl i tessl/pypi-commitizen

docs

commands.md

configuration.md

git-operations.md

index.md

plugins.md

version-management.md

tile.json