Metadata-Version: 2.2
Name: openai-git-hook
Version: 0.0.2
Summary: A Git pre-commit hook powered by OpenAI to review your staged changes.
Author-email: Rhys Postans <rmp71171@gmail.com>
License: MIT
Project-URL: Repository, https://gitlab.com/personal-projects8784807/openai-git-hook
Keywords: git,pre-commit,openai,hook
Classifier: Programming Language :: Python :: 3.6
Classifier: Programming Language :: Python :: 3.7
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Requires-Python: >=3.6
Description-Content-Type: text/markdown
Requires-Dist: requests>=2.0.0

# 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+
- **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
```

**TestPyPI**:

```bash
pip install -i https://test.pypi.org/simple/ openai-git-hook==0.0.1
```

### 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.
