forked from cms-sw/cms-bot
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathquery-new-pull-requests
executable file
·35 lines (29 loc) · 1.43 KB
/
query-new-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
#!/usr/bin/env python
from github import Github
from os.path import expanduser
from optparse import OptionParser
from categories import CMSSW_CATEGORIES, CMSSW_L2
from datetime import datetime, timedelta
import re
if __name__ == "__main__":
parser = OptionParser(usage="%prog <since-n-seconds>")
parser.add_option("--repository", "-r", dest="repository", type=str, default="cmssw")
parser.add_option("--tests-pending", "-t", action="store_true", dest="only_tests_pending" , \
help="Only show the pull requests that are pending for tests")
parser.add_option("--only-issues", "-i", action="store_true", dest="only_issues" , \
help="Only show actual issues")
opts, args = parser.parse_args()
if not len(args):
parser.error("Please specify the number of seconds since you want updates")
since = datetime.utcnow() - timedelta(seconds=int(args[0]))
gh = Github(login_or_token=open(expanduser("~/.github-token")).read().strip())
repo = gh.get_repo( "cms-sw/" + opts.repository )
if opts.only_tests_pending:
queried_labels = []
queried_labels.append( repo.get_label( "tests-pending" ) )
issues = repo.get_issues( state="open" , labels=queried_labels , sort="updated" , since=since )
else:
issues = repo.get_issues(state="open", sort="updated", since=since)
if opts.only_issues:
issues = [ i for i in issues if not i.pull_request ]
print " ".join([str(x.number) for x in issues])