DBS davanand.bahall at
Mon Aug 24 22:14:03 CEST 2015


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('' % 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'


More information about the Python-list mailing list