Skip to content

Commit 78b210a

Browse files
authored
Update README.md
1 parent c92b8fb commit 78b210a

File tree

1 file changed

+15
-54
lines changed

1 file changed

+15
-54
lines changed

README.md

Lines changed: 15 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -1,73 +1,34 @@
1-
Automate backport PR
1+
# `backport` - Tool to semi-automate backport pull requests
22

3-
## Prerequisites
3+
This tool is used to backport pull requests labeled `to-be-backported`.
44

5-
Requires installation of PyGithub
6-
```shell
7-
pip install pygithub
8-
```
5+
Generally backport PRs are [automatically created by GitHub Actions workflow](https://github.com/cupy/cupy/blob/main/.github/workflows/backport.yml).
6+
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.
97

10-
Token is [provided from Github](https://help.github.com/articles/creating-a-personal-access-token-for-the-command-line/). Scope with `repo/public_repo` is required.
8+
## Prerequisites
119

12-
Script requires authentication to github.com via SSH. [Directions here](https://help.github.com/articles/connecting-to-github-with-ssh/).
10+
1. Create a [classic GitHub token with `public_repo` scope](https://github.com/settings/tokens/new?scopes=public_repo).
11+
2. Install PyGitHub (`pip install pygithub`).
1312

1413
## Usage
1514

16-
```
17-
usage: backport.py [-h] --repo {chainer,cupy} --token TOKEN --pr PR
18-
[--branch BRANCH] [--debug] [--continue]
19-
[--abort-before-push]
15+
For example, to backport PR #9876:
2016

21-
optional arguments:
22-
-h, --help show this help message and exit
23-
--repo {chainer,cupy}
24-
chainer or cupy
25-
--token TOKEN GitHub access token.
26-
--pr PR The original PR number to be backported.
27-
--branch BRANCH Target branch to make a backport
28-
--debug
29-
--continue Continues the process suspended by conflict situation.
30-
Run from the working tree directory.
31-
--abort-before-push Abort the procedure before making an push. Useful if
32-
you want to make some modification to the backport
33-
branch. Use --continue to make an actual push after
34-
making modification.
17+
```shell
18+
$ export BACKPORT_GITHUB_TOKEN=ghp_XXXXXXXXXXXXXXXXXXXXX
19+
$ python backport.py --repo cupy --pr 9876
3520
```
3621

37-
## Example
22+
If there are conflicts during backport, the tool will stop and ask you to resolve the conflict manually.
23+
Follow the instructions shown.
3824

39-
```shell
40-
$ python backport.py --repo chainer --token abcdefghijklmn --pr 1234
41-
```
25+
Run `python backport.py --help` for additional options.
4226

4327
## How it works
4428

4529
Basically it follows this procedure:
4630

47-
1. Clone the target branch (e.g. `v5`) of the target repository (e.g. `chainer/chainer`) to a temporary directory.
31+
1. Clone the target branch (e.g. `v13`) of the target repository (e.g. `cupy/cupy`) to a temporary directory.
4832
2. Create a local temporary branch and cherry-pick the merge commit of the original PR.
4933
3. Push it to the user repository.
5034
4. Make a backport PR.
51-
52-
53-
## In the case of conflict
54-
55-
If conflict has occurred during backporting, you have to resolve conflict yourself,
56-
and rerun the command with additional `--continue` option.
57-
58-
```shell
59-
$ python backport.py --repo chainer --token abcdefghijklmn --pr 1234
60-
...
61-
Cherry-pick failed.
62-
Working tree is saved at: /tmp/bp-FktJXG5R
63-
Go to the working tree, resolve the conflict and type `git cherry-pick --continue`,
64-
then run this script with --continue option.
65-
66-
$ cd /tmp/bp-FktJXG5R
67-
68-
$ <resolve conflict>
69-
70-
$ git cherry-pick --continue
71-
72-
$ python backport.py --repo chainer --token abcdefghijklmn --pr 1234 --continue
73-
```

0 commit comments

Comments
 (0)