Skip to content

hseghetti/codereview-with-ai-chatgpt

Repository files navigation

AI Code Reviewer for git post-commit hook

Build Status

License

This project uses OpenAI's GPT-3 model to provide code reviews for each git commit executed locally. The code review is performed by analyzing the git diff between the new commit and the previous one.

Installation

  1. Clone the repository:
git clone https://github.com/yourusername/ai-code-reviewer.git
  1. Navigate to the project directory:
cd ai-code-reviewer
  1. Install the required Python packages:
pip install -r requirements.txt

Usage

  1. Set your OpenAI API key as an environment variable:
export OPENAI_API_KEY='your-openai-api-key'
  1. Copy the post-commit.sample file to .git/hooks/post-commit:
cp post-commit.sample .git/hooks/post-commit
  1. Run the Flask application:
python main.py

The application will start and be accessible at http://localhost:8000.

Running Tests

To run the tests, execute the following command:

python -m unittest main-test.py

Contributing

Contributions are welcome. Please open an issue to discuss your idea or submit a Pull Request.

License

MIT License

Copyright (c) 2023 Hernan Seghetti

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
```
```

About

Execute a local code review with Chatgpt using git hooks

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published