gh-safeapprove


Namegh-safeapprove JSON
Version 0.1.0 PyPI version JSON
download
home_pageNone
SummaryA GitHub CLI-compatible Python tool to safely auto-approve pull requests based on customizable rules
upload_time2025-07-23 10:15:41
maintainerNone
docs_urlNone
authorNone
requires_python>=3.8
licenseMIT
keywords approval automation cli github pull-request
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # gh-safeapprove

A GitHub CLI-compatible Python tool to **safely auto-approve pull requests** based on customizable rules.

## ๐Ÿงฉ What is `gh-safeapprove`?

`gh-safeapprove` is a CLI tool designed to automate the approval of pull requests, but **only when they meet strict
safety criteria** โ€” such as matching a specific diff pattern, modifying only certain files, or passing a custom rule
check.

It is ideal for teams who want to streamline the review of low-risk, repetitive changes (e.g., version bumps, URL
rewrites, comment-only diffs) without compromising code quality.

## ๐Ÿš€ Installation

### Prerequisites

- Python 3.8 or higher
- GitHub CLI (`gh`) installed and authenticated

### Install from PyPI

```bash
pip install gh-safeapprove
```

### Install from source

```bash
# Clone the repository
git clone https://github.com/danielmeint/gh-safeapprove.git
cd gh-safeapprove

# Install in development mode
pip install -e .
```

## ๐Ÿ› ๏ธ Basic Usage

### Phase 1 Features

Currently supports:

- Reading PR URLs from a file or stdin
- Pattern matching on added lines using regex
- Dry-run mode for testing
- GitHub Enterprise support
- Basic authentication checks

```bash
# Approve all PRs listed in a file if their diffs only match the pattern
gh-safeapprove --file prs.txt --pattern '\\.url\\s*=' --dry-run

# Same via stdin
cat prs.txt | gh-safeapprove --stdin --pattern '\\.url\\s*='

# Using GitHub Enterprise instance
gh-safeapprove --file prs.txt --enterprise-host github.enterprise.com
```

### Input Format

Create a file with PR URLs (one per line):

```text
https://github.com/owner/repo/pull/123
https://github.com/owner/repo/pull/456
# Comments are ignored
https://github.com/owner/repo/pull/789
```

## ๐Ÿ“‹ Command Line Options

| Option              | Description                                        |
|---------------------|----------------------------------------------------|
| `--file`, `-f`      | File containing PR URLs (one per line)             |
| `--stdin`           | Read PR URLs from stdin                            |
| `--pattern`, `-p`   | Regex pattern to match against added lines         |
| `--dry-run`         | Show what would be done without actually approving |
| `--enterprise-host` | GitHub Enterprise hostname                         |
| `--verbose`, `-v`   | Enable verbose output                              |

## ๐Ÿ”ง Development

### Setup

```bash
# Install development dependencies
pip install -e ".[dev]"

# Run tests
pytest

# Format code
black src/ tests/
ruff check src/ tests/
```

### Project Structure

```
gh-safeapprove/
โ”œโ”€โ”€ src/
โ”‚   โ””โ”€โ”€ gh_safeapprove/
โ”‚       โ”œโ”€โ”€ __init__.py
โ”‚       โ”œโ”€โ”€ cli.py             # CLI entry point (typer)
โ”‚       โ”œโ”€โ”€ approver.py        # Main approval logic
โ”‚       โ”œโ”€โ”€ github_client.py   # Wrapper for `gh` CLI
โ”‚       โ””โ”€โ”€ utils.py           # Utility functions
โ”œโ”€โ”€ tests/
โ”œโ”€โ”€ pyproject.toml
โ””โ”€โ”€ README.md
```

## ๐Ÿงช Testing

```bash
# Run all tests
pytest

# Run with coverage
pytest --cov=gh_safeapprove
```

## ๐Ÿ“ License

MIT License - see LICENSE file for details.

## ๐Ÿšง Status

**Phase 1 Complete**: Basic functionality with pattern matching and GitHub CLI integration.

Planned for future phases:

