[PYTHON] When merging via pull request, there is no committer information in the response from Github API

Should be in the Github API documentation There is a state where the content of the response cannot be taken, I was investigating the cause of what was wrong, but I still didn't understand, so I went home and checked.

Check the response of / repos /: owner /: repo / commits of Github API. http://developer.github.com/v3/repos/commits/

First, let's get a token using OAuth.

curl https://api.github.com/authorizations \
--user "futoase" \
--data '{"scopes": ["repo"], "note": "Test"}'

Reference

Since it is difficult to understand what is wrong with the library (Is it the influence of the parsing method or singleton on the response contents of the library) Pull text data via curl and pull it Check the contents by running the json parser of Python. (For the response, the header part is deleted)

... as an example, get the commits of isaacs' npm repository.

curl -i "https://api.github.com/repos/isaacs/npm/commits?access_token={access_token}" > npm

Cut out the body part of the response, parse json and check the contents.

cat npm | python -mjson.tool

Perth is done properly. So check if there is a committer key.

verify.py


#!/usr/bin/env python
# -*- coding:utf-8 -*-

import json
import sys


def parse(file_name):
    with open(file_name, 'r') as f:
        results = json.loads(f.read())

    for result in results:
        if result.get('committer') is None:
            print('\ncommitter is None: ' + result.get('sha'))
        else:
            print('.', end="")


if __name__ == '__main__':
    parse(sys.argv[1])

I will feed the file that I had no problem with parsing earlier.

./verify.py npm

When I turned it, 3 out of 30 cases, the result was that there was no committer. (Ignore pagination etc.)

............…..
commiter is None: 4638a792fda9a322c4084a46728ebcc9cdab0036
commiter is None: e9e1db1cafcc7e311ddbd8137ae3b74857768469
.
commiter is None: 94de57821d58f3e36a9747f0212f9d4545a896e7

As a test, let's check e9e1db1.

https://api.github.com/repos/isaacs/npm/commits/e9e1db1cafcc7e311ddbd8137ae3b74857768469

committer: null.

I wonder why, check the contents of the commit from git log.

git log -p e9e1db1cafcc7e311ddbd8137ae3b74857768469

commit e9e1db1cafcc7e311ddbd8137ae3b74857768469
Author: Domenic Denicola <[email protected]>
Date: Mon Jan 28 03:10:42 2013 -0500

    Fix bug in prettyWhere calculation

Let's take a look at the Pull Request based on the commit log ...

https://github.com/isaacs/npm/pull/3100

It was in Pull Request. Check the contents of other commit logs that are `` `committer: null```.

https://api.github.com/repos/isaacs/npm/commits/4638a792fda9a322c4084a46728ebcc9cdab0036

Look for Pull Request. https://github.com/isaacs/npm/pull/3103 was.

https://api.github.com/repos/isaacs/npm/commits/94de57821d58f3e36a9747f0212f9d4545a896e7

Look for Pull Request. https://github.com/isaacs/npm/pull/3097 was.

Check the response content of the API about the contents of the commit that was normally committed, not merged via Pull Request (I'm not sure what I wrote ...).

https://api.github.com/repos/isaacs/npm/commits/4f511b99520b5fc76e6bf8e1c44bf71423fddda4

The committer contains the information. If you think about it, it's natural, but as an API response, Because there is no way to tell if the committer is null or not Don't expect reponse [: committer] to come, just use response [: author] ...

Recommended Posts

When merging via pull request, there is no committer information in the response from Github API
Call github api in python to get pull request information
What to do when there is no response due to Proxy setting in Python web scraping
Unfortunately there is no sense of unity in the where method
I tried using the COTOHA API (there is code on GitHub)
[Python] Whiten the parts that turn black when there is no data in the Choropleth map of Folium.
There is no switch in python
What to do when the result downloaded via scrapy is in English
When the target is Ubuntu 16.04 in Ansible
Is there NaN in the pandas DataFrame?