A gh cli extension to automatically combine multiple pull requests into one.
This project is a gh cli extension that is used to combine multiple pull requests into one. It is inspired by the github/combine-prs Action but with a focus on the gh cli.
The primary use case for this extension is to combine multiple pull requests from dependabot into one. Even though dependabot supports grouped version updates, these groups are limited by their type. For example, you cannot have dependabot combine a group of Ruby and JavaScript updates into one pull request. They are treated as separate groups. This extension solves that problem by bundling those updates into one pull request.
Install this gh cli extension by running the following command:
gh extension install github/gh-combine
You can upgrade this extension by running the following command:
gh ext upgrade combine
Basic usage of the combine
command to combine multiple dependent pull requests into one for a given repository:
gh combine owner/repo
By default, this command will attempt to combine all open pull requests in the repository. You should use generally use some form of filtering to limit the number of pull requests that are combined. See the examples below for more information.
Combine all open pull requests in a repository that are created by dependabot:
gh combine owner/repo --dependabot
Combine multiple pull requests together but only if their CI checks are passing:
gh combine owner/repo --require-ci
gh combine owner/repo --require-ci --require-approved
gh combine owner/repo1 owner/repo2
# alternatively separate with a comma
gh combine owner/repo1,owner/repo2
# or use the --owner flag if all the repos are owned by the same owner
gh combine --owner owner repo1 repo2 repo3
gh combine --file repos.txt
Where repos.txt
is a file with a list of repositories to combine (one per line):
owner/repo1
owner/repo2
owner/repo3
By using the --minimum
flag you can require a minimum number of pull requests that must be combined for a new PR to be opened. If less than the minimum number of pull requests are combined, the command will exit without opening a new PR.
gh combine owner/repo --minimum 3
gh combine owner/repo --labels dependencies
You can also require a set of multiple labels
gh combine owner/repo --labels security,dependencies
Note that the labels are OR'd together. So if a pull request has either label, it will be included in the combined pull request. Meaning that if you use
--labels security,dependencies
and a pull request has thesecurity
label, it will be included in the combined pull request even if it does not have thedependencies
label.
gh combine owner/repo --branch-regex "dependabot/.*"
gh combine owner/repo --branch-prefix "dependabot/"
gh combine owner/repo --branch-suffix "-some-cool-feature"
gh combine owner/repo --ignore-labels wip,dependencies
Note that labels are OR'd together. So if a pull request has either label, it will be ignored in the combined pull request. Meaning that if you use
--ignore-labels wip,dependencies
and a pull request has thewip
label, it will be ignored in the combined pull request even if it does not have thedependencies
label.
gh combine owner/repo --update-branch
LOG_LEVEL=DEBUG gh combine owner/repo
Run gh combine --help
for more information and full command/options usage.