Python/Github
DBS
davanand.bahall at gmail.com
Mon Aug 24 16:14:03 EDT 2015
Hello,
I'm trying to retrieve the number of commits and changed files on all pull requests submitted to a branch.
The call to get all the pull requests is GET /repos/:owner/:repo/pulls, but it does not return "commits" or "changed_files".
The call that returns number of commits and changed files is GET /repos/:owner/:repo/pulls/:number.
Any guidance on how I can modify the call below to include commits and changed files on all pull requests?
#!/usr/bin/env python
import json
import requests
import datetime
import sys
import codecs
sys.stdout = codecs.getwriter('utf8')(sys.stdout)
sys.stderr = codecs.getwriter('utf8')(sys.stderr)
OAUTH_KEY = "xxxxxxxxxxxxxxxxxxx"
repos = ['my-repo']
# List pull request
def list_pr():
for repo in repos:
r = requests.get('https://api.github.com/repos/owner/%s/pulls' % repo, auth=('token', OAUTH_KEY))
data = r.json()
for i in data:
print "\nUser: " + i['user']['login'] + '\n' + "Number: " + str(i['number']) + '\n' + "Time created: " + i['created_at'] + '\n' + "Title: " + i['title'] + '\n' + "Body: " + i['body'] + '\n'
list_pr()
More information about the Python-list
mailing list