Skip to main content

Python commitizen client tool.

Project description

Python 3 command line utility to standardize commit messages

Conventional Commits PyPI Package latest release Supported versions

About

This client tool prompts the user with information about the commit.

Based on conventional commits

Example running commitizen

This is an example of how the git messages history would look like:

docs: improved commitizens tab in readme
feat(cz): jira smart commits
refactor(cli): renamed all to ls command
refactor(cz): renamed angular cz to conventional changelog cz
feat: info command for angular
docs(README): added badges
docs(LICENSE): new one
docs(README): added about, installation, creating, etc
chore(bumpversion): configured and added as dev dep
feat(config): new loads from ~/.cz and working project .cz .cz.cfg and setup.cfg

Commitizens

These are the available commiting styles by default:

The installed ones can be checked with:

cz ls

Installation

pip install commitizen

Commiting

Run in your terminal

cz commit

or the shortcut

cz c

Usage

usage: cz [-h] [--debug] [-n NAME] {ls,commit,c,example,info,schema} ...

Commitizen is a cli tool to generate conventional commits.
For more information about the topic go to https://conventionalcommits.org/

optional arguments:
  -h, --help            show this help message and exit
  --debug               use debug mode
  -n NAME, --name NAME  use the given commitizen

commands:
  {ls,commit,c,example,info,schema}
    ls                 show available commitizens
    commit (c)          create new commit
    example             show commit example
    info                show information about the cz
    schema              show commit schema

Configuration

You can create in your project folder a file called .cz, .cz.cfg or in your setup.cfg or if you want to configure the global default in your user’s home folder a .cz file with the following information:

[commitizen]
name = cz_conventional_changelog

Creating a commiter

Create a file starting with cz_ for example cz_jira.py. This prefix is used to detect the plugin. Same method flask uses

Inherit from BaseCommitizen and you must define questions and message. The others are optionals.

from commitizen import BaseCommitizen

class JiraCz(BaseCommitizen):

    def questions(self):
        """Questions regarding the commit message.

        Must have 'whaaaaat' format.
        More info: https://github.com/finklabs/whaaaaat/

        :rtype: list
        """
        questions = [
            {
                'type': 'input',
                'name': 'title',
                'message': 'Commit title'
            },
            {
                'type': 'input',
                'name': 'issue',
                'message': 'Jira Issue number:'
            },
        ]
        return questions

    def message(self, answers):
        """Generate the message with the given answers.

        :type answers: dict
        :rtype: string
        """
        return '{0} (#{1})'.format(answers['title'], answers['issue'])

    def example(self):
        """Provide an example to help understand the style (OPTIONAL)
        Used by cz example.

        :rtype: string
        """
        return 'Problem with user (#321)'

    def schema(self):
        """Show the schema used (OPTIONAL)

        :rtype: string
        """
        return '<title> (<issue>)'

    def info(self):
        """Explanation of the commit rules. (OPTIONAL)
        :rtype: string
        """
        return 'We use this because is useful'


discover_this = JiraCz  # used by the plugin system

The next file required is setup.py modified from flask version

from distutils.core import setup

setup(
    name='JiraCommitizen',
    version='0.1.0',
    py_modules=['cz_jira'],
    license='MIT',
    long_description='this is a long description',
    install_requires=['commitizen']
)

So at the end we would have

.
├── cz_jira.py
└── setup.py

And that’s it, you can install it without uploading to pypi by simply doing pip install . If you feel like it should be part of the repo, create a PR.

Todo

  • [ ] auto changelog integration

  • [ ] tests

Project details


Release history Release notifications | RSS feed

This version

0.8.4

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

commitizen-0.8.4.tar.gz (9.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

commitizen-0.8.4-py2.py3-none-any.whl (12.9 kB view details)

Uploaded Python 2Python 3

File details

Details for the file commitizen-0.8.4.tar.gz.

File metadata

  • Download URL: commitizen-0.8.4.tar.gz
  • Upload date:
  • Size: 9.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for commitizen-0.8.4.tar.gz
Algorithm Hash digest
SHA256 6971a53d5ec900a2fed8a02a665dd9960c9334647fde6e41e95b04edab51ae71
MD5 11aedca9630003ce5d96f5fce9c23f96
BLAKE2b-256 898aee719864d2968186e26222b1462d2ed664575db8d3bd46a15692e496f82f

See more details on using hashes here.

File details

Details for the file commitizen-0.8.4-py2.py3-none-any.whl.

File metadata

File hashes

Hashes for commitizen-0.8.4-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 ffbf25cf31b95951a82a5a47b8be3ff63d51be0f8584cd670fee49fc4bb9b80b
MD5 cc17621d101eb38d374e306bedd89c53
BLAKE2b-256 e06d4b766abf4609cb4f9302bb692a465ff480bb467f2c9ce527c7b106366d59

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page