]>
git.ipfire.org Git - thirdparty/pdns.git/blob - build-scripts/cherry-pick-pr.py
11 res
= requests
.get('https://api.github.com/repos/PowerDNS/pdns/pulls/'
12 '{}/commits'.format(pr
)).json()
13 return [c
['sha'] for c
in res
]
14 except (ValueError, requests
.exceptions
.HTTPError
) as e
:
21 subprocess
.check_call(cmd
)
22 except subprocess
.CalledProcessError
as e
:
27 a
= argparse
.ArgumentParser()
28 action
= a
.add_mutually_exclusive_group(required
=True)
30 '-b', '--backport-unto', metavar
='REF', nargs
=1, help='Backport, using '
31 'cherry-pick, all commits from PULL_REQUEST onto REF. This is done on a '
32 'branch called "backport-PULL_REQUEST-to-basename(REF)". When the cherry-pick fails, solve '
33 'the conflict as usual and run "git cherry-pick --continue --allow-empty"')
35 '-m', '--merge-into', metavar
='REF', nargs
=1, help='Take the backport-'
36 'PULL_REQUEST branch and merge it into REF')
38 'pull_request', metavar
='PULL_REQUEST', type=int,
39 help='The PR number to backport')
43 if args
.backport_unto
:
44 command
= ['git', 'checkout', '-b',
45 'backport-{}-to-{}'.format(args
.pull_request
, args
.backport_unto
[0].split('/')[-1]), args
.backport_unto
[0]]
48 commits
= get_commits(args
.pull_request
)
49 command
= ['git', 'cherry-pick', '-x', '--allow-empty'] + commits
53 command
= ['git', 'checkout', args
.merge_into
[0]]
56 command
= ['git', 'merge', '--no-ff',
57 'backport-{}-to-{}'.format(args
.pull_request
, args
.merge_into
[0].split('/')[-1]), '-m',
58 'Backport #{}'.format(args
.pull_request
)]