A CLI tool to automate PR creation and listing.
Project description
AutoPR
A CLI tool designed to streamline your GitHub workflow by automating Pull Request (PR) creation and issue management. Future versions will incorporate AI to assist in generating PR descriptions.
Features (Current)
- List open GitHub issues for the current repository.
- List all (open and closed) GitHub issues using the
-aflag. - Create a new PR with a specified title.
- Automatically detects the GitHub repository from your local .git configuration.
Installation & Setup
For Users (when published on PyPI):
You can install AutoPR using pip:
pip install autopr_cli
For Developers (Local Setup):
- Clone the repository:
git clone <your-repository-url> # Replace <your-repository-url> with the actual URL cd autopr-cli # Or your repository's directory name
- Create and activate a virtual environment (recommended):
python3 -m venv venv source venv/bin/activate # On Windows, use `venv\Scripts\activate`
- Install dependencies (including development tools):
pip install -r requirements.txt
Usage
Make sure you are in the root directory of your Git repository.
- List open issues:
autopr ls # For developers: python run_cli.py ls
- List all issues (open and closed):
autopr ls -a # For developers: python run_cli.py ls -a
- Start working on an issue:
autopr workon <issue_number> # For developers: python run_cli.py workon <issue_number>
(See full guide below) - Create a new PR:
autopr create --title "Your Amazing PR Title" # For developers: python run_cli.py create --title "Your Amazing PR Title"
Starting Work on an Issue (autopr workon)
The workon command helps you kickstart development on a specific GitHub issue.
Command:
autopr workon <issue_number>
# For developers: python run_cli.py workon <issue_number>
Replace <issue_number> with the actual number of the GitHub issue you want to work on.
What it does:
- Fetches Issue Details: It uses the
ghCLI to retrieve the title of the specified issue. - Generates a Branch Name: Based on the issue number and its title, it creates a sanitized, descriptive branch name in the format
feature/<issue_number>-<sanitized-title>.- Sanitization includes: lowercasing, replacing spaces and special characters with hyphens, and limiting length.
- Creates and Switches Branch: It executes
git checkout -b <generated_branch_name>to create the new local branch and immediately switch to it. - Stores Context: The issue number is saved to a file named
.autopr_current_issueinside your local.gitdirectory. This allows futureautoprcommands (likeautopr commitandautopr pr createin upcoming features) to know which issue you're currently working on.
Example:
If you want to start working on issue #42 which has the title "Fix login button display error":
autopr workon 42
# For developers: python run_cli.py workon 42
This might:
- Fetch details for issue #42.
- Generate a branch name like
feature/42-fix-login-button-display-error. - Create and switch to this new branch.
- Save
42into.git/.autopr_current_issue.
You are then ready to start coding on the new branch with the issue context set up for future autopr commands.
Development
Running Tests
To run the automated tests, use Make:
make test
Formatting Code
To format the code using Black:
make format
Publishing a New Version (for Maintainers)
This project uses Makefile targets to streamline the release process. Ensure you have twine configured with your PyPI credentials (API tokens are recommended) and have installed development dependencies via pip install -r requirements.txt.
-
Update Version: Increment the
__version__string inautopr/__init__.py. -
Build the Package:
make buildThis cleans old builds and creates new source distribution and wheel files in the
dist/directory. -
Test Publishing (Highly Recommended): Publish to TestPyPI to ensure everything works correctly before a real release.
make publish-testYou will be prompted for confirmation. Check the package on test.pypi.org.
-
Publish to PyPI (Real):
make publishThis will upload the package to the official PyPI. You will be prompted for confirmation.
-
Full Release (Publish to PyPI & Tag): For a complete release including Git tagging:
make releaseThis performs
make publishand then creates a Git tag for the new version (e.g.,v0.2.5). After running this, you must push the tag to the remote repository:git push origin vX.Y.Z # Replace X.Y.Z with the version number # OR push all tags if you have multiple new tags git push --tags
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file autopr_cli-0.2.7.tar.gz.
File metadata
- Download URL: autopr_cli-0.2.7.tar.gz
- Upload date:
- Size: 9.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.11.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
936f45ff66c60283b2544f434eacf4ac093301ebc4b6675d2c0af4e8f334b94e
|
|
| MD5 |
faf452eab6a7f861cc299789b5eb07e3
|
|
| BLAKE2b-256 |
bd822c66df484ee576e359271ef814fb7c1259b43940bd3fee8fa9c71a7dadac
|
File details
Details for the file autopr_cli-0.2.7-py3-none-any.whl.
File metadata
- Download URL: autopr_cli-0.2.7-py3-none-any.whl
- Upload date:
- Size: 11.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.11.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
298472c278c7154b1aa9b5415388e12b60f9af48006d1cd257b4b8e5e53aaf85
|
|
| MD5 |
2fc2081311f15a8a2354def4b823ef6c
|
|
| BLAKE2b-256 |
d83c56a201a79bb6b4668e4e93e55c74941a519ab3eabecadfde1cb44e7096cb
|