Skip to main content

comlipy - git commit linting for python by slashplus

Project description

comlipy - git commit linting for python by slashplus

Demo generated with svg-term-cli

comlipy is a helper that makes it incredibly easy to check whether your commit messages follow predefined or custom commit message standards or not.

This means that after setting up comlipy in combination with a custom git commit-msg hook (further information), comlipy takes care of the provided commit msg and warns you whenever a message does not fit your style.

By default comlipy follows the conventional commit standards, but you can easily change the configuration in order to fit your needs.

Requirements

  • python 3.7
  • pip (pip3) & pipenv

Installation

Installation with brew

# Add the source
brew tap slashplus/comlipy git@gitlab.com:slashplus-build/comlipy.git

# Install comlipy
brew install comlipy

Installation with pip

pip3 install comlipy

Development installation

Install the repository by git cloning it and by setting up a virtual environment using pipenv:

git clone git@gitlab.com:slashplus-build/comlipy.git
cd comlipy/
pipenv install

# OR optional: install the current version globally
# pip3 install .

Run comlipy:

pipenv shell

Usage

Make sure you have initialized git in your project.

Set up a commit-msg hook that checks the commit message before the actual commit.
An example commit-msg hook can be found here

Tip:
It is recommended to set up a custom git hooks path, instead of overriding the commit-msg hook directly.
Learn more about it here.

[Optional:] Configure comlipy by setting up a custom configuration yml file

See docs for further details.

Documentation

Documentation is currently not finished. Following a list of available references:

  • docs: ALL documents
  • rules: Reference of all available rules with configuration values
  • commit-msg sample hook: Example git commit-msg hook
  • cli: List of available cli flags

Configuration

It is possible to change the configuration values. This way you are able to change rule behaviour of all rules by providing values for applicable, value, level or you can change global settings i.e. the help message.

Therefore you must define a custom yml file with the rules to override and pass the custom config file path via parameter:

If a config rule is not set, the default value will be used instead.

Example config.yml

## global definitions
global:
  help: 'get help here: foo-bar-baz.abc'

rules:
  header-min-length:
    applicable: 'always'
    value: 0
    level: 1
  header-max-length: 
    applicable: 'always'
    value: 123
    level: 2
  scope-case:
    value: 'upper-case'
  scope-empty:
    applicable: 'never'
    level: 2

Tests

You can run unit.tests by following the python 3 unittest documentation. For example:

python -m unittest comlipy.tests.lib.test_ensure
python -m unittest comlipy.tests.lib.test_rule_checker

or run all tests in batch:

# optionally run it in verbose mode (-v)
python -m unittest -v comlipy.tests.suite

Credits & inspiration

Project details


Download files

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

Source Distribution

comlipy-1.0.0.tar.gz (17.8 kB view hashes)

Uploaded Source

Built Distribution

comlipy-1.0.0-py3-none-any.whl (31.7 kB view hashes)

Uploaded Python 3

Supported by

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