Package: conventional-pre-commit
conventional-pre-commitApre-commithook to check commit messages forConventional Commitsformatting.Works with Python >= 3.8.UsageMake surepre-commitisinstalled.Create a blank configuration file at the root of your repo, if needed:touch .pre-commit-config.yamlAdd a new repo entry to your configuration file:repos:# - repo: ...-repo:https://github.com/compilerla/conventional-pre-commitrev:<git sha or tag>hooks:-id:conventional-pre-commitstages:[commit-msg]args:[]Install thepre-commitscript:pre-commit install --hook-type commit-msgMake a (normal) commit :x::$gitcommit-m"add a new feature"[INFO] Initializing environment for ....Conventional Commit......................................................Failed- hook id: conventional-pre-commit- duration: 0.07s- exit code: 1[Bad Commit message] >> add a new featureYour commit message does not follow Conventional Commits formattinghttps://www.conventionalcommits.org/Conventional Commits start with one of the below types, followed by a colon,followed by the commit message:build chore ci docs feat fix perf refactor revert style testExample commit message adding a feature:feat: implement new APIExample commit message fixing an issue:fix: remove infinite loopExample commit with scope in parentheses after the type for more context:fix(account): remove infinite loopExample commit with a body:fix: remove infinite loopAdditional information on the issue caused by the infinite loopMake a (conventional) commit :heavy_check_mark::$gitcommit-m"feat: add a new feature"[INFO] Initializing environment for ....Conventional Commit......................................................Passed- hook id: conventional-pre-commit- duration: 0.05sInstall with pipconventional-pre-commitcan also be installed and used from the command line:pipinstallconventional-pre-commitThen run the command line script:conventional-pre-commit[types]input[types]is an optional list of Conventional Commit types to allow (e.g.feat fix chore)inputis a file containing the commit message to check:conventional-pre-commitfeatfixchorecitest.git/COMMIT_MSGOr from a Python program:fromconventional_pre_commit.formatimportis_conventional# prints Trueprint(is_conventional("feat: this is a conventional commit"))# prints Falseprint(is_conventional("nope: this is not a conventional commit"))# prints Trueprint(is_conventional("custom: this is a conventional commit",types=["custom"]))Passingargsconventional-pre-commitsupports a number of arguments to configure behavior:$conventional-pre-commit-h
usage:conventional-pre-commit[-h][--force-scope][--strict][types...]input

CheckagitcommitmessageforConventionalCommitsformatting.

positionalarguments:typesOptionallistoftypestosupportinputAfilecontainingagitcommitmessage

options:-h,--helpshowthishelpmessageandexit--force-scopeForcecommittohavescopedefined.--strictForcecommittostrictlyfollowConventionalCommitsformatting.Disallowsfixup!stylecommits.Supply arguments on the command-line, or via the pre-commithooks.argsproperty:repos:-repo:https://github.com/compilerla/conventional-pre-commitrev:<git sha or tag>hooks:-id:conventional-pre-commitstages:[commit-msg]args:[--strict,--force-scope,feat,fix,chore,test,custom]NOTE:when using as a pre-commit hook,inputis supplied automatically (with the current commit's message).Developmentconventional-pre-commitcomes with aVS Code devcontainerconfiguration to provide a consistent development environment.With theRemote - Containersextension enabled, open the folder containing this repository inside Visual Studio Code.You should receive a prompt in the Visual Studio Code window; clickReopen in Containerto run the development environment
inside the devcontainer.If you do not receive a prompt, or when you feel like starting from a fresh environment:Ctrl/Cmd+Shift+Pto bring up the command palette in Visual Studio CodeTypeRemote-Containersto filter the commandsSelectRebuild and Reopen in Containerto completely rebuild the devcontainerSelectReopen in Containerto reopen the most recent devcontainer buildVersioningVersioning generally followsSemantic Versioning.Making a releaseReleases to PyPI and GitHub are triggered by pushing a tag.Ensure all changes for the release are present in themainbranchTag with the new version:git tag vX.Y.Zfor regular release,git tag vX.Y.Z-preNfor pre-releasePush the new version tag:git push origin vX.Y.ZLicenseApache 2.0Inspired by matthorgan'spre-commit-conventional-commits.