Skip to main content

pccc

The Python Conventional Commit Checker.

PyPI Version Documentation Status

Description

pccc is a PyParsing based grammar and script for parsing and verifying a commit message is a conventional commit. The default grammar follows the specification, but allows for the definition of types in addition to feat and fix and for the definition of project specific scopes and footers in compliance with the specification. The maximum line lengths of the commit header and commit body and spelling can also be checked.

Currently, the script interface will load configuration options and a commit message and attempt to parse it. If there are no parse exceptions, it will return 0, otherwise 1. This interface should be usable at the git commit-msg hook stage now. It can also be configured to ignore certain automatically generated commits (from git pull for instance) if it is not desirable or possible to generate those commits as conventional commits (preferable).

Parsing Grammar

Github Closes Issue Syntax

  • KEYWORD = ‘(close[ds]?|fix(?:es|ed)?|resolve[ds]?)’

  • OWNER = ‘^[a-zA-Z0-9](?:[a-zA-Z0-9]|-(?=[a-zA-Z0-9])){0,38}$’

  • REPOSITORY = ‘^[a-zA-Z0-9](?:[a-zA-Z0-9]|-(?=[a-zA-Z0-9])){0,38}$’

  • ISSUE-NUMBER = ‘#d+’

  • Single issue in same repository: KEYWORD #ISSUE-NUMBER

  • Single issue in different repository: KEYWORD OWNER/REPOSITORY ISSUE-NUMBER

  • Multiple issues: use full syntax for each issue

The parser in pccc requires separating multiple issues on the Github-issues line with “, “.

See:

  1. https://docs.github.com/en/issues/tracking-your-work-with-issues/linking-a-pull-request-to-an-issue/

  2. https://github.com/shinn/github-username-regex/

Installation

Install pccc with:

pip install pccc
pip freeze > requirements.txt

or add as a poetry dev-dependency.

If you desire a package locally built with poetry, download the source, change the appropriate lines in pyproject.toml, and rebuild.

To use as a git commit-msg hook, copy the script pccc to .git/hooks/commit-msg and set the file as executable or integrate the script or module into your existing commit-msg hook. pccc relies on git setting the current working directory of the script to the root of the repository (where pyproject.toml or package.json typically lives). If this is not the repository default, pass the configuration file path as an argument or symlink from the current working directory to an appropriate configuration file.

Usage

Console:

pccc COMMIT_MSG
cat COMMIT_MSG | pccc

In Python:

>>> import pccc
>>> ccr = pccc.ConventionalCommitRunner()
>>> ccr.options.load()
>>> ccr.raw = "some commit message"
>>> ccr.clean()
>>> ccr.parse()
>>> if ccr.exc == None:
...     print(ccr)

See the source and documentation for more information.

Configuration

See pccc.toml for an example [tool.pccc] section that may be copied into a pyproject.toml file. The same entries may be used in a pccc entry in package.json for JavaScript/TypeScript projects.

Author

Jeremy A Gray

Metadata

Release files for pccc 0.4.14

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pccc 0.4.14
File Size Uploaded
pccc-0.4.14.tar.gz 204.2 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for pccc 0.4.14
File Interpreter ABI Platform
pccc-0.4.14-py3-none-any.whl Python 3 none any Details

Total release size: 234.2 kB

Release files / pccc-0.4.14.tar.gz

Download URL pccc-0.4.14.tar.gz
Size 204.2 kB
Tags Source
SHA-256 checksum
How to use checksums
286cb8880a45ca0db683a22ac103c79f2c66f8f10a14d7d96b8887df4b50201f
BLAKE2b-256 checksum
How to use checksums
213962499556598ff06c163bda898d19a262b7025ec2e851d209f7cb638845e2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.11.2

Release files / pccc-0.4.14-py3-none-any.whl

Download URL pccc-0.4.14-py3-none-any.whl
Size 30.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
7e88ad3a3a5c0a90bb6663a39e7afbeb2a88aa5862b4f3cfd4a15c43c42ac3a5
BLAKE2b-256 checksum
How to use checksums
1a3b19acc8c940c398334183d0b0024a77dd1944a26e4149b2c06d9df2d3be6b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.11.2

Release history Release notifications | RSS feed

This release

0.4.14 This release

2 release files

0.4.13

2 release files

0.4.10

2 release files

0.4.9

2 release files

0.4.8

2 release files

0.4.7

2 release files

0.4.6

2 release files

0.4.5

2 release files

0.4.4

2 release files

0.4.3

2 release files

0.4.2

2 release files

0.4.1

2 release files

0.4.0

2 release files

0.3.4

2 release files

0.3.3

2 release files

0.3.2

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page