semvec/pypi-packages huggingface dataset:
openai-git-hook 0.0.4
A Git pre-commit hook powered by OpenAI to review your staged changes.
License: MIT
Requires Python: >=3.6
Keywords: git, pre-commit, openai, hook

# 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](https://openai.com)

## Setup

### 1. Install the Package

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

**PyPi**:

```bash
pip install openai-git-hook
```

### 2. Configure the Hook

```bash
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.