Receiving messages from committer

I am trying to get the email addresses of project committers for specific files. After creating a query that finds code files in a list of repositories that match certain criteria, I get the correct results as code_results (of type CodeSearchResult). Now, to try and access the commit information, I do the following

for code_result in code_results:
            repository = code_result.repository
            file_path = code_result.path
            commits = repository.commits(path=file_path)
            for commit in commits:
                if commit.committer is not None:
                    print commit.committer

      

The problem is that trying to get email via commit.committer.email always returns None, even though the documentation states that the commit contains a committer message. I also tried the author instead of the committer as the documentation says the author is the file containing the letter, but I'm not sure what these keys are.

Thank!

+3


source to share


1 answer


Many GitHub endpoints that return lists only return partial objects in a listing. It's weird that a committer or author would never be honest, but you could try:

for commit in commits:
    commit = commit.refresh()
    if commit.committer is not None:
        print commit.committer

      

However, when testing this on github3.py, I cannot reproduce the issue. I did



repository = github3.repository('sigmavirus24', 'github3.py')
for commit in repository.commits(path='setup.py'):
     print(commit.committer)
     print(commit.author)

      

And with the exception of one commit, both were always present. It was from this commit where the user did not have a GitHub account. However, I can check commit.commit

to get the raw data about the git commit object itself. It has an object committer

and author

, see

>>> commit.commit.committer
{u'date': u'2013-09-05T02:23:17Z', u'name': u'Barry Morrison and Ian Cordasco', u'email': u'graffatcolmingov+bmorriso@gmail.com'}
>>> commit.commit.author
{u'date': u'2013-09-05T02:23:17Z', u'name': u'Barry Morrison and Ian Cordasco', u'email': u'graffatcolmingov+bmorriso@gmail.com'}

      

+1


source







All Articles