Skip to main content

No project description provided

Project description

Update-Pre-Commit

OpenSSF Best Practices CI Code Coverage

😎 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 updates hooks revs in .pre-commit-config.yaml and automate creating pull request.


⭐ Why switch to update-pre-commit?

  • we outperform others in update speed by more than 70% (with minimum 4 hooks).
  • we reduce your supply chain risks with openssf best practices in our development and operation.
  • we automate your change management operations with built-in feature to create pull request on GitHub.
  • we protect you against unreliable revs with tag such as alpha, beta, prerelease, and rc.

Use Case 1️⃣ - running on GitHub action

Please visit our GitHub action (update-pre-commit-action) on the GitHub Marketplace.


Use Case 2️⃣ - running locally on your computer

Prerequisites

* Python (3.12+)
  □ install pre-commit.

* GitHub
  □ create a fine-grained token with repository permissions (see below).

GitHub Token Permission


🔆 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 $ workon hello-world
(hello-world) ~/work/hello-world $ export GH_TOKEN=github_pat_xxxxxxxxxxxxx
(hello-world) ~/work/hello-world $ 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 to show version: --version

(hello-world) ~/work/hello-world $ update-pre-commit --version
update-pre-commit, version 1.0.0



🏃 Run default (without any options)

By default, update-pre-commit implicitly runs --dry-run true --open-pr false.

Thus, update-pre-commit:

  1. reads .pre-commit-config.yaml.
  2. 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 on .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:

  1. reads .pre-commit-config.yaml.
  2. produce a list of out-of-date pre-commit hooks on screen.
  3. update .pre-commit-config.yaml.
(hello-world) ~/work/hello-world $ update-pre-commit --dry-run false

Starting update-pre-commit on .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:

  1. reads .pre-commit-config.yaml.
  2. produces a list of out-of-date pre-commit hooks on screen.
  3. update .pre-commit-config.yaml.
  4. checkout a new git branch update_pre_commit_XXXXXXXXXXXXXXXXXXXXX.
  5. open 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 on .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 successfully....

Push commits successfully:
from local branch: update_pre_commit_01JV8P09N4G5K9Q4DDD533ARBH
with commit hash : 7b293faf5e14f6950bf28b510eb8d8c8beff26fe

Creating a Pull Request as follows:
Owner/Repo.  : tagdots/hello-world
Title        : update pre-commit-config
Source Branch: tagdots:update_pre_commit_01JV8P09N4G5K9Q4DDD533ARBH
PR for Branch: main
Rev Variances: [{"owner_repo": "antonbabenko/pre-commit-terraform", "current_rev": "v1.98.1", "new_rev": "v1.99.0"}, {"owner_repo": "adrienverge/yamllint", "current_rev": "v1.37.0", "new_rev": "v1.37.1"}]

Created pull request #101 successfully: https://github.com/tagdots/hello-world/pull/101

😕 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

Pre-Commit on Github

How to fork a repo

Manage Github Token


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

update_pre_commit-1.1.20.tar.gz (11.6 kB view details)

Uploaded Source

Built Distribution

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

update_pre_commit-1.1.20-py3-none-any.whl (8.3 kB view details)

Uploaded Python 3

File details

Details for the file update_pre_commit-1.1.20.tar.gz.

File metadata

  • Download URL: update_pre_commit-1.1.20.tar.gz
  • Upload date:
  • Size: 11.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for update_pre_commit-1.1.20.tar.gz
Algorithm Hash digest
SHA256 1850e89f34868e2a5bc0750ee8e5ae97bfc744185141f6bcdad7174f305690d9
MD5 a85469b40941cd2b76e0922f02adc756
BLAKE2b-256 23c326ba813174946d8c3832e22766187d945cfe0758f9b0c6337c313549980f

See more details on using hashes here.

File details

Details for the file update_pre_commit-1.1.20-py3-none-any.whl.

File metadata

File hashes

Hashes for update_pre_commit-1.1.20-py3-none-any.whl
Algorithm Hash digest
SHA256 fcb59f4ed8251bb8f55e4fca1945ce8b0d7b77a189cb09d84626ddb4b902202c
MD5 4cb9bfad52d3964125ba4fe07fecf69e
BLAKE2b-256 497ffdd5db13f3822e36fac47892e0c7fc1269d4808221ad557c79733ce9a3a7

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