Python 2 command line utility to standardize commit messages
This client tool prompts the user with information about the commit.
Based on conventional commits
These are the available commiting styles by default:
- cz_conventional_changelog: angular's conventional changelog
- cz_jira: jira smart commits
The installed ones can be checked with:
cz ls
pip install commitizen
Run in your terminal
cz commit
or the shortcut
cz c
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
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_angular
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.
fromcommitizenimportBaseCommitizenclassJiraCz(BaseCommitizen):
defquestions(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:'
},
]
returnquestionsdefmessage(self, answers):
"""Generate the message with the given answers. :type answers: dict :rtype: string """return'{0} (#{1})'.format(answers['title'], answers['issue'])
defexample(self):
"""Provide an example to help understand the style (OPTIONAL) Used by cz example. :rtype: string """return'Problem with user (#321)'defschema(self):
"""Show the schema used (OPTIONAL) :rtype: string """return'<title> (<issue>)'definfo(self):
"""Explanation of the commit rules. (OPTIONAL) :rtype: string """return'We use this because is useful'discover_this=JiraCz# used by the plugin systemThe next file required is setup.py modified from flask version
fromdistutils.coreimportsetupsetup(
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.
- [ ] auto changelog integration
- [ ] tests
