1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2024-12-29 04:50:03 +01:00
RIOT/dist/tools/backport_pr
2023-10-18 14:12:45 +02:00
..
.gitignore tools/backport_pr: add tox.ini 2019-02-12 15:34:15 +01:00
backport_pr.py backport_pr.py: increase entries per page for branches GET 2023-10-18 14:12:45 +02:00
README.md dist/tools/backport_pr: fix typos 2019-11-23 22:39:37 +01:00
requirements.txt dist/tools: Add script for backporting PR's 2019-02-12 15:34:12 +01:00
setup.cfg tools/backport_pr: add black testenv in tox 2021-10-22 10:20:52 +02:00
tox.ini tools/backport_pr: add black testenv in tox 2021-10-22 10:20:52 +02:00

Pull requests backport script

This script provides functionality to easily backport a merged pull request to a release branch.

It relies on having a github API token stored in ~/.riotgithubtoken by default.

The script works by fetching information from the supplied merged pull request. It then looks for the last release branch. A temporary git worktree with a new branch is created based on this release branch. All commits from the pull request are then cherry-picked into this branch which is then pushed to origin. It then creates a new pull request on github with a reference to the original pull request. It optionally puts a comment under the original pull request to the new backport pull request.

Usage

Most common usage would be to run:

backport_pr.py --comment PR_NUMBER

If you are executing from a worktree, the script cannot currently detect the base git directory and must be used with --gitdir PATH_TO_ORIGINAL_GIT_DIR

Full help:

usage: backport_pr.py [-h] [-k KEYFILE] [-c] [-n] [-r RELEASE_BRANCH]
                      [--backport-branch-fmt BACKPORT_BRANCH_FMT] [-d GITDIR]
                      PR

positional arguments:
  PR                    Pull request number to backport

optional arguments:
  -h, --help            show this help message and exit
  -k KEYFILE, --keyfile KEYFILE
                        File containing github token
  -c, --comment         Put a comment with a reference underthe original PR
  -n, --noop            Limited noop mode, creates branch, but doesn'tpush and
                        create the PR
  -r RELEASE_BRANCH, --release-branch RELEASE_BRANCH
                        Base the backport on this branch, default is the
                        latest
  --backport-branch-fmt BACKPORT_BRANCH_FMT
                        Backport branch format. Fields '{release}' and
                        '{origbranch} will be replaced by the release name and
                        remote branch name.
  -d GITDIR, --gitdir GITDIR
                        Base git repo to work from

Create an authentication token

A Personal access token must be created on the github website and stored in your home directory at ~/.riotgithubtoken.

The setting is located at https://github.com/settings/tokens :

Github->Settings->
    Developer settings->Personal access tokens->Generate New Token

And it should have the following scope:

repo[public repo]: Access public repositories

Warning its value should be saved directly as you cannot see it later anymore.