Skip to main content

Pre-commit hooks collection that utilizes ChatGPT and OpenAI platform to validate modifications made to the codebase.

Project description

🤖 ChatGPT / OpenAI pre-commit-hooks

pre-commit PyPI - version PyPI - python version PyPI - downloads GitHub - ci

📥 Setup

pre-commit setup

Before you start, ensure you have pre-commit installed in your repository. Below is just an essential quick start. Follow official pre-commit install documentation for advanced scenarios.

# install using pip
pip install pre-commit

# check if working - expected print with version like `pre-commit 3.2.2`
pre-commit --version

# setup the git repo for hooks
pre-commit install

# periodically run updates to your pre-commit config to make sure you always have the latest version of the hooks
pre-commit autoupdate

Hooks setup

Remote repo reference

Add to your .pre-commit-config.yaml

repos:
  - repo: https://github.com/DariuszPorowski/chatgpt-pre-commit-hooks
    rev: vX.Y.Z  # Use the ref you want to point at, see ⚠️ NOTE below!
    hooks:
      - id: ... # follow 🎣 Hooks section to see available hooks IDs

Example:

repos:
  - repo: https://github.com/DariuszPorowski/chatgpt-pre-commit-hooks
    rev: v0.0.1
    hooks:
      - id: chatgpt-commit-message

⚠️ NOTE

For the rev: always try to use the latest version. You can check the latest release under GitHub Releases

Local repo reference

  1. Install or add PyPI package to your project.

    • if you are using pip:

      pip install chatgpt-pre-commit-hooks
      
    • or include it in a requirements.txt file in your project:

      chatgpt-pre-commit-hooks
      
    • or, even better, in the dev section of your pyproject.toml file:

      [project.optional-dependencies]
      dev = ["chatgpt-pre-commit-hooks"]
      
    • or, if you are using poetry as a package manager:

      poetry add chatgpt-pre-commit-hooks --group dev
      
  2. Add to your .pre-commit-config.yaml

    repos:
      - repo: local
        hooks:
          - id: ... # follow 🎣 Hooks section to see available hooks IDs
            name: Run chatgpt-pre-commit-hooks (<name>)
            entry: chatgpt-pre-commit-hooks.<id> # follow 🎣 Hooks section to see available hooks IDs
            language: system
    

    Example:

    repos:
      - repo: local
        hooks:
          - id: chatgpt-commit-message
            name: Run chatgpt-pre-commit-hooks (chatgpt-commit-message)
            entry: chatgpt-pre-commit-hooks.chatgpt-commit-message
            language: system
    

OpenAI API Key

Hooks require OpenAI access.

  1. Create your OpenAI API Key
  2. Store API key as an environment variable (see: Best Practices for API Key Safety)

🎣 Hooks

chatgpt-commit-message

Hook that uses OpenAI's ChatGPT API to generate a summary of changes made to a codebase and use it to populate the commit message automatically.

License

This project is distributed under the terms of the MIT license.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

chatgpt_pre_commit_hooks-0.1.0-py3-none-any.whl (13.6 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page