Respect TRAVIS_REPO_SLUG environment variable when checking PRs

develop
lethosor 2015-06-14 11:54:25 -04:00
parent d07bf6f8ed
commit 4c3ae91e98
1 changed files with 6 additions and 2 deletions

@ -5,14 +5,18 @@ else:
from urllib.request import urlopen
from urllib.error import HTTPError
try:
repo = os.environ.get('TRAVIS_REPO_SLUG', 'dfhack/dfhack').lower()
pr_id = int(os.environ.get('TRAVIS_PULL_REQUEST', 'false'))
except ValueError:
print('Not a pull request')
sys.exit(0)
print('Pull request %i' % pr_id)
print('Pull request %s#%i' % (repo, pr_id))
if repo != 'dfhack/dfhack':
print('Not in dfhack/dfhack')
sys.exit(0)
res = {}
try:
res = json.loads(urlopen('https://api.github.com/repos/dfhack/dfhack/pulls/%i' % pr_id).read().decode('utf-8'))
res = json.loads(urlopen('https://api.github.com/repos/%s/pulls/%i' % (repo, pr_id)).read().decode('utf-8'))
except ValueError:
pass
except HTTPError: