The GitHub PR Tool is a Rust-based command-line utility designed to streamline the process of creating GitHub pull requests (PRs). It leverages OpenAI's language model to generate meaningful branch names and commit messages, while automating tasks such as staging changes, creating new branches, committing changes, and opening PRs via the GitHub CLI (gh
).
- Smart Branch Naming: Automatically generate descriptive branch names based on the content of your changes.
- Commit Message Assistance: Create concise commit titles and optional detailed descriptions using OpenAI's LLM.
- Automated Workflow: Stage changes, create a branch, commit changes, and open a pull request with minimal effort.
- Interactive Staging: Offers to stage unstaged changes interactively if no changes are staged.
- Error Handling: Validates prerequisites like being inside a Git repository and having the OpenAI API key set.
- Git: Installed and available in your PATH.
- GitHub CLI (
gh
): Installed and authenticated. - Rust: Installed for building and running the tool.
- OpenAI API Key: Set as an environment variable (
OPENAI_KEY
).
-
Clone the repository:
git clone https://github.com/sasa-tomic/github-pr-tool.git cd github-pr-tool
-
Build the project:
cargo build --release
-
Run the tool:
./target/release/github-pr-tool
-
Ensure you are inside a Git repository.
-
Run the tool:
./target/release/github-pr-tool
-
The tool will:
- Check for staged changes.
- If none are staged, interactively ask to stage unstaged changes.
- Generate a branch name and commit message based on the changes.
- Create a new branch, commit changes, and open a pull request.
OPENAI_KEY
: Your OpenAI API key, required for generating branch names and commit messages.
> ./target/release/github-pr-tool
No staged changes found. Stage all unstaged changes? (y/n): y
Pull request created successfully.
Contributions are welcome! Here’s how you can help:
-
Fork the repository.
-
Create a feature branch:
git checkout -b feature/your-feature
-
Make your changes and test thoroughly.
-
Submit a pull request.
This project is licensed under the MIT License. See the LICENSE
file for details.
- Built with Rust and powered by OpenAI's GPT technology.