Update-Pre-Commit
😎 Why you need update-pre-commit?
If you are already using pre-commit or you are planning to use pre-commit to enforce coding standard and detect issues before code check-in, update-pre-commit keeps revs in .pre-commit-config.yaml up to date and facilitate your change management operations to optionally create pull request.
⭐ Why switch to update-pre-commit?
- we outperform others in update speed by more than
70%. - we protect you against unreliable revs with tag such as
alpha,beta,prerelease, andrc. - we reduce your supply chain risks with
openssf best practicesin our development and operations.
🎉 Use Case 1️⃣ - running on GitHub action
Example - summary
update-pre-commit:
- runs on a scheduled interval - every day at 5:30 pm UTC (
- cron: '30 17 * * *') - uses GitHub Token with permissions:
contents: writeandpull-requests: write - updates
.pre-commit-config.yamlwhen new revs become available (dry-run: false) - opens a pull request after update to
.pre-commit-config.yaml(open-pr: true)
Example - workflow
name: update-pre-commit
on:
# on schedule: e.g. every day at 5:30 pm UTC
schedule:
- cron: '30 17 * * *'
# on demand
workflow_dispatch:
permissions:
contents: read
pull-requests: read
jobs:
update-pre-commit:
runs-on: ubuntu-latest
permissions:
contents: write
pull-requests: write
steps:
- name: Run update-pre-commit
id: update-pre-commit
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
uses: tagdots/update-pre-commit@<commit sha> # 1.3.0
with:
file: .pre-commit-config.yaml
dry-run: false
open-pr: true
🎉 Use Case 2️⃣ - running CLI locally
Prerequisites
* Python (3.12+)
□ install pre-commit.
* GitHub
□ create a fine-grained token with repository permissions (see below).
🔆 Install update-pre-commit
In the command-line examples below, we use a GitHub project named hello-world. This project has pre-commit installed and a valid .pre-commit-config.yaml.
We will first install update-pre-commit in a virtual environment named after the project. Next, we will run update-pre-commit with different options and show the results.
~/work/hello-world $ export GH_TOKEN=github_pat_xxxxxxxxxxxxx
~/work/hello-world $ uv pip install -U update-pre-commit
🔍 Using update-pre-commit
🏃 Run to show command line usage and options: --help
(hello-world) ~/work/hello-world $ update-pre-commit --help
Usage: update-pre-commit [OPTIONS]
Options:
--file TEXT default: .pre-commit-config.yaml
--dry-run BOOLEAN default: true
--open-pr BOOLEAN default: false
--version Show the version and exit.
--help Show this message and exit.
🏃 Run default (without any options)
By default, update-pre-commit implicitly runs --dry-run true --open-pr false.
update-pre-commit:
- reads
.pre-commit-config.yaml. - produces a list of out-of-date pre-commit hooks on screen.
(NO changes will be made to.pre-commit-config.yaml)
(hello-world) ~/work/hello-world $ update-pre-commit
Starting update-pre-commit (ver.: 1.3.0, file: .pre-commit-config.yaml, dry-run True, open-pr False)...
hadolint/hadolint (v2.11.0) is not using the latest release rev (v2.12.0)
pycqa/flake8 (7.1.2) is not using the latest release tag (7.2.0)
antonbabenko/pre-commit-terraform (v1.98.0) is not using the latest release rev (v1.98.1)
✅ Update revs in .pre-commit-config.yaml: None
🏃 Run to update out-of-date hooks: --dry-run false
update-pre-commit:
- reads
.pre-commit-config.yaml. - produce a list of out-of-date pre-commit hooks.
- update
.pre-commit-config.yaml.
(hello-world) ~/work/hello-world $ update-pre-commit --dry-run false
Starting update-pre-commit (ver.: 1.3.0, file: .pre-commit-config.yaml, dry-run False, open-pr False)...
hadolint/hadolint (v2.11.0) is not using the latest release rev (v2.12.0)
pycqa/flake8 (7.1.2) is not using the latest release tag (7.2.0)
antonbabenko/pre-commit-terraform (v1.98.0) is not using the latest release rev (v1.98.1)
✅ Update revs in .pre-commit-config.yaml: Success
🏃 Run to update out-of-date hooks and open a pull request: --dry-run false --open-pr true
update-pre-commit:
- reads
.pre-commit-config.yaml. - produces a list of out-of-date pre-commit hooks on screen.
- updates
.pre-commit-config.yaml. - checkout a new git branch
update_pre_commit_XXXXXXXXXXXXXXXXXXXXX. - opens a pull request against repository default branch.
(hello-world) ~/work/hello-world $ update-pre-commit --dry-run false --open-pr true
Starting update-pre-commit (ver.: 1.3.0, file: .pre-commit-config.yaml, dry-run False, open-pr True)...
hadolint/hadolint (v2.11.0) is not using the latest release rev (v2.12.0)
pycqa/flake8 (7.1.2) is not using the latest release tag (7.2.0)
antonbabenko/pre-commit-terraform (v1.98.0) is not using the latest release rev (v1.99.0)
✅ Update revs in .pre-commit-config.yaml: Success
✅ Checkout new branch (dep/update_pre_commit_01M38D6RHRMWPS2EBHB4NWX0P1).
✅ Push commits to remote from local branch: dep/update_pre_commit_01M38D6RHRMWPS2EBHB4NWX0P1
✅ Pull request created successfully : https://github.com/tagdots/update-pre-commit/pull/709
✅ Branch restored to original branch: main
😕 Troubleshooting
Step 1 - Ensure the following
* your project's .pre-commit-config.yaml file is valid.
* your GitHub fine-grained token has the write permissions to contents and pull requests.
* update-pre-commit can find the .pre-commit-config.yaml file at the root of YOUR project.
Step 2 - Open an issue
🙏 Contributing
Pull requests and stars are always welcome. For pull requests to be accepted on this project, you should follow PEP8 when creating/updating Python codes.
See Contributing
📚 References
Metadata
Release files for update-pre-commit 1.3.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| update_pre_commit-1.3.0.tar.gz | 134.6 kB | Without provenance | Details for update_pre_commit-1.3.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| update_pre_commit-1.3.0-py3-none-any.whl | Python 3 | none | any | Details for update_pre_commit-1.3.0-py3-none-any.whl |
Total release size: 144.0 kB
Release files / update_pre_commit-1.3.0.tar.gz
| Download URL | update_pre_commit-1.3.0.tar.gz |
|---|---|
| Size | 134.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
77dd89d13ac705a035335cec49570a89825aa253e0fdd05f102f4c3eaf9faa60
|
|
BLAKE2b-256 checksum How to use checksums |
45d0c1caf0c0f4006430df71bf5bda59fc35ab9e19163749fa1b89830fdd9633
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Release files / update_pre_commit-1.3.0-py3-none-any.whl
| Download URL | update_pre_commit-1.3.0-py3-none-any.whl |
|---|---|
| Size | 9.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
63686386e973ce0ed5c48815d12ff6946a41284ffaf7ed916e9a6e13356521ef
|
|
BLAKE2b-256 checksum How to use checksums |
3fe8d1656051007aa5dafe30a17104a6a8838a83078099bb9121adabdaa2b871
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Security for update-pre-commit 1.3.0
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.