Skip to main content

A Git pre-commit hook powered by OpenAI to review your staged changes.

Project description

AI-Powered Code Review Git Hook

A Git pre-commit hook that leverages OpenAI's API to automatically analyze staged code changes for potential issues before committing.

Features

  • Automated Code Review: Reviews staged changes for syntax errors, potential bugs, and security issues.
  • GPT-4 Based Analysis: Utilizes OpenAI's GPT-4 (configurable) for detailed feedback.
  • Line-Number Specific Feedback: Annotates diffs with precise line numbers for easy reference.
  • Environment Variable Controls: Easily enable or disable the hook via environment variables.

Prerequisites

  • Python: 3.6+ (recommended)
  • Git: Installed and configured
  • OpenAI API Key: Obtain an API key from OpenAI

Setup

1. Install the Package

Install the package via pip (from PyPI or TestPyPI):

PyPi:

pip install openai-git-hook

2. Configure the Hook

export OPENAI_API_KEY=your_api_key_here

3. Using the Hook

  • Manual Review:
    Run openai-git-hook manually to perform a code review on your staged changes. Note: You must run git add . (or stage your changes) before executing the command, as the hook analyzes the diff of the staged changes.

  • Automatic Installation:
    Run openai-git-hook-install to install or update the Git pre-commit hook in your repository. This command writes the necessary script to .git/hooks/pre-commit, ensuring that the code review is automatically executed every time you commit changes. Remember to stage your changes with git add . so that the hook can access the diff and other required information. If you need to bypass the hook during a commit, you can do so by using the --no-verify flag.

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

openai_git_hook-0.0.4.tar.gz (5.5 kB view details)

Uploaded Source

Built Distribution

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

openai_git_hook-0.0.4-py3-none-any.whl (5.9 kB view details)

Uploaded Python 3

File details

Details for the file openai_git_hook-0.0.4.tar.gz.

File metadata

  • Download URL: openai_git_hook-0.0.4.tar.gz
  • Upload date:
  • Size: 5.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.9.20

File hashes

Hashes for openai_git_hook-0.0.4.tar.gz
Algorithm Hash digest
SHA256 80e597442f871caf7e3afd4488398371e5a96eb47aa3cbf93b86007e3209ddd6
MD5 07c1e2f3709cdda4d7a30df83fbc6a00
BLAKE2b-256 d1bf666fccd5d0e2704582e21da41d760e9b4cb16e35a98899e67cbcaa411699

See more details on using hashes here.

File details

Details for the file openai_git_hook-0.0.4-py3-none-any.whl.

File metadata

File hashes

Hashes for openai_git_hook-0.0.4-py3-none-any.whl
Algorithm Hash digest
SHA256 d67f8a20e31fe5da4573856208c5a8633b44e7102ce0563e44587adcb54e4f55
MD5 216646aac7d404725436d1993f9136df
BLAKE2b-256 fca57186e09036eade0a65e01af8faf08470c95d9b9214e8ecc72612aecbfad7

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