- Advanced rule system
- File-scope rules
- GitHub API support
- GitHub Actions integration 

            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "gh-safeapprove",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.8",
    "maintainer_email": null,
    "keywords": "approval, automation, cli, github, pull-request",
    "author": null,
    "author_email": "Daniel Meint <pilots-4-trilogy@icloud.com>",
    "download_url": "https://files.pythonhosted.org/packages/52/56/d54c5000a12131829a4121764980b2b3dad2b11737d1a0772e80674f1a54/gh_safeapprove-0.1.0.tar.gz",
    "platform": null,
    "description": "# gh-safeapprove\n\nA GitHub CLI-compatible Python tool to **safely auto-approve pull requests** based on customizable rules.\n\n## \ud83e\udde9 What is `gh-safeapprove`?\n\n`gh-safeapprove` is a CLI tool designed to automate the approval of pull requests, but **only when they meet strict\nsafety criteria** \u2014 such as matching a specific diff pattern, modifying only certain files, or passing a custom rule\ncheck.\n\nIt is ideal for teams who want to streamline the review of low-risk, repetitive changes (e.g., version bumps, URL\nrewrites, comment-only diffs) without compromising code quality.\n\n## \ud83d\ude80 Installation\n\n### Prerequisites\n\n- Python 3.8 or higher\n- GitHub CLI (`gh`) installed and authenticated\n\n### Install from PyPI\n\n```bash\npip install gh-safeapprove\n```\n\n### Install from source\n\n```bash\n# Clone the repository\ngit clone https://github.com/danielmeint/gh-safeapprove.git\ncd gh-safeapprove\n\n# Install in development mode\npip install -e .\n```\n\n## \ud83d\udee0\ufe0f Basic Usage\n\n### Phase 1 Features\n\nCurrently supports:\n\n- Reading PR URLs from a file or stdin\n- Pattern matching on added lines using regex\n- Dry-run mode for testing\n- GitHub Enterprise support\n- Basic authentication checks\n\n```bash\n# Approve all PRs listed in a file if their diffs only match the pattern\ngh-safeapprove --file prs.txt --pattern '\\\\.url\\\\s*=' --dry-run\n\n# Same via stdin\ncat prs.txt | gh-safeapprove --stdin --pattern '\\\\.url\\\\s*='\n\n# Using GitHub Enterprise instance\ngh-safeapprove --file prs.txt --enterprise-host github.enterprise.com\n```\n\n### Input Format\n\nCreate a file with PR URLs (one per line):\n\n```text\nhttps://github.com/owner/repo/pull/123\nhttps://github.com/owner/repo/pull/456\n# Comments are ignored\nhttps://github.com/owner/repo/pull/789\n```\n\n## \ud83d\udccb Command Line Options\n\n| Option              | Description                                        |\n|---------------------|----------------------------------------------------|\n| `--file`, `-f`      | File containing PR URLs (one per line)             |\n| `--stdin`           | Read PR URLs from stdin                            |\n| `--pattern`, `-p`   | Regex pattern to match against added lines         |\n| `--dry-run`         | Show what would be done without actually approving |\n| `--enterprise-host` | GitHub Enterprise hostname                         |\n| `--verbose`, `-v`   | Enable verbose output                              |\n\n## \ud83d\udd27 Development\n\n### Setup\n\n```bash\n# Install development dependencies\npip install -e \".[dev]\"\n\n# Run tests\npytest\n\n# Format code\nblack src/ tests/\nruff check src/ tests/\n```\n\n### Project Structure\n\n```\ngh-safeapprove/\n\u251c\u2500\u2500 src/\n\u2502   \u2514\u2500\u2500 gh_safeapprove/\n\u2502       \u251c\u2500\u2500 __init__.py\n\u2502       \u251c\u2500\u2500 cli.py             # CLI entry point (typer)\n\u2502       \u251c\u2500\u2500 approver.py        # Main approval logic\n\u2502       \u251c\u2500\u2500 github_client.py   # Wrapper for `gh` CLI\n\u2502       \u2514\u2500\u2500 utils.py           # Utility functions\n\u251c\u2500\u2500 tests/\n\u251c\u2500\u2500 pyproject.toml\n\u2514\u2500\u2500 README.md\n```\n\n## \ud83e\uddea Testing\n\n```bash\n# Run all tests\npytest\n\n# Run with coverage\npytest --cov=gh_safeapprove\n```\n\n## \ud83d\udcdd License\n\nMIT License - see LICENSE file for details.\n\n## \ud83d\udea7 Status\n\n**Phase 1 Complete**: Basic functionality with pattern matching and GitHub CLI integration.\n\nPlanned for future phases:\n\n- Advanced rule system\n- File-scope rules\n- GitHub API support\n- GitHub Actions integration \n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "A GitHub CLI-compatible Python tool to safely auto-approve pull requests based on customizable rules",
    "version": "0.1.0",
    "project_urls": null,
    "split_keywords": [
        "approval",
        " automation",
        " cli",
        " github",
        " pull-request"
    ],
    "urls": [
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "f4e7c5a9ef0921260cd914e4212d135267e1bdf28b75add5f08e96f08e048407",
                "md5": "2b5000c693c7b02cce9f2fb201162d66",
                "sha256": "d4c696a1a4dace5e2091ebb0eaa9c3dbb93a0cebaf7a4c9b0b0336026b7dec13"
            },
            "downloads": -1,
            "filename": "gh_safeapprove-0.1.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "2b5000c693c7b02cce9f2fb201162d66",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.8",
            "size": 8646,
            "upload_time": "2025-07-23T10:15:40",
            "upload_time_iso_8601": "2025-07-23T10:15:40.183400Z",
            "url": "https://files.pythonhosted.org/packages/f4/e7/c5a9ef0921260cd914e4212d135267e1bdf28b75add5f08e96f08e048407/gh_safeapprove-0.1.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "5256d54c5000a12131829a4121764980b2b3dad2b11737d1a0772e80674f1a54",
                "md5": "35aef2ffb42383ea1b54f2d04c65222d",
                "sha256": "a0d526b7609c6ec91dfdd13f54dcaac6076b787b67b52d452fba724e418e49a4"
            },
            "downloads": -1,
            "filename": "gh_safeapprove-0.1.0.tar.gz",
            "has_sig": false,
            "md5_digest": "35aef2ffb42383ea1b54f2d04c65222d",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.8",
            "size": 36335,
            "upload_time": "2025-07-23T10:15:41",
            "upload_time_iso_8601": "2025-07-23T10:15:41.821204Z",
            "url": "https://files.pythonhosted.org/packages/52/56/d54c5000a12131829a4121764980b2b3dad2b11737d1a0772e80674f1a54/gh_safeapprove-0.1.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2025-07-23 10:15:41",
    "github": false,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "lcname": "gh-safeapprove"
}
        
Elapsed time: 1.67670s