From bf6057d212e3c744839e60ef852a9419efefc91b 2014-05-21 04:27:45 From: MinRK Date: 2014-05-21 04:27:45 Subject: [PATCH] backport backport_pr.py from master --- diff --git a/tools/backport_pr.py b/tools/backport_pr.py index cf59cda..b8930a3 100755 --- a/tools/backport_pr.py +++ b/tools/backport_pr.py @@ -2,11 +2,11 @@ """ Backport pull requests to a particular branch. -Usage: backport_pr.py branch [PR] +Usage: backport_pr.py branch [PR] [PR2] e.g.: - python tools/backport_pr.py 0.13.1 123 + python tools/backport_pr.py 0.13.1 123 155 to backport PR #123 onto branch 0.13.1 @@ -70,6 +70,11 @@ def backport_pr(branch, num, project='ipython/ipython'): req = urlopen(patch_url) patch = req.read() + lines = description.splitlines() + if len(lines) > 5: + lines = lines[:5] + ['...'] + description = '\n'.join(lines) + msg = "Backport PR #%i: %s" % (num, title) + '\n\n' + description check = Popen(['git', 'apply', '--check', '--verbose'], stdin=PIPE) a,b = check.communicate(patch) @@ -142,6 +147,8 @@ def should_backport(labels=None, milestone=None): if not pr['merged']: print ("Marked PR closed without merge: %i" % pr['number']) continue + if pr['base']['ref'] != 'master': + continue should_backport.add(pr['number']) return should_backport @@ -161,4 +168,9 @@ if __name__ == '__main__': print (pr) sys.exit(0) - sys.exit(backport_pr(sys.argv[1], int(sys.argv[2]))) + for prno in map(int, sys.argv[2:]): + print("Backporting PR #%i" % prno) + rc = backport_pr(sys.argv[1], prno) + if rc: + print("Backporting PR #%i failed" % prno) + sys.exit(rc)