Some useful (more or less) git hooks.
Hooks
check-commit-msg
It provides a simple regex check on commit message.
Supported message header formats:
[type]: [description]
[type]([context]): [description]
[type] #[issue_id]: [description]
[type]([context]) #[issue_id]: [description]
Supported message format (if you need a longer commit message):
[header]
[message]
Here type is a specific commit type tag. Recognized types are:
'fix', # bugfix
'feat', 'feature', # feature
'wip', # work-in-progress changes (not ready to use)
'maint', 'maintenance', # code maintenance (dependences, configs)
'backport', # backport to an older branch
'test', 'tests', # code test related
'doc', 'docs', # documentation related
'style' # code style and minor refactoring
The context keyword is optional. It must be in round brackets if present. You may provide a module name or a service name or any project-specific information to localize the scope of a problem.
The issue_id must be prepended with # if present and it should match an bug report / feature request ID connected to this specific commit.
The description is just a short description of your commit. The maximum length of a description part of a header is 60 symbols.
You also can provide any additional information after the header.
Here are some examples:
fix: fixed possible connection drops in db
feat(cache): added multi-value caching
feature(db) #112: support for sqlalchemy v.2
Added sqlalchemy v.2 support in database services
incl. new table init engine and other bla-bla-bla...
<write text here>
Usage
Add it to your .pre-commit-config.yaml for pre-commit:
- repo: https://github.com/violet-black/hooks-vb
rev: 0.0.2
hooks:
- id: check-commit-msg
Also you can install the package via pip and run the hook from the CLI:
pip install hooks-vb
check-commit-msg my_project_dir
Options
–msg-fmt - different regex format
–categories - different list of type tags
add-version-tag
It automatically adds a version tag to a commit if the __version__ variable in __init__.py has changed and if there’s no such version tag exists in repo. Version tags are checked against PEP440
Examples:
1.0.0
1.2
1.1rc2
Usage
Add it to your .pre-commit-config.yaml for pre-commit:
- repo: https://github.com/violet-black/hooks-vb
rev: 0.0.2
hooks:
- id: add-version-tag
args: [ 'my_package' ]
Also you can install the package via pip and run the hook from the CLI:
pip install hooks-vb
add-version-tag my_project_dir
Options
–skip-tag - skip tagging and only validate a version against PEP440
–version-file - change version file location (__init__.py)
–version-var - change version variable name (__version__)
–remote - change default git remote name to pre-pull tags from (origin)
–branch - change default branch name (master)
publish-package
It will automatically build and publish a package on each version change. You will need a properly configured .pypirc for this. If a package with such version is already present in PyPI then it won’t be built. Version tags are checked against PEP440
Usage
Add it to your .pre-commit-config.yaml for pre-commit:
- repo: https://github.com/violet-black/hooks-vb
rev: 0.0.2
hooks:
- id: publish-package
args: [ 'my_package' ]
Also you can install the package via pip and run the hook from the CLI:
pip install hooks-vb
publish-package my_project_dir
Options
–package-name - alternative package name (package dir name by default)
–dist-type - package type (sdist or wheel)
–output - package storage dir (./dist)
–repository - alternative PyPI repository name (pypi)
–version-file - change version file location (__init__.py)
–version-var - change version variable name (__version__)
Development
You must setup the package in the dev mode and with dev dependencies. The script will automatically install pre-commit and pre-commit hooks for the repository.
git clone https://github.com/violet-black/hooks-vb.git
pip install -e .[dev]
Metadata
Release files for hooks-vb 0.0.6
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| hooks_vb-0.0.6-py3-none-any.whl | Python 3 | none | any | Details for hooks_vb-0.0.6-py3-none-any.whl |
Release files / hooks_vb-0.0.6-py3-none-any.whl
| Download URL | hooks_vb-0.0.6-py3-none-any.whl |
|---|---|
| Size | 13.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
41c2e59c4db680b632f64e133d38f1181b1c1c86e44409f9eb7ecf885918e0e2
|
|
BLAKE2b-256 checksum How to use checksums |
41c267c2c65c14db31f519ab5e8d3d247b40b0b81577d95064f43742fa5855f6
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.6.0 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.10.0
|
Security for hooks-vb 0.0.6
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.