Skip to content

Commit

Permalink
Migrate cherrypick_pr to python3 (#14900)
Browse files Browse the repository at this point in the history
  • Loading branch information
kvch committed Dec 3, 2019
1 parent 28ffc35 commit 20e1ecc
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions dev-tools/cherrypick_pr
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env python
#!/usr/bin/env python3
"""Cherry pick and backport a PR"""
from __future__ import print_function

Expand Down Expand Up @@ -47,7 +47,7 @@ def main():
formatter_class=argparse.RawDescriptionHelpFormatter,
epilog=usage)
parser.add_argument("to_branch",
help="To branch (e.g 5.0)")
help="To branch (e.g 7.x)")
parser.add_argument("pr_number",
help="The PR number being merged (e.g. 2345)")
parser.add_argument("commit_hashes", metavar="hash", nargs="+",
Expand Down Expand Up @@ -131,15 +131,15 @@ def main():
# get the github username from the remote where we pushed
remote_url = check_output("git remote get-url {}".format(remote),
shell=True)
remote_user = re.search("github.com[:/](.+)/beats", remote_url).group(1)
remote_user = re.search("github.com[:/](.+)/beats", str(remote_url)).group(1)

# create PR
request = session.post(base + "/pulls", json=dict(
title="Cherry-pick #{} to {}: {}".format(args.pr_number, args.to_branch, original_pr["title"].encode('utf-8')),
head=remote_user + ":" + tmp_branch,
base=args.to_branch,
body="Cherry-pick of PR #{} to {} branch. Original message: \n\n{}"
.format(args.pr_number, args.to_branch, original_pr["body"].encode('utf-8'))
.format(args.pr_number, args.to_branch, original_pr["body"])
))
if request.status_code > 299:
print("Creating PR failed: {}".format(request.json()))
Expand Down

0 comments on commit 20e1ecc

Please sign in to comment.