Automatically merge pull requests created by automation tools across GitHub organizations
Project description
Dependamerge
Automatically merge similar pull requests across GitHub organizations, supporting both automation tools (like Dependabot, pre-commit.ci, Renovate) and regular GitHub users.
Overview
Dependamerge analyzes a source pull request and finds similar pull requests across all repositories in the same GitHub organization. It then automatically approves and merges the matching PRs, saving time on routine dependency updates, automated maintenance tasks, and coordinated changes across all repositories.
Supports two types of pull requests:
- Automation PRs: From tools like Dependabot, pre-commit.ci, Renovate (original functionality)
- Non-Automation PRs: From regular GitHub users with SHA-based security validation (new feature)
Features
- Automated PR Detection: Identifies pull requests created by popular automation tools
- Non-Automation PR Support: Handles PRs from regular GitHub users with SHA-based security validation
- Smart Matching: Uses content similarity algorithms to match related PRs across repositories
- Bulk Operations: Approve and merge related similar PRs with a single command
- Security Features: SHA-based authentication for non-automation PRs ensures authorized bulk merges
- Dry Run Mode: Preview what changes will apply without modifications
- Rich CLI Output: Beautiful terminal output with progress indicators and tables
Supported Automation Tools
- Dependabot
- pre-commit.ci
- Renovate
- GitHub Actions
- Allcontributors
Installation
# Install from source
git clone <repository-url>
cd dependamerge
pip install -e .
# Or install dependencies directly
pip install typer requests PyGithub rich pydantic
Authentication
You need a GitHub personal access token with appropriate permissions:
- Go to GitHub Settings → Developer settings → Personal access tokens
- Create a token with these scopes:
repo(for private repositories)public_repo(for public repositories)read:org(to list organization repositories)
Set the token as an environment variable:
export GITHUB_TOKEN=your_token_here
Or pass it directly to the command using --token.
Usage
Automation PRs (Original Functionality)
For pull requests from automation tools like Dependabot, pre-commit.ci, and Renovate:
dependamerge https://github.com/lfreleng-actions/python-project-name-action/pull/22
Non-Automation PRs (New Feature)
For pull requests from regular GitHub users, a two-step process ensures security:
Step 1: Get the required SHA
dependamerge https://github.com/owner/repo/pull/123
# Output: To merge this and similar PRs, run again with: --override a1b2c3d4e5f6g7h8
Step 2: Use the SHA to proceed
dependamerge https://github.com/owner/repo/pull/123 --override a1b2c3d4e5f6g7h8
The SHA hash generates based on:
- The PR author's GitHub username
- The first line of the commit message
- This ensures PRs from the same author with matching commits can be bulk merged
Basic Usage
dependamerge https://github.com/lfreleng-actions/python-project-name-action/pull/22
Dry Run (Preview Mode)
dependamerge https://github.com/owner/repo/pull/123 --dry-run
Custom Options
dependamerge https://github.com/owner/repo/pull/123 \
--threshold 0.9 \
--merge-method squash \
--fix \
--token your_github_token
Command Options
--dry-run: Show what changes will apply without making them--threshold FLOAT: Similarity threshold for matching PRs (0.0-1.0, default: 0.8)--merge-method TEXT: Merge method - merge, squash, or rebase (default: merge)--fix: Automatically fix out-of-date branches before merging--token TEXT: GitHub token (alternative to GITHUB_TOKEN env var)--override TEXT: SHA hash to override non-automation PR restriction
How It Works
For Automation PRs
- Parse Source PR: Analyzes the provided pull request URL and extracts metadata
- Validation: Ensures the PR is from a recognized automation tool
- Organization Scan: Lists all repositories in the same GitHub organization
- PR Discovery: Finds all open pull requests in each repository
- Content Matching: Compares PRs using different similarity metrics:
- Title similarity (normalized to remove version numbers)
- File change patterns
- Author matching
- Approval & Merge: For matching PRs above the threshold:
- Adds an approval review
- Merges the pull request
- Source PR Merge: Merges the original source PR that served as the baseline
For Non-Automation PRs
- Parse Source PR: Analyzes the provided pull request URL and extracts metadata
- Non-Automation Detection: Identifies that PR is from a regular user
- SHA Generation: Creates unique SHA based on author + commit message
- Override Validation: If
--overrideprovided, validates SHA matches expectations - Author-Specific Scan: Finds PRs from the same author
- Content Matching: Same similarity algorithms as automation PRs
- Approval & Merge: Merges matching PRs from the same author
Similarity Matching
The tool uses different algorithms to determine if PRs are similar:
Title Normalization
- Removes version numbers (e.g., "1.2.3", "v2.0.0")
- Removes commit hashes
- Removes dates
- Normalizes whitespace
File Change Analysis
- Compares changed filenames using Jaccard similarity
- Accounts for path normalization
- Ignores version-specific filename differences
Confidence Scoring
Combines different factors:
- Title similarity score
- File change similarity score
- Author matching (same automation tool)
Examples
Dependabot PR
# Merge a Dependabot dependency update across all repos
dependamerge https://github.com/myorg/repo1/pull/45
pre-commit.ci PR
# Merge pre-commit hook updates
dependamerge https://github.com/myorg/repo1/pull/12 --threshold 0.85
Non-Automation User PR
# First run to get the SHA
dependamerge https://github.com/myorg/repo1/pull/89
# Output: To merge this and similar PRs, run again with: --override f1a2b3c4d5e6f7g8
# Second run with the override SHA
dependamerge https://github.com/myorg/repo1/pull/89 --override f1a2b3c4d5e6f7g8
Dry Run with Fix Option
# See what changes will apply and automatically fix out-of-date branches
dependamerge https://github.com/myorg/repo1/pull/78 --dry-run --fix --threshold 0.9
Non-Automation PR Example
# Step 1: Get the SHA for the non-automation PR
dependamerge https://github.com/owner/repo/pull/123
# Step 2: Merge using the obtained SHA
dependamerge https://github.com/owner/repo/pull/123 --override a1b2c3d4e5f6g7h8
Safety Features
For All PRs
- Mergeable Check: Verifies PRs are in a mergeable state before attempting merge
- Auto-Fix: Automatically update out-of-date branches when using
--fixoption - Detailed Status: Shows specific reasons why PRs cannot merge (conflicts, blocked by checks, etc.)
- Similarity Threshold: Configurable confidence threshold prevents incorrect matches
- Dry Run Mode: Always test with
--dry-runfirst - Detailed Logging: Shows which PRs match and why they match
Security for Automation PRs
- Automation-Focused: Processes PRs from recognized automation tools
Security for Non-Automation PRs
- SHA-Based Authentication: Requires unique SHA hash for each author/commit combination
- Author Isolation: Merges PRs from the same author as source PR
- Commit Binding: SHA changes if commit message changes, preventing replay attacks
- No Cross-Author Attacks: One author's SHA cannot work for another author's PRs
Enhanced URL Support
The tool now supports GitHub PR URLs with path segments:
# These URL formats now work:
dependamerge https://github.com/owner/repo/pull/123
dependamerge https://github.com/owner/repo/pull/123/
dependamerge https://github.com/owner/repo/pull/123/files
dependamerge https://github.com/owner/repo/pull/123/commits
dependamerge https://github.com/owner/repo/pull/123/files/diff
This enhancement allows you to copy URLs directly from GitHub's PR pages without worrying about the specific tab you're viewing.
Development
Setup Development Environment
git clone <repository-url>
cd dependamerge
pip install -e ".[dev]"
Running Tests
pytest
Code Quality
# Format code
black src tests
# Lint code
flake8 src tests
# Type checking
mypy src
Contributing
- Fork the repository
- Create a feature branch
- Add tests for new functionality
- Ensure all tests pass
- Submit a pull request
License
MIT License - see LICENSE file for details.
Troubleshooting
Common Issues
Authentication Error
Error: GitHub token needed
Solution: Set GITHUB_TOKEN environment variable or use --token flag.
Permission Error
Failed to fetch organization repositories
Solution: Ensure your token has read:org scope.
No Similar PRs Found
- Check that other repositories have open automation PRs
- Try lowering the similarity threshold with
--threshold 0.7 - Use
--dry-runto see detailed matching information
Merge Failures
- Ensure PRs are in mergeable state (no conflicts)
- Check that you have write permissions to the target repositories
- Verify the repository settings permit the merge method
Getting Help
- Check the command help:
dependamerge --help - Enable verbose output with environment variables
- Review the similarity scoring in dry-run mode
Security Considerations
- Store GitHub tokens securely (environment variables, not in code)
- Use tokens with minimal required permissions
- Rotate access tokens periodically
- Review PR changes in dry-run mode first
- Be cautious with low similarity thresholds
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 dependamerge-0.0.0.tar.gz.
File metadata
- Download URL: dependamerge-0.0.0.tar.gz
- Upload date:
- Size: 28.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2f81f562bbc66a83174cb639307c86f3dda6e5366a709e6ec8eb72de266eec0f
|
|
| MD5 |
dffa267779c5047813d291beed488048
|
|
| BLAKE2b-256 |
78bf046d4b31b5d40a0e7b1b37f25fc1a84dacb5f296e49a1ab6cb42ad9e274d
|
Provenance
The following attestation bundles were made for dependamerge-0.0.0.tar.gz:
Publisher:
build-test-release.yaml on lfit/dependamerge
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
dependamerge-0.0.0.tar.gz -
Subject digest:
2f81f562bbc66a83174cb639307c86f3dda6e5366a709e6ec8eb72de266eec0f - Sigstore transparency entry: 408421221
- Sigstore integration time:
-
Permalink:
lfit/dependamerge@76b1d8e43e74b638e373fa8f50c4f1829c5aa95b -
Branch / Tag:
refs/tags/v0.1.1 - Owner: https://github.com/lfit
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
build-test-release.yaml@76b1d8e43e74b638e373fa8f50c4f1829c5aa95b -
Trigger Event:
push
-
Statement type:
File details
Details for the file dependamerge-0.0.0-py3-none-any.whl.
File metadata
- Download URL: dependamerge-0.0.0-py3-none-any.whl
- Upload date:
- Size: 23.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
08717158f856f816775377230d494a76f498c37883a668c05aab1fd71b16c022
|
|
| MD5 |
72689d0570ca83d9ecc6e5af3f33edb3
|
|
| BLAKE2b-256 |
e7a4a6bae6f0f1cac812ec765c5318df132fc7b3b8bf31f340e6d203dc0969f5
|
Provenance
The following attestation bundles were made for dependamerge-0.0.0-py3-none-any.whl:
Publisher:
build-test-release.yaml on lfit/dependamerge
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
dependamerge-0.0.0-py3-none-any.whl -
Subject digest:
08717158f856f816775377230d494a76f498c37883a668c05aab1fd71b16c022 - Sigstore transparency entry: 408421238
- Sigstore integration time:
-
Permalink:
lfit/dependamerge@76b1d8e43e74b638e373fa8f50c4f1829c5aa95b -
Branch / Tag:
refs/tags/v0.1.1 - Owner: https://github.com/lfit
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
build-test-release.yaml@76b1d8e43e74b638e373fa8f50c4f1829c5aa95b -
Trigger Event:
push
-
Statement type: