Closed simonw closed 4 years ago
This suggests that commit["author"]
can be None
in some cases?
Commits aren't always associated with a GitHub user. For example, perhaps a friend of mine and I were working on a project together. I have a GitHub account and my friend doesn't. If we both add commits to the repository using our own email addresses and names and then I push the repository to GitHub, my commits will be associated with my GitHub user account but my friends' commits will show up with
author
andcommitter
asnull
.
I need to find an example before I work on this.
[
{
"sha": "a8dc914089d399d9b522ebb51b67f9ac2e8aa6b0",
"node_id": "MDY6Q29tbWl0OTMyMDk6YThkYzkxNDA4OWQzOTlkOWI1MjJlYmI1MWI2N2Y5YWMyZThhYTZiMA==",
"commit": {
"author": {
"name": "Simon Willison",
"email": "simon@...",
"date": "2008-12-18T23:17:12Z"
},
"committer": {
"name": "Simon Willison",
"email": "simon@...",
"date": "2008-12-18T23:17:12Z"
},
"message": "First commit",
"tree": {
"sha": "ac2dfb75e2592c59165c2880f3f7a16dafd452a1",
"url": "https://api.github.com/repos/simonw/simonw.github.com/git/trees/ac2dfb75e2592c59165c2880f3f7a16dafd452a1"
},
"url": "https://api.github.com/repos/simonw/simonw.github.com/git/commits/a8dc914089d399d9b522ebb51b67f9ac2e8aa6b0",
"comment_count": 0,
"verification": {
"verified": false,
"reason": "unsigned",
"signature": null,
"payload": null
}
},
"url": "https://api.github.com/repos/simonw/simonw.github.com/commits/a8dc914089d399d9b522ebb51b67f9ac2e8aa6b0",
"html_url": "https://github.com/simonw/simonw.github.com/commit/a8dc914089d399d9b522ebb51b67f9ac2e8aa6b0",
"comments_url": "https://api.github.com/repos/simonw/simonw.github.com/commits/a8dc914089d399d9b522ebb51b67f9ac2e8aa6b0/comments",
"author": null,
"committer": null,
"parents": []
}
]
So it turns out "author"
and "committer"
on the commit are null
if the email address in the nested "commit"
doesn't match an existing GitHub user.
Maybe I should be storing the nested data somewhere as well?
I could pull a pk-hashed version of the name/email into separate raw_author
and raw_committer
columns perhaps - against a commit_authors
table. Could be interesting.
I implemented the raw_authors
idea.
Got this running the
commits
command from cron.