Skip to main content

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.

Metadata

Release files for openai-git-hook 0.0.4

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for openai-git-hook 0.0.4
File Size Uploaded
openai_git_hook-0.0.4.tar.gz 5.5 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for openai-git-hook 0.0.4
File Interpreter ABI Platform
openai_git_hook-0.0.4-py3-none-any.whl Python 3 none any Details

Total release size: 11.3 kB

Release files / openai_git_hook-0.0.4.tar.gz

Download URL openai_git_hook-0.0.4.tar.gz
Size 5.5 kB
Tags Source
SHA-256 checksum
How to use checksums
80e597442f871caf7e3afd4488398371e5a96eb47aa3cbf93b86007e3209ddd6
BLAKE2b-256 checksum
How to use checksums
d1bf666fccd5d0e2704582e21da41d760e9b4cb16e35a98899e67cbcaa411699
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.9.20

Release files / openai_git_hook-0.0.4-py3-none-any.whl

Download URL openai_git_hook-0.0.4-py3-none-any.whl
Size 5.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
d67f8a20e31fe5da4573856208c5a8633b44e7102ce0563e44587adcb54e4f55
BLAKE2b-256 checksum
How to use checksums
fca57186e09036eade0a65e01af8faf08470c95d9b9214e8ecc72612aecbfad7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.9.20

Release history Release notifications | RSS feed

This release

0.0.4 This release

2 release files

0.0.3

2 release files

0.0.2

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page