forked from html5rocks/www.html5rocks.com
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmilestone.py
44 lines (30 loc) · 1.14 KB
/
milestone.py
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
import getpass
import sys
import re
from datetime import datetime, timedelta
from optparse import OptionParser
from github import Github
from github.Repository import Repository
from github.GithubException import GithubException
repository = "html5rocks/www.html5rocks.com"
def main():
username = raw_input("Username: ")
password = getpass.getpass()
g = Github(username, password)
repo = g.get_repo(repository)
issues = repo.get_issues(milestone="none", state="open")
for issue in issues:
# Make a new milestone
print "Checking %s" % issue.title
due_on_re = re.search("(due on|due):\s*(\d{4}-\d{2}-\d{2})", issue.body, flags=re.I)
if issue.milestone is not None:
continue
if due_on_re is None:
continue
due_on = datetime.strptime(due_on_re.group(2), "%Y-%m-%d")
milestone = repo.create_milestone("ARTICLE: %s" % issue.title, due_on=due_on)
print "Created milestone: %s" % milestone.url
issue.edit(milestone=milestone)
print "Issue updated with milestone"
if __name__ == "__main__":
main()