Simple CLI tool to check and update pre-commit hooks.
Project description
pre-commit-update
pre-commit-update is a simple CLI tool to check and update pre-commit hooks.
Table of contents
1. Reasoning
pre-commit
is a nice little tool that helps you polish your code before releasing it into the wild.
It is fairly easy to use. A single pre-commit-config.yaml
file can hold multiple hooks (checks) that will go through
your code or repository and do certain checks. The trick is that file is static and once you pin your hook versions
after a while they get outdated.
pre-commit
has a CLI that helps with that by making use of pre-commit autoupdate
command so the question is
why the f* are you reading this?
pre-commit-update
was created mostly because there is no easy way to update your hooks by using
pre-commit autoupdate
and avoiding non-stable (alpha, beta, ...) hook versions. pre-commit-update
comes
with a CLI that can be configured to solve that problem - along with other use cases.
Other than that - I was bored ^^
2. Installation
pre-commit-update
is available on PyPI:
$ python -m pip install pre-commit-update
Python >= 3.7 is supported.
NOTE: Please make sure that git
is installed.
3. Usage
pre-commit-update
CLI can be used as below:
Usage: pre-commit-update [OPTIONS]
Options:
-d, --dry-run Dry run only checks for the new versions
-a, --all-versions Include the alpha/beta versions
-v, --verbose Display the complete output
-e, --exclude TEXT Exclude specific hook(s) by the `id` of a hook
-h, --help Show this message and exit.
If you want to just check for updates (without updating pre-commit-config.yaml
), for example, you would use:
pre-commit-update -d
OR
pre-commit-update --dry-run
Pipeline usage example
GitLab job:
pre-commit-hooks-update:
stage: update
script:
# install git if not present in the image
- pip install pre-commit-update
- pre-commit-update --dry-run
except:
- main
when: manual
allow_failure: true
NOTE: This is just an example, feel free to do your own configuration
pre-commit hook usage example
You can also use pre-commit-update
as a hook in your pre-commit
hooks:
- repo: local
hooks:
- id: pre-commit-update
entry: pre-commit-update
language: python
name: pre-commit-update
pass_filenames: false
args: [--dry-run --exclude black --exclude isort]
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for pre_commit_update-0.0.5-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7c7b6854287132c7cbed4a55035e21abf85ec4d92e4e1a7392049f8b039121b8 |
|
MD5 | a5717d452dd2183fe898e79d289e73d5 |
|
BLAKE2b-256 | 01fbf0b8bb9049a8b0d527232c9d21356984c4bc610b9274142349065408fdf6 |