Skip to main content

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 -a flag.
  • 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):

  1. 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
    
  2. Create and activate a virtual environment (recommended):
    python3 -m venv venv
    source venv/bin/activate  # On Windows, use `venv\Scripts\activate`
    
  3. 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 -m autopr.cli ls
    
  • List all issues (open and closed):
    autopr ls -a
    # For developers: python -m autopr.cli ls -a
    
  • Start working on an issue:
    autopr workon <issue_number>
    # For developers: python -m autopr.cli workon <issue_number>
    
    (See full guide below)
  • Create a new PR:
    autopr create --title "Your Amazing PR Title"
    # For developers: python -m autopr.cli 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 -m autopr.cli workon <issue_number>

Replace <issue_number> with the actual number of the GitHub issue you want to work on.

What it does:

  1. Fetches Issue Details: It uses the gh CLI to retrieve the title of the specified issue.
  2. 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.
  3. Creates and Switches Branch: It executes git checkout -b <generated_branch_name> to create the new local branch and immediately switch to it.
  4. Stores Context: The issue number is saved to a file named .autopr_current_issue inside your local .git directory. This allows future autopr commands (like autopr commit and autopr pr create in 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 -m autopr.cli 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 42 into .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.

  1. Update Version: Increment the __version__ string in autopr/__init__.py.

  2. Build the Package:

    make build
    

    This cleans old builds and creates new source distribution and wheel files in the dist/ directory.

  3. Test Publishing (Highly Recommended): Publish to TestPyPI to ensure everything works correctly before a real release.

    make publish-test
    

    You will be prompted for confirmation. Check the package on test.pypi.org.

  4. Publish to PyPI (Real):

    make publish
    

    This will upload the package to the official PyPI. You will be prompted for confirmation.

  5. Full Release (Publish to PyPI & Tag): For a complete release including Git tagging:

    make release
    

    This performs make publish and 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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

autopr_cli-0.2.8.tar.gz (9.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

autopr_cli-0.2.8-py3-none-any.whl (11.1 kB view details)

Uploaded Python 3

File details

Details for the file autopr_cli-0.2.8.tar.gz.

File metadata

  • Download URL: autopr_cli-0.2.8.tar.gz
  • Upload date:
  • Size: 9.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.11.8

File hashes

Hashes for autopr_cli-0.2.8.tar.gz
Algorithm Hash digest
SHA256 518250ad4cab29c9e0612f8ab30e623e66ec3c32bf5f99a9414d068cadd49176
MD5 0430599057dfaff88c7473898dd2b4b4
BLAKE2b-256 bf15a8423ff12e60099203155c54427f9bebef3456b31799cecae6c6290d28b9

See more details on using hashes here.

File details

Details for the file autopr_cli-0.2.8-py3-none-any.whl.

File metadata

  • Download URL: autopr_cli-0.2.8-py3-none-any.whl
  • Upload date:
  • Size: 11.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.11.8

File hashes

Hashes for autopr_cli-0.2.8-py3-none-any.whl
Algorithm Hash digest
SHA256 69bbde03fcb77adaa27aa6dc3b74086e29a42d152623708f8b09616ffd78da60
MD5 bc50918e12ef04af6bbc4268a34fc10f
BLAKE2b-256 4e44016fe5e045fdebbdc509592346fb806a3f7e375ac885d08d53742bea5a77

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page