forked from cms-sw/cms-bot
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathget-pr-branch
executable file
·38 lines (35 loc) · 1.17 KB
/
get-pr-branch
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#!/usr/bin/env python
from sys import exit, argv, path
from os.path import expanduser,dirname,abspath,join, exists
from github import Github
from socket import setdefaulttimeout
setdefaulttimeout(120)
if __name__ == "__main__":
prId = int(argv[1])
repo = "cms-sw/cmssw"
try: repo = argv[2]
except: pass
gh = Github(login_or_token=open(expanduser("~/.github-token")).read().strip())
try:
pr = gh.get_repo(repo).get_pull(prId)
except Exception as ex:
print "Could not find pull request %s. Maybe this is an issue" % prId
print ex
exit(1)
if pr.base.ref == "master":
from releases import CMSSW_DEVEL_BRANCH
from commands import getstatusoutput
e, o = getstatusoutput("curl -s -L https://cmssdt.cern.ch/SDT/BaselineDevRelease | grep '^CMSSW_'")
if not o: o = CMSSW_DEVEL_BRANCH
print o
else:
pr_branch = pr.base.ref
try:
SCRIPT_DIR = dirname(abspath(argv[0]))
repo_dir = join(SCRIPT_DIR,'repos',repo.replace("-","_"))
if exists(join(repo_dir,"repo_config.py")):
path.insert(0,repo_dir)
import repo_config
pr_branch = repo_config.CMS_BRANCH_MAP[pr.base.ref]
except: pass
print pr_branch