Skip to main content

comlipy by slashplus - lint commit messages with python

Project description

comlipy by slashplus - lint commit messages with python

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) or brew
  • poetry

Installation

Installation with brew (recommended)

# 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 poetry:

git clone git@gitlab.com:slashplus-build/comlipy.git # clone repo
cd comlipy/ # change to comlipy directory
poetry install # install dependencies

Run comlipy:

poetry shell # open the virtual environment

# or just run a single command
# poetry run comlipy-install

Usage

Setting up a git commit-msg hook (optional)

Comlipy comes with a simple git commit-msg hook installer. This sets up a commit-msg hook that checks the commit message before the actual commit.
An example commit-msg hook can be found here

Make sure you have initialized git in your project. And then just run comlipy-install, or comlipy-install -c 'PATH/TO/CUSTOM/CONFIGFILE.yml' if you want to set a default config override.

Note:
Don't worry, the installer will not automatically override an existing commit-msg hook. In case such file already exists, you will be asked if you want to override it.

Tip:
Sometimes it can be useful to to set up a custom git hooks path, instead of overriding the commit-msg hook directly.
Learn more about it here.

Setting up a a custom configuration override (optional)

Its on you to configure comlipy so it perfectly fits your needs by setting up and passing a custom configuration yml file. By doing this, you can override the default configuration i.e. enable or disable rules or changing the message behaviour (none, warning, error).

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 validation rules with configuration values
  • ignores: Reference of default validation ignores and how to add custom ignores
  • 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 YAML 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-comlipy.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
ignores:
    - '^SKIPME' #skip validations where header starts with "SKIPME"

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.2.1.tar.gz (20.5 kB view details)

Uploaded Source

Built Distribution

comlipy-1.2.1-py3-none-any.whl (33.8 kB view details)

Uploaded Python 3

File details

Details for the file comlipy-1.2.1.tar.gz.

File metadata

  • Download URL: comlipy-1.2.1.tar.gz
  • Upload date:
  • Size: 20.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/47.1.1 requests-toolbelt/0.9.1 tqdm/4.47.0 CPython/3.8.3

File hashes

Hashes for comlipy-1.2.1.tar.gz
Algorithm Hash digest
SHA256 cc5253dd55f002f958cfab56dec7af714d42b8cfb0171a591157b1440c4d6878
MD5 c2d684d28b5d210c5f9537c4d1e84bd1
BLAKE2b-256 fa21236be034d8498d264ba96ebc386dde29fbd2bedcb1d58277dbcc0d470e6c

See more details on using hashes here.

File details

Details for the file comlipy-1.2.1-py3-none-any.whl.

File metadata

  • Download URL: comlipy-1.2.1-py3-none-any.whl
  • Upload date:
  • Size: 33.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/47.1.1 requests-toolbelt/0.9.1 tqdm/4.47.0 CPython/3.8.3

File hashes

Hashes for comlipy-1.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 aa836b8ff7184661727f987def812f3d084e1599cbdd8076613d0dafc5264996
MD5 d294730e41278118506ad073fe0f0ea7
BLAKE2b-256 4209f95b2e85d6bffdf0f166b1e6e6665743254b6f4dcd40956f1c032a3e983f

See more details on using hashes here.

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