Skip to content

Commit

Permalink
Merge pull request #2 from kunaaljain/master
Browse files Browse the repository at this point in the history
Better Description
  • Loading branch information
yangl1996 committed Jun 17, 2015
2 parents 63c8cd3 + f917731 commit a4d9a3c
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion server.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,11 @@
pagureRepo = "docs-test"
local_repo_path = '/root/doc-test'

githubToken = "token "
githubHeader = {"Authorization": githubToken}
githubUsername = "kunaaljain"
githubRepo = "centos-docs"

# TODO: now can't handle special character (Pagure don't support), should auto delete special characters

class MyServer(BaseHTTPRequestHandler):
Expand All @@ -35,7 +40,15 @@ def do_POST(self):
# TODO: now containing all the metadata in the title, should use a more elegant solution
if not info['content']:
info['content'] = "*No description provided.*"
pagure_payload = {'title': pagure_title, 'issue_content': info['content']}
PR_id = str(info['id'])
r = requests.get("https://api.github.com/repos/{}/{}/pulls/{}/files".format(githubUsername, githubRepo, PR_id), headers=githubHeader)
data = json.loads(r.text)
filelist = ''
for i in data:
filelist += "###{}\n\n".format(i['filename'])

pagure_content = "##Files Modified\n\n{}\n\n##PR ID : #{}\n\n##Creator : {}\n\n##Description\n\n{}\n\n".format(filelist,PR_id,info['creator'],info['content'])
pagure_payload = {'title': pagure_title, 'issue_content': pagure_content}
pagure_URL = "https://pagure.io/api/0/" + pagureRepo + "/new_issue"
pagure_head = {"Authorization": pagureToken}
r = requests.post(pagure_URL, data=pagure_payload, headers=pagure_head)
Expand Down

0 comments on commit a4d9a3c

Please sign in to comment.