Skip to main content

Python Conventional Commit Checker

Project description

The Python Conventional Commit Checker.

PyPI Version Documentation Status

What is pccc?

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.

Roadmap

  1. Finish body wrapping. (target: 0.5.0)

    • fail if over

    • rewrap if over

    • do nothing if fine

    • rewrap if fine

  2. Implement spell checking. (target: 0.6.0)

    • will not autocorrect

    • communication: kick back to editor on errors, with comment line to indicate acceptance

  3. Implement simple reformatting. (target: 0.7.0)

    • footer separator as “: “ and not “ #”

    • “BREAKING-CHANGE” not “BREAKING CHANGE”

    • set breaking flag (!) and “BREAKING-CHANGE”

    • correct token capitalization (“BREAKING-CHANGE” not “breaking-change” or “Breaking-Change”; “Signed-off-by” not “Signed-Off-By” or “signed-off-by”)

  4. Implement partial parsing on failure for correction and improved exception handling. (target: 0.9.0 or later)

    • header partial parsing

    • body partial parsing

    • breaking change partial parsing

    • footer partial parsing

  5. Implement custom hooks for handling per-project footers. (target: 0.9.0 or later)

  6. Integrate argparse help into documentation. (done: 0.3.3)

  7. Insert license information into all source files. (done: 0.3.3)

  8. Complete upload and build for setuptools/pip and poetry. (done: 0.3.3; poetry is configured but not used)

  9. Complete documentation integration and upload at Read The Docs. (done: 0.3.3)

  10. Github issue template based off current tests/good/*.json files, with guidelines. (done: 0.3.3)

  11. JSON configuration support, via pccc entry in package.json. (done: 0.3.3)

  12. 100% test coverage, with tests implemented before merging. (done: 0.3.4)

  13. Add and configure tox. (done: 0.4.0)

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

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

pccc-0.4.1.tar.gz (261.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pccc-0.4.1-py3-none-any.whl (24.1 kB view details)

Uploaded Python 3

File details

Details for the file pccc-0.4.1.tar.gz.

File metadata

  • Download URL: pccc-0.4.1.tar.gz
  • Upload date:
  • Size: 261.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.6.1 requests/2.25.1 setuptools/51.1.1 requests-toolbelt/0.9.1 tqdm/4.55.1 CPython/3.9.1

File hashes

Hashes for pccc-0.4.1.tar.gz
Algorithm Hash digest
SHA256 2d0074ecb5a1bdcf32d156be86e63cfa45d76284a5bd63738f6d54bf644fe37f
MD5 54a279ea559d474ba40de50866cd39b4
BLAKE2b-256 5be49803df8491ed9e98592e9d7845315cf10011132e8e5584e712434e8f1629

See more details on using hashes here.

File details

Details for the file pccc-0.4.1-py3-none-any.whl.

File metadata

  • Download URL: pccc-0.4.1-py3-none-any.whl
  • Upload date:
  • Size: 24.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.6.1 requests/2.25.1 setuptools/51.1.1 requests-toolbelt/0.9.1 tqdm/4.55.1 CPython/3.9.1

File hashes

Hashes for pccc-0.4.1-py3-none-any.whl
Algorithm Hash digest
SHA256 58a755bddecf346d64ab3bdf805afd5921daab1b7debcd2ca1f2494e5aac1ec7
MD5 aa5f890244e1c1ef77900d50a3e874ee
BLAKE2b-256 037983dfe7793b670f6fd2f0904590fd3aae69a8e33ba397b791b9699323f1f2

See more details on using hashes here.

Supported by

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