Skip to main content

Simple CLI tool to check and update pre-commit hooks.

Project description

pre-commit-update

Version Downloads Formatter License

pre-commit-update is a simple CLI tool to check and update pre-commit hooks.

Table of contents

  1. Reasoning
  2. Installation
  3. Usage
    1. Pipeline usage example
    2. pre-commit hook usage example

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.

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 new versions
  -a, --all-versions  Include alpha/beta versions
  -v, --verbose       Display complete output
  --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:
    - 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]

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

pre_commit_update-0.0.2.tar.gz (5.6 kB view details)

Uploaded Source

Built Distribution

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

pre_commit_update-0.0.2-py3-none-any.whl (7.8 kB view details)

Uploaded Python 3

File details

Details for the file pre_commit_update-0.0.2.tar.gz.

File metadata

  • Download URL: pre_commit_update-0.0.2.tar.gz
  • Upload date:
  • Size: 5.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.2.2 CPython/3.11.0 Linux/6.0.6-1-MANJARO

File hashes

Hashes for pre_commit_update-0.0.2.tar.gz
Algorithm Hash digest
SHA256 e5d7746759a635b762294c235a8690b2ae013594f5f834864fce78f6bd773422
MD5 3aa95b68a7bdac1c8187dee2056de7ad
BLAKE2b-256 7300155eaac614e834a3d3b473679d101d0a918eb10412a9e0c2fdef8662990d

See more details on using hashes here.

File details

Details for the file pre_commit_update-0.0.2-py3-none-any.whl.

File metadata

  • Download URL: pre_commit_update-0.0.2-py3-none-any.whl
  • Upload date:
  • Size: 7.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.2.2 CPython/3.11.0 Linux/6.0.6-1-MANJARO

File hashes

Hashes for pre_commit_update-0.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 65150df87a9f6a6e768b6d8349f0276afdf26eb1a1a6f8569bd353386a3b5f21
MD5 df50faf5cf169add062c78b17e355abb
BLAKE2b-256 bb21f62f596ea4a8a9df2e5403bb315c3d277e6f59f17d8167bf6e10c595bd76

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