This tool is used to backport pull requests labeled to-be-backported
.
Generally backport PRs are automatically created by GitHub Actions workflow. However, in case there is a conflict during the backport process, you need to run this tool in your local environment to manually resolve the conflict.
- Create a classic GitHub token with
public_repo
scope. - Install PyGitHub (
pip install pygithub
).
For example, to backport PR #9876:
$ export BACKPORT_GITHUB_TOKEN=ghp_XXXXXXXXXXXXXXXXXXXXX
$ python backport.py --repo cupy --pr 9876
If there are conflicts during backport, the tool will stop and ask you to resolve the conflict manually. Follow the instructions shown.
Run python backport.py --help
for additional options.
Basically it follows this procedure:
- Clone the target branch (e.g.
v13
) of the target repository (e.g.cupy/cupy
) to a temporary directory. - Create a local temporary branch and cherry-pick the merge commit of the original PR.
- Push it to the user repository.
- Make a backport PR.