Merge pull request #4 from JayFoxRox/http
Use HTTP headers and params, show status
This commit is contained in:
commit
fb8a8b01f4
16
tag_build.py
16
tag_build.py
@ -31,6 +31,14 @@ MAIN_REPO = PULL_REPOS[1]
|
|||||||
PUSH_REPO = 'git@github.com:citra-emu/citra-bleeding-edge'
|
PUSH_REPO = 'git@github.com:citra-emu/citra-bleeding-edge'
|
||||||
# PUSH_REPO = 'git@github.com:jroweboy/lemon'
|
# PUSH_REPO = 'git@github.com:jroweboy/lemon'
|
||||||
|
|
||||||
|
GITHUB_API_HEADERS = {
|
||||||
|
'User-Agent': 'citra-emu/lemonbot'
|
||||||
|
}
|
||||||
|
GITHUB_API_PARAMS = {
|
||||||
|
'client_id': 'xxxx',
|
||||||
|
'client_secret': 'yyyy'
|
||||||
|
}
|
||||||
|
|
||||||
class TagMergeBot:
|
class TagMergeBot:
|
||||||
''' Fetches all the pull requests on a repository and merges all the pull requests with a specified tag on them. '''
|
''' Fetches all the pull requests on a repository and merges all the pull requests with a specified tag on them. '''
|
||||||
def __init__(self, main_repo, pull_repos, push_repo):
|
def __init__(self, main_repo, pull_repos, push_repo):
|
||||||
@ -67,15 +75,15 @@ class TagMergeBot:
|
|||||||
self.current_prs = {}
|
self.current_prs = {}
|
||||||
for repo in self.repos:
|
for repo in self.repos:
|
||||||
self.current_prs[repo['remote_name']] = []
|
self.current_prs[repo['remote_name']] = []
|
||||||
res = requests.get(GITHUB_API+'/{owner}/{repo}/issues?labels={labels}&per_page=100'.format(labels=LABEL_TO_FETCH, owner=repo['owner'], repo=repo['name']))
|
res = requests.get(GITHUB_API+'/{owner}/{repo}/issues?labels={labels}&per_page=100'.format(labels=LABEL_TO_FETCH, owner=repo['owner'], repo=repo['name']), params=GITHUB_API_PARAMS, headers=GITHUB_API_HEADERS)
|
||||||
if res.status_code != 200:
|
if res.status_code != 200:
|
||||||
logger.error("Could not retrive pull requests from github")
|
logger.error("Could not retrive pull requests from github. Status: {status}".format(status=res.status_code))
|
||||||
return False
|
return False
|
||||||
issues = res.json()
|
issues = res.json()
|
||||||
for issue in issues:
|
for issue in issues:
|
||||||
pr_response = requests.get(issue['pull_request']['url'])
|
pr_response = requests.get(issue['pull_request']['url'], params=GITHUB_API_PARAMS, headers=GITHUB_API_HEADERS)
|
||||||
if res.status_code != 200:
|
if res.status_code != 200:
|
||||||
logger.warn("Couldn't fetch the PRs details for PR {pr}".format(pr=issue['']))
|
logger.warn("Couldn't fetch the PRs details for PR {pr}. Status: {status}".format(pr=issue[''], status=res.status_code))
|
||||||
continue
|
continue
|
||||||
pr = pr_response.json()
|
pr = pr_response.json()
|
||||||
self.current_prs[repo['remote_name']].append({"number": pr['number'], "commit": pr['head']['sha'], "ref": pr['head']['ref']})
|
self.current_prs[repo['remote_name']].append({"number": pr['number'], "commit": pr['head']['sha'], "ref": pr['head']['ref']})
|
||||||
|
Loading…
x
Reference in New Issue
Block a user