Skip to content

ranshamay/commitizen

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Commitizen

Python 3 command line utility to standardize commit messages

[![Conventional Commits](https://img.shields.io/badge/Conventional%20Commits-1.0.0-yellow.svg?style=flat-square)](https://conventionalcommits.org)

About

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

Based on conventional commits

By default it uses angular guidelines

Installation

pip install commitizen

Usage

Run in your terminal

cz

Help

cz --help

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 by doing pip install .

Todo

  • [ ] auto changelog integration
  • [ ] tests

About

Python 3 commitizen client tool

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Python 100.0%