Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add a script to automate stable porting
- Loading branch information
Showing
1 changed file
with
34 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import os | ||
from subprocess import CalledProcessError | ||
from subprocess import check_output | ||
|
||
import requests | ||
import yaml | ||
|
||
s = requests.Session() | ||
with open(os.path.expanduser('~/.config/hub')) as f: | ||
config = yaml.load(f)['github.com'][0] | ||
s.auth = config['user'], config['oauth_token'] | ||
|
||
os.system("git fetch --all") | ||
r = s.get("https://api.github.com/search/issues?q=label:\"port%20to%20stable\"+repo:buildbot/buildbot") | ||
to_port = r.json() | ||
summary = "" | ||
for pr in to_port['items']: | ||
r = s.get("https://api.github.com/repos/buildbot/buildbot/pulls/{number}/commits".format(**pr)) | ||
commits = r.json() | ||
for c in commits: | ||
title = c['commit']['message'].split("\n")[0] | ||
try: | ||
check_output("git cherry-pick {sha} 2>&1".format(**c), shell=True) | ||
except CalledProcessError as e: | ||
os.system("git diff") | ||
os.system("git reset --hard HEAD 2>&1 >/dev/null") | ||
if '--allow-empty' in e.output: | ||
continue | ||
if 'fatal: bad object' in e.output: | ||
continue | ||
print "cannot automatically cherry-pick", pr['number'], c['sha'], title,e.output | ||
else: | ||
summary += "\n#{number}: {title}".format(number=pr['number'], title=title , **c) | ||
print summary |