Pre-commit hooks collection that utilizes ChatGPT and OpenAI platform to validate modifications made to the codebase.
Project description
🤖 ChatGPT / OpenAI pre-commit-hooks
📥 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
-
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
-
-
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.
- Create your OpenAI API Key
- 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.
- Read setup and usage for this hook.
License
This project is distributed under the terms of the MIT license.
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 Distributions
Built Distribution
Hashes for chatgpt_pre_commit_hooks-0.1.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ad817e256a9e4ecbba38e98d3080bc3f9951d85a1fd0814a2564454e5cd87087 |
|
MD5 | 0e32b9e8403318871d91c827deee161d |
|
BLAKE2b-256 | 93928ffe1c1ff9f1a7932fffb8e118309ba1bcdd4af80f736407bffed52ed116 |