This script is designed to automate the process of reviewing code changes between two commits BEFORE pushing to remote using a local AI language model. Use your desired methods to trigger the script in your pre-commit hook.
To use this tool:
- Ensure you have Node.js installed.
- Make sure the AI language model server is running at
http://localhost:11434/api/generate?. - Execute the script with
node review.jsor get it executed via the pre-commit hook - Check the
code_reviewdirectory
Add a pre-commit hook to your repository to automate checks before you commit your code. Here’s how you can do it:
-
Create a new file named
pre-commitin the.git/hooksdirectory and make it an executable:touch .git/hooks/pre-commit chmod +x .git/hooks/pre-commit
-
Add the following content to the
pre-commitfile. This example script will runnpm testbefore you commit:#!/bin/sh echo "Generating code review..." npm review.js