forked from FNALbuild/cms-bot
-
Notifications
You must be signed in to change notification settings - Fork 0
/
auto-create-pull-requests
executable file
·56 lines (53 loc) · 1.58 KB
/
auto-create-pull-requests
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
#!/usr/bin/env python
# Creates pull requests to automatically forward port from one release to another.
from __future__ import print_function
from github import Github, GithubException
from sys import exit
from os.path import expanduser
from socket import setdefaulttimeout
setdefaulttimeout(120)
# Mappings between releases for CMSSW
MAPPINGS = {
"cmssw": [
# CMSSW_6_2_X
("CMSSW_6_2_X", "CMSSW_6_2_X_SLHC"),
# CMSSW_7_0_X
("CMSSW_7_0_X", "CMSSW_7_1_X"),
# CMSSW_7_1_X
("CMSSW_7_1_X", "CMSSW_7_2_X"),
# CMSSW_7_2_X
("CMSSW_7_2_X", "CMSSW_7_3_X"),
],
"cmsdist": [
# CMSSW_7_0_X
# CMSSW_7_1_X
# CMSSW_7_2_X
]
}
if __name__ == "__main__":
from os import environ
gh = Github(login_or_token=environ['GITHUBTOKEN'])
for repo in MAPPINGS:
try:
gh_repo = gh.get_organization("cms-sw").get_repo(repo)
except:
print("Could not find repository.")
exit(0)
for (head, base) in MAPPINGS[repo]:
title = "Forward port %s into %s" % (head, base)
pr = None
try:
pr = gh_repo.create_pull(title=title,
body="",
base=base,
head=head)
except GithubException as e:
if e.data[u"errors"][0][u"message"].startswith("No commits between"):
print("%s already in %s" % (head, base))
elif e.data[u"errors"][0][u"message"].startswith("A pull request already exists"):
print("%s is already pending for merge in %s" % (head, base))
else:
print(e.data)
exit(1)
if pr:
print(pr)