Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/ozgen/go-chatgpt-pr-reviewer
https://github.com/ozgen/go-chatgpt-pr-reviewer
chatgpt-api cli-app go-github golang
Last synced: 24 days ago
JSON representation
- Host: GitHub
- URL: https://github.com/ozgen/go-chatgpt-pr-reviewer
- Owner: ozgen
- License: apache-2.0
- Created: 2024-09-02T22:54:47.000Z (5 months ago)
- Default Branch: main
- Last Pushed: 2024-09-03T00:07:09.000Z (5 months ago)
- Last Synced: 2024-11-09T13:30:11.291Z (3 months ago)
- Topics: chatgpt-api, cli-app, go-github, golang
- Language: Go
- Homepage:
- Size: 24.4 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# ChatGPT PR Reviewer
ChatGPT PR Reviewer is a Go-based command-line tool that integrates with GitHub and OpenAI's ChatGPT to perform
automated code reviews on pull requests (PRs). The tool fetches changes from a specified PR, sends the modified code
blocks to ChatGPT for review, and posts the feedback as comments on the PR.## Features
- Fetches pull request changes from a GitHub repository.
- Sends modified code blocks to ChatGPT for review.
- Posts ChatGPT's feedback as comments on the pull request.## Prerequisites
- Go 1.22 or later
- A GitHub account with a personal access token.
- An OpenAI account with API access.## Installation
1. **Install the CLI Tool**
Use the following command to install the `review` CLI tool:
```bash
go install github.com/ozgen/go-chatgpt-pr-reviewer/cmd/[email protected]
```This will download and build the CLI tool, placing the `review` binary in your `GOPATH/bin` or `GOBIN` directory.
2. **Set Environment Variables**
Before running the tool, you need to set the following environment variables:
```bash
export OPENAI_API_KEY=
export ORGANIZATION_ID=
export PROJECT_ID=
export GITHUB_TOKEN=
```- **`OPENAI_API_KEY`**: Your OpenAI API key.
- **`ORGANIZATION_ID`**: Your OpenAI organization ID.
- **`PROJECT_ID`**: Your OpenAI project ID.
- **`GITHUB_TOKEN`**: Your GitHub personal access token with `repo` scope.## Usage
Once installed, you can use the `review` command to perform a code review on a pull request:
```bash
review --local "/path/to/local/repo" --pr 1 [--post-comments]
```- `--local` specifies the path to your local Git repository.
- `--pr` specifies the pull request number you want to review.### Example
1. **Set Environment Variables**:
```bash
export OPENAI_API_KEY=sk-...
export ORGANIZATION_ID=org-...
export PROJECT_ID=proj-...
export GITHUB_TOKEN=ghp_...
```2. **Run the Review Command**:
To run the review without posting comments (default behavior):
```bash
review --local "/Users/ozgen/Desktop/checkstyle-runner" --pr 1
```To run the review and post comments to GitHub:
```bash
review --local "/Users/ozgen/Desktop/checkstyle-runner" --pr 1 --post-comments
```This command will fetch the changes from PR #1 in the specified local repository, send the changes to ChatGPT for
review, and post the feedback as comments on the PR.## Development
### Building from Source
If you want to build the project from source:
1. Clone the repository:
```bash
git clone https://github.com/ozgen/go-chatgpt-pr-reviewer.git
cd go-chatgpt-pr-reviewer
```2. Build the CLI tool:
```bash
go build -o pr-reviewer ./cmd/review
```3. Run the tool:
```bash
./pr-reviewer --local "/path/to/local/repo" --pr 1
```### Running Tests
To run tests:
```bash
go test -v ./...
```## Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
## License
This project is licensed under the MIT License. See the [LICENSE](LICENSE) file for details